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."); } }
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!"); } }