示例#1
0
  public DiscardCardsCommand(IGame theGame, IPlayer player, ResourceBank discardedCards)
      throws IllegalCommandException {
    super(theGame, player);
    this.discardedCards = discardedCards;

    // does the player have enough cards to merit a discard operation
    if (getGame().getGameState() != GameState.Discarding
        || !player.needsToDiscard()
        || !player.canAfford(discardedCards)) {
      throw new IllegalCommandException("Invalid discard command.");
    }
  }
示例#2
0
  public BuyDevCardCommand(IGame game, IPlayer player) throws IllegalCommandException {
    super(game, player, "bought a development card");

    if (!getGame().canBuyDevCard(getPlayer())) {
      throw new IllegalCommandException(
          "Player " + player.getName() + " tried to buy a DevCard illegally!");
    }
  }