From 1b4ed2ebcda4142a3567d23341d4da39a097797f Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Tue, 15 Nov 2011 15:31:21 +0000 Subject: [PATCH] "Memories of Darkness" --- .../gempukku/lotro/cards/PlayConditions.java | 9 +++ .../lotro/cards/set10/dwarven/Card10_002.java | 58 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java index 4d6b06478..2c21f45f1 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java @@ -173,6 +173,15 @@ public class PlayConditions { return game.getModifiersQuerying().hasInitiative(game.getGameState()) == side; } + public static boolean loseInitiative(EffectResult effectResult, Side side) { + if (effectResult.getType() == EffectResult.Type.INITIATIVE_CHANGE) { + InitiativeChangeResult initiativeChangeResult = (InitiativeChangeResult) effectResult; + if (initiativeChangeResult.getSide() != side) + return true; + } + return false; + } + public static boolean canAddThreat(LotroGame game, PhysicalCard card, int count) { return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION) - game.getGameState().getThreats() >= count; } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java new file mode 100644 index 000000000..1f3130b3c --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set10/dwarven/Card10_002.java @@ -0,0 +1,58 @@ +package com.gempukku.lotro.cards.set10.dwarven; + +import com.gempukku.lotro.cards.AbstractPermanent; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.effects.ChoiceEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDiscardEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromHandEffect; +import com.gempukku.lotro.common.*; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.actions.OptionalTriggerAction; +import com.gempukku.lotro.logic.timing.Effect; +import com.gempukku.lotro.logic.timing.EffectResult; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +/** + * Set: Mount Doom + * Side: Free + * Culture: Dwarven + * Twilight Cost: 1 + * Type: Condition • Support Area + * Game Text: To play, spot a Dwarf. Each time you lose initiative (except during the fellowship phase), you may play + * a [DWARVEN] condition from hand or from your discard pile. + */ +public class Card10_002 extends AbstractPermanent { + public Card10_002() { + super(Side.FREE_PEOPLE, 1, CardType.CONDITION, Culture.DWARVEN, Zone.SUPPORT, "Memories of Darkness", true); + } + + @Override + public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) { + return super.checkPlayRequirements(playerId, game, self, twilightModifier, ignoreRoamingPenalty) + && PlayConditions.canSpot(game, Race.DWARF); + } + + @Override + public List getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) { + if (PlayConditions.loseInitiative(effectResult, Side.FREE_PEOPLE) + && game.getGameState().getCurrentPhase() != Phase.FELLOWSHIP + && ( + PlayConditions.canPlayFromHand(playerId, game, Culture.DWARVEN, CardType.CONDITION) + || PlayConditions.canPlayFromDiscard(playerId, game, Culture.DWARVEN, CardType.CONDITION))) { + OptionalTriggerAction action = new OptionalTriggerAction(self); + List possibleEffects = new LinkedList(); + possibleEffects.add( + new ChooseAndPlayCardFromHandEffect(playerId, game.getGameState().getHand(playerId), Culture.DWARVEN, CardType.CONDITION)); + possibleEffects.add( + new ChooseAndPlayCardFromDiscardEffect(playerId, game.getGameState().getDiscard(playerId), Culture.DWARVEN, CardType.CONDITION)); + action.appendEffect( + new ChoiceEffect(action, playerId, possibleEffects)); + return Collections.singletonList(action); + } + return null; + } +}