diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set20/gandalf/Card20_155.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set20/gandalf/Card20_155.java new file mode 100644 index 000000000..af5f88d8a --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set20/gandalf/Card20_155.java @@ -0,0 +1,69 @@ +package com.gempukku.lotro.cards.set20.gandalf; + +import com.gempukku.lotro.cards.AbstractEvent; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.actions.PlayEventAction; +import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; +import com.gempukku.lotro.common.*; +import com.gempukku.lotro.filters.Filters; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.decisions.CardsSelectionDecision; +import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; +import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision; +import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect; +import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect; + +import java.util.Set; + +/** + * 3 + * Discernment + * Gandalf Event • Manuever + * Spell. + * Exert Gandalf twice and add X to discard up to four Shadow conditions, where X is the combined twilight cost of those conditions. + */ +public class Card20_155 extends AbstractEvent { + public Card20_155() { + super(Side.FREE_PEOPLE, 3, Culture.GANDALF, "Discernment", Phase.MANEUVER); + addKeyword(Keyword.SPELL); + } + + @Override + public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int withTwilightRemoved, int twilightModifier, boolean ignoreRoamingPenalty, boolean ignoreCheckingDeadPile) { + return super.checkPlayRequirements(playerId, game, self, withTwilightRemoved, twilightModifier, ignoreRoamingPenalty, ignoreCheckingDeadPile) + && PlayConditions.canExert(self, game, 2, Filters.gandalf); + } + + @Override + public PlayEventAction getPlayCardAction(final String playerId, final LotroGame game, final PhysicalCard self, final int twilightModifier, boolean ignoreRoamingPenalty) { + final PlayEventAction action = new PlayEventAction(self); + action.appendCost( + new ChooseAndExertCharactersEffect(action, playerId, 1, 1, 2, Filters.gandalf)); + action.appendCost( + new PlayoutDecisionEffect(playerId, + new IntegerAwaitingDecision(1, "Choose X", 0, Integer.MAX_VALUE, 0) { + @Override + public void decisionMade(String result) throws DecisionResultInvalidException { + final int x = getValidatedResult(result); + action.appendEffect( + new PlayoutDecisionEffect(playerId, + new CardsSelectionDecision(1, "Choose up to 4 Shadow conditions with combined twilight cost of up to "+x, + Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Side.SHADOW, CardType.CONDITION, Filters.canBeDiscarded(self)), 0, 4) { + @Override + public void decisionMade(String result) throws DecisionResultInvalidException { + Set selectedCardsByResponse = getSelectedCardsByResponse(result); + int twilightTotal = 0; + for (PhysicalCard physicalCard : selectedCardsByResponse) + twilightTotal+=physicalCard.getBlueprint().getTwilightCost(); + if (twilightTotal>x) + throw new DecisionResultInvalidException("You have chosen conditions of combined twilight cost of "+twilightTotal); + action.appendEffect( + new DiscardCardsFromPlayEffect(self, Filters.in(selectedCardsByResponse))); + } + })); + } + })); + return action; + } +}