From f7bb4c6c6f103e9c05e877142e862fe75562a331 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Mon, 12 Dec 2011 11:34:33 +0000 Subject: [PATCH] "Countless Companies" --- .../gempukku/lotro/cards/PlayConditions.java | 10 +++ .../lotro/cards/set12/men/Card12_058.java | 62 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/men/Card12_058.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 0068b7da1..f83acee74 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 @@ -247,6 +247,16 @@ public class PlayConditions { return false; } + public static boolean canPlayFromStacked(String playerId, LotroGame game, int withTwilightRemoved, Filterable stackedOn, Filterable... filters) { + final Collection matchingStackedOn = Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), stackedOn); + for (PhysicalCard stackedOnCard : matchingStackedOn) { + if (Filters.filter(game.getGameState().getStackedCards(stackedOnCard), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game, withTwilightRemoved, 0, false, false))).size() > 0) + return true; + } + + return false; + } + public static boolean canPlayFromDiscard(String playerId, LotroGame game, Filterable... filters) { if (game.getModifiersQuerying().hasFlagActive(game.getGameState(), ModifierFlag.CANT_PLAY_FROM_DISCARD_OR_DECK)) return false; diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/men/Card12_058.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/men/Card12_058.java new file mode 100644 index 000000000..f00d0836d --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/men/Card12_058.java @@ -0,0 +1,62 @@ +package com.gempukku.lotro.cards.set12.men; + +import com.gempukku.lotro.cards.AbstractPermanent; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.TriggerConditions; +import com.gempukku.lotro.cards.effects.RemoveTwilightEffect; +import com.gempukku.lotro.cards.effects.StackCardFromDiscardEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromStackedEffect; +import com.gempukku.lotro.common.*; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.GameUtils; +import com.gempukku.lotro.logic.actions.ActivateCardAction; +import com.gempukku.lotro.logic.timing.Action; +import com.gempukku.lotro.logic.timing.EffectResult; +import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult; + +import java.util.Collections; +import java.util.List; + +/** + * Set: Black Rider + * Side: Shadow + * Culture: Men + * Twilight Cost: 0 + * Type: Condition • Support Area + * Game Text: Response: If a [MEN] possession is discarded from play, stack it here. Shadow: Remove (1) to play + * a possession stacked here as if from hand. + */ +public class Card12_058 extends AbstractPermanent { + public Card12_058() { + super(Side.SHADOW, 0, CardType.CONDITION, Culture.MEN, Zone.SUPPORT, "Countless Companies"); + } + + @Override + public List getOptionalInPlayAfterActions(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) { + if (TriggerConditions.forEachDiscardedFromPlay(game, effectResult, Culture.MEN, CardType.POSSESSION, Zone.DISCARD)) { + DiscardCardsFromPlayResult result = (DiscardCardsFromPlayResult) effectResult; + final PhysicalCard discardedCard = result.getDiscardedCard(); + ActivateCardAction action = new ActivateCardAction(self); + action.setText("Stack " + GameUtils.getCardLink(discardedCard)); + action.appendEffect( + new StackCardFromDiscardEffect(discardedCard, self)); + return Collections.singletonList(action); + } + return null; + } + + @Override + protected List getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) { + if (PlayConditions.canUseShadowCardDuringPhase(game, Phase.SHADOW, self, 1) + && PlayConditions.canPlayFromStacked(playerId, game, 1, self, CardType.POSSESSION)) { + ActivateCardAction action = new ActivateCardAction(self); + action.appendCost( + new RemoveTwilightEffect(1)); + action.appendEffect( + new ChooseAndPlayCardFromStackedEffect(playerId, self, CardType.POSSESSION)); + return Collections.singletonList(action); + } + return null; + } +}