From 447b4ce472d22de8424f6e84908764b5e87a76c9 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Fri, 23 Sep 2011 15:32:04 +0000 Subject: [PATCH] If an action or effect has play card from non-deck zone as an effect or a cost, you have to have a playable card of type in that zone before you start playing the action or effect. If you use an action or effect of that type, you HAVE to choose a matching card and play it if possible, but only from cards that were in that zone when you started playing that action or effect. Examples - you can't use Morgul Gates without playable Nazgul in hand and you HAVE to play it, you can't discard 3 cards using They Are Coming without an Orc in discard, if you have an Orc and use it, the Orc you play MAY NOT be one of those you discarded as a cost. --- .../ChooseAndPlayCardFromHandEffect.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ChooseAndPlayCardFromHandEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ChooseAndPlayCardFromHandEffect.java index 384a041af..a7c4df9f2 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ChooseAndPlayCardFromHandEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ChooseAndPlayCardFromHandEffect.java @@ -4,7 +4,7 @@ import com.gempukku.lotro.filters.Filter; 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.ArbitraryCardsSelectionDecision; +import com.gempukku.lotro.logic.decisions.CardsSelectionDecision; import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; import com.gempukku.lotro.logic.timing.UnrespondableEffect; @@ -32,18 +32,24 @@ public class ChooseAndPlayCardFromHandEffect extends UnrespondableEffect { return "Play card from hand"; } + @Override + public boolean canPlayEffect(LotroGame game) { + return getPlayableInHandCards(game).size() > 0; + } + + private List getPlayableInHandCards(LotroGame game) { + return Filters.filter(game.getGameState().getHand(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter, Filters.playable(game, _twilightModifier)); + } + @Override public void doPlayEffect(final LotroGame game) { - List discard = Filters.filter(game.getGameState().getHand(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter, Filters.playable(game, _twilightModifier)); + List playableInHand = getPlayableInHandCards(game); game.getUserFeedback().sendAwaitingDecision(_playerId, - new ArbitraryCardsSelectionDecision(1, "Choose a card to play", discard, 1, 1) { + new CardsSelectionDecision(1, "Choose a card to play", playableInHand, 1, 1) { @Override public void decisionMade(String result) throws DecisionResultInvalidException { - List selectedCards = getSelectedCardsByResponse(result); - if (selectedCards.size() > 0) { - PhysicalCard selectedCard = selectedCards.get(0); - game.getActionsEnvironment().addActionToStack(selectedCard.getBlueprint().getPlayCardAction(_playerId, game, selectedCard, _twilightModifier)); - } + final PhysicalCard selectedCard = getSelectedCardsByResponse(result).get(0); + game.getActionsEnvironment().addActionToStack(selectedCard.getBlueprint().getPlayCardAction(_playerId, game, selectedCard, _twilightModifier)); } }); }