コード例 #1
0
ファイル: DiscardCardsCommand.java プロジェクト: 255/catan
  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
ファイル: BuyDevCardCommand.java プロジェクト: 255/catan
  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!");
    }
  }