From 71f4108c46e7107392b0ee411fd61ba9087c2bd4 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Fri, 27 Jan 2012 16:04:35 +0000 Subject: [PATCH] "Lying Counsel" --- .../lotro/cards/actions/PreventSubAction.java | 6 +- .../cards/effects/PreventableEffect.java | 14 ++- .../lotro/cards/set15/men/Card15_085.java | 88 +++++++++++++++++++ 3 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/men/Card15_085.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PreventSubAction.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PreventSubAction.java index 8a815e5d2..3876f459c 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PreventSubAction.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/actions/PreventSubAction.java @@ -15,14 +15,16 @@ public class PreventSubAction extends SubAction { private Effect _effectToExecute; private Iterator _choicePlayers; private PreventableEffect.PreventionCost _preventionCost; + private Effect _insteadEffect; private Effect _playerPreventionCost; - public PreventSubAction(Action action, Effect effectToExecute, Iterator choicePlayers, PreventableEffect.PreventionCost preventionCost) { + public PreventSubAction(Action action, Effect effectToExecute, Iterator choicePlayers, PreventableEffect.PreventionCost preventionCost, Effect insteadEffect) { super(action); _effectToExecute = effectToExecute; _choicePlayers = choicePlayers; _preventionCost = preventionCost; + _insteadEffect = insteadEffect; appendEffect(new DecideIfPossible()); } @@ -65,6 +67,8 @@ public class PreventSubAction extends SubAction { protected void doPlayEffect(LotroGame game) { if (!_playerPreventionCost.wasCarriedOut()) appendEffect(new DecideIfPossible()); + else if (_insteadEffect != null) + appendEffect(_insteadEffect); } } } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PreventableEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PreventableEffect.java index fa9cedf5e..de7bc3639 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PreventableEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PreventableEffect.java @@ -15,20 +15,26 @@ import java.util.List; public class PreventableEffect extends AbstractSubActionEffect { private CostToEffectAction _action; private Effect _effectToExecute; + private Effect _insteadEffect; private Iterator _choicePlayers; private PreventionCost _preventionCost; public PreventableEffect(CostToEffectAction action, Effect effectToExecute, String[] choicePlayers, PreventionCost preventionCost) { - this(action, effectToExecute, Arrays.asList(choicePlayers), preventionCost); + this(action, effectToExecute, Arrays.asList(choicePlayers), preventionCost, null); } public PreventableEffect(CostToEffectAction action, Effect effectToExecute, String choicePlayer, PreventionCost preventionCost) { - this(action, effectToExecute, Collections.singletonList(choicePlayer), preventionCost); + this(action, effectToExecute, Collections.singletonList(choicePlayer), preventionCost, null); } - public PreventableEffect(CostToEffectAction action, Effect effectToExecute, List choicePlayers, PreventionCost preventionCost) { + public PreventableEffect(CostToEffectAction action, Effect effectToExecute, String choicePlayer, PreventionCost preventionCost, Effect insteadEffect) { + this(action, effectToExecute, Collections.singletonList(choicePlayer), preventionCost, insteadEffect); + } + + public PreventableEffect(CostToEffectAction action, Effect effectToExecute, List choicePlayers, PreventionCost preventionCost, Effect insteadEffect) { _action = action; _effectToExecute = effectToExecute; + _insteadEffect = insteadEffect; _choicePlayers = choicePlayers.iterator(); _preventionCost = preventionCost; } @@ -50,7 +56,7 @@ public class PreventableEffect extends AbstractSubActionEffect { @Override public void playEffect(LotroGame game) { - final PreventSubAction subAction = new PreventSubAction(_action, _effectToExecute, _choicePlayers, _preventionCost); + final PreventSubAction subAction = new PreventSubAction(_action, _effectToExecute, _choicePlayers, _preventionCost, _insteadEffect); processSubAction(game, subAction); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/men/Card15_085.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/men/Card15_085.java new file mode 100644 index 000000000..fa073bae8 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/men/Card15_085.java @@ -0,0 +1,88 @@ +package com.gempukku.lotro.cards.set15.men; + +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.AddBurdenEffect; +import com.gempukku.lotro.cards.effects.PreventableEffect; +import com.gempukku.lotro.cards.effects.ReturnCardsToHandEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; +import com.gempukku.lotro.common.Culture; +import com.gempukku.lotro.common.Phase; +import com.gempukku.lotro.common.Race; +import com.gempukku.lotro.common.Side; +import com.gempukku.lotro.filters.Filter; +import com.gempukku.lotro.filters.Filters; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.GameState; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.GameUtils; +import com.gempukku.lotro.logic.actions.SubAction; +import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect; +import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect; +import com.gempukku.lotro.logic.modifiers.ModifiersQuerying; +import com.gempukku.lotro.logic.timing.Effect; + +/** + * Set: The Hunters + * Side: Shadow + * Culture: Men + * Twilight Cost: 1 + * Type: Event • Maneuver + * Game Text: Exert your [MEN] Man and spot an unbound companion bearing 3 or more cards to return each Free Peoples + * card that companion bears to its owner’s hand. + * The Free Peoples player may add a burden to discard those cards instead. + */ +public class Card15_085 extends AbstractEvent { + public Card15_085() { + super(Side.SHADOW, 1, Culture.MEN, "Lying Counsel", Phase.MANEUVER); + } + + @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, Filters.owner(playerId), Culture.MEN, Race.MAN) + && PlayConditions.canSpot(game, Filters.unboundCompanion, + new Filter() { + @Override + public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) { + return gameState.getAttachedCards(physicalCard).size() >= 3; + } + }); + } + + @Override + public PlayEventAction getPlayCardAction(String playerId, LotroGame game, final PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) { + final PlayEventAction action = new PlayEventAction(self); + action.appendCost( + new ChooseAndExertCharactersEffect(action, playerId, 1, 1, Filters.owner(playerId), Culture.MEN, Race.MAN)); + action.appendCost( + new ChooseActiveCardEffect(self, playerId, "Choose an unbound companion", Filters.unboundCompanion, + new Filter() { + @Override + public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) { + return gameState.getAttachedCards(physicalCard).size() >= 3; + } + }) { + @Override + protected void cardSelected(LotroGame game, final PhysicalCard card) { + action.appendEffect( + new PreventableEffect(action, + new ReturnCardsToHandEffect(self, Filters.and(Side.FREE_PEOPLE, Filters.attachedTo(card))) { + @Override + public String getText(LotroGame game) { + return "Return each Free Peoples card attached to " + GameUtils.getCardLink(card); + } + }, game.getGameState().getCurrentPlayerId(), + new PreventableEffect.PreventionCost() { + @Override + public Effect createPreventionCostForPlayer(SubAction subAction, String playerId) { + return new AddBurdenEffect(self, 1); + } + }, new DiscardCardsFromPlayEffect(self, Side.FREE_PEOPLE, Filters.attachedTo(card)) + )); + } + }); + return action; + } +}