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