From 34725eb26eddd97a0e2320b589da20d8911b02cc Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Sat, 22 Oct 2011 21:05:39 +0000 Subject: [PATCH] "Mudeseld" --- .../gempukku/lotro/cards/PlayConditions.java | 11 ++- .../ChooseAndPlayCardFromDeadPileEffect.java | 70 +++++++++++++++++++ .../lotro/cards/set4/gandalf/Card4_106.java | 17 ++--- .../lotro/cards/set6/site/Card6_117.java | 45 ++++++++++++ 4 files changed, 128 insertions(+), 15 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromDeadPileEffect.java create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set6/site/Card6_117.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 48c81c1da..4144e373d 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 @@ -84,7 +84,7 @@ public class PlayConditions { return (!blueprint.isUnique() || ( !Filters.canSpot(gameState, modifiersQuerying, Filters.name(blueprint.getName())) - && (Filters.filter(gameState.getDeadPile(self.getOwner()), gameState, modifiersQuerying, Filters.name(blueprint.getName())).size() == 0))); + && (self.getZone() == Zone.DEAD || (Filters.filter(gameState.getDeadPile(self.getOwner()), gameState, modifiersQuerying, Filters.name(blueprint.getName())).size() == 0)))); } private static int getTotalCompanions(String playerId, GameState gameState, ModifiersQuerying modifiersQuerying) { @@ -93,7 +93,10 @@ public class PlayConditions { } public static boolean checkRuleOfNine(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard self) { - return (getTotalCompanions(self.getOwner(), gameState, modifiersQuerying) < 9); + if (self.getZone() == Zone.DEAD) + return (getTotalCompanions(self.getOwner(), gameState, modifiersQuerying) <= 9); + else + return (getTotalCompanions(self.getOwner(), gameState, modifiersQuerying) < 9); } public static boolean canHealByDiscarding(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard self) { @@ -162,6 +165,10 @@ public class PlayConditions { return Filters.filter(game.getGameState().getHand(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game, twilightModifier))).size() > 0; } + public static boolean canPlayFromDeadPile(String playerId, LotroGame game, Filterable... filters) { + return Filters.filter(game.getGameState().getDeadPile(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game))).size() > 0; + } + public static boolean canPlayFromDiscard(String playerId, LotroGame game, Filterable... filters) { return Filters.filter(game.getGameState().getDiscard(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game))).size() > 0; } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromDeadPileEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromDeadPileEffect.java new file mode 100644 index 000000000..f9be91253 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndPlayCardFromDeadPileEffect.java @@ -0,0 +1,70 @@ +package com.gempukku.lotro.cards.effects.choose; + +import com.gempukku.lotro.common.Filterable; +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.DecisionResultInvalidException; +import com.gempukku.lotro.logic.timing.AbstractEffect; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +public class ChooseAndPlayCardFromDeadPileEffect extends AbstractEffect { + private String _playerId; + private Filter _filter; + private int _twilightModifier; + + public ChooseAndPlayCardFromDeadPileEffect(String playerId, List cardsInDeadPileAtStart, Filterable... filter) { + this(playerId, cardsInDeadPileAtStart, 0, filter); + } + + public ChooseAndPlayCardFromDeadPileEffect(String playerId, List cardsInDeadPileAtStart, int twilightModifier, Filterable... filter) { + _playerId = playerId; + // Card has to be in dead pile when you start playing the card (we need to copy the collection) + _filter = Filters.and(filter, Filters.in(new LinkedList(cardsInDeadPileAtStart))); + _twilightModifier = twilightModifier; + } + + @Override + public String getText(LotroGame game) { + return "Play card from dead pile"; + } + + @Override + public boolean isPlayableInFull(LotroGame game) { + return getPlayableInDeadPile(game).size() > 0; + } + + @Override + public Type getType() { + return null; + } + + @Override + protected FullEffectResult playEffectReturningResult(final LotroGame game) { + Collection deadPile = getPlayableInDeadPile(game); + if (deadPile.size() > 0) { + game.getUserFeedback().sendAwaitingDecision(_playerId, + new ArbitraryCardsSelectionDecision(1, "Choose a card to play", new LinkedList(deadPile), 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)); + } + } + }); + return new FullEffectResult(null, true, true); + } + return new FullEffectResult(null, false, false); + } + + private Collection getPlayableInDeadPile(LotroGame game) { + return Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter, Filters.playable(game, _twilightModifier)); + } +} \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/gandalf/Card4_106.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/gandalf/Card4_106.java index 2cd17fcec..3812e4dcf 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/gandalf/Card4_106.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/gandalf/Card4_106.java @@ -1,8 +1,9 @@ package com.gempukku.lotro.cards.set4.gandalf; import com.gempukku.lotro.cards.AbstractOldEvent; +import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.actions.PlayEventAction; -import com.gempukku.lotro.cards.effects.choose.ChooseArbitraryCardsEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDeadPileEffect; import com.gempukku.lotro.common.Culture; import com.gempukku.lotro.common.Phase; import com.gempukku.lotro.common.Race; @@ -11,8 +12,6 @@ import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; -import java.util.Collection; - /** * Set: The Two Towers * Side: Free @@ -32,7 +31,7 @@ public class Card4_106 extends AbstractOldEvent { && Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ELF)) && Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.GONDOR), Filters.race(Race.MAN)) && Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.DWARF)) - && Filters.filter(game.getGameState().getDeadPile(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.name("Gandalf")).size() > 0; + && PlayConditions.canPlayFromDeadPile(playerId, game, Filters.name("Gandalf")); } @Override @@ -44,15 +43,7 @@ public class Card4_106 extends AbstractOldEvent { public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { PlayEventAction action = new PlayEventAction(self); action.appendEffect( - new ChooseArbitraryCardsEffect(playerId, "Choose Gandalf in dead pile", game.getGameState().getDeadPile(playerId), Filters.name("Gandalf"), 1, 1) { - @Override - protected void cardsSelected(LotroGame game, Collection selectedCards) { - if (selectedCards.size() > 0) { - PhysicalCard gandalf = selectedCards.iterator().next(); - game.getActionsEnvironment().addActionToStack(gandalf.getBlueprint().getPlayCardAction(playerId, game, gandalf, 0)); - } - } - }); + new ChooseAndPlayCardFromDeadPileEffect(playerId, game.getGameState().getDeadPile(playerId), Filters.name("Gandalf"))); return action; } } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set6/site/Card6_117.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set6/site/Card6_117.java new file mode 100644 index 000000000..0510bb37c --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set6/site/Card6_117.java @@ -0,0 +1,45 @@ +package com.gempukku.lotro.cards.set6.site; + +import com.gempukku.lotro.cards.AbstractSite; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDeadPileEffect; +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.actions.ActivateCardAction; +import com.gempukku.lotro.logic.timing.Action; + +import java.util.Collections; +import java.util.List; + +/** + * Set: Ents of Fangorn + * Twilight Cost: 0 + * Type: Site + * Site: 3T + * Game Text: Sanctuary. Fellowship: Exert 3 companions with the Gandalf signet to play an unbound companion from + * your dead pile. + */ +public class Card6_117 extends AbstractSite { + public Card6_117() { + super("Mudeseld", Block.TWO_TOWERS, 3, 0, Direction.RIGHT); + addKeyword(Keyword.SANCTUARY); + } + + @Override + public List getPhaseActions(String playerId, LotroGame game, PhysicalCard self) { + if (PlayConditions.canUseSiteDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self) + && PlayConditions.canExertMultiple(self, game, 1, 3, CardType.COMPANION, Signet.GANDALF) + && PlayConditions.canPlayFromDeadPile(playerId, game, Filters.unboundCompanion)) { + ActivateCardAction action = new ActivateCardAction(self); + action.appendCost( + new ChooseAndExertCharactersEffect(action, playerId, 3, 3, CardType.COMPANION, Signet.GANDALF)); + action.appendEffect( + new ChooseAndPlayCardFromDeadPileEffect(playerId, game.getGameState().getDeadPile(playerId), Filters.unboundCompanion)); + return Collections.singletonList(action); + } + return null; + } +}