From c21d8b0d735e44c21c4c5cecb00e7f49a2513001 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 8 Dec 2011 17:24:31 +0000 Subject: [PATCH] "Attunement" --- ...PutCardsFromDeckBeneathDrawDeckEffect.java | 72 ++++++++++++++++++ .../lotro/cards/set12/elven/Card12_016.java | 73 +++++++++++++++++++ .../lotro/cards/set5/gollum/Card5_028.java | 60 +-------------- 3 files changed, 149 insertions(+), 56 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutCardsFromDeckBeneathDrawDeckEffect.java create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/elven/Card12_016.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutCardsFromDeckBeneathDrawDeckEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutCardsFromDeckBeneathDrawDeckEffect.java new file mode 100644 index 000000000..47e58b47e --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/PutCardsFromDeckBeneathDrawDeckEffect.java @@ -0,0 +1,72 @@ +package com.gempukku.lotro.cards.effects; + +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.actions.SubAction; +import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect; +import com.gempukku.lotro.logic.timing.AbstractSubActionEffect; +import com.gempukku.lotro.logic.timing.Action; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public class PutCardsFromDeckBeneathDrawDeckEffect extends AbstractSubActionEffect { + private Action _action; + private PhysicalCard _source; + private String _playerId; + private Set _cards; + + public PutCardsFromDeckBeneathDrawDeckEffect(Action action, PhysicalCard source, String playerId, Collection cards) { + _action = action; + _source = source; + _playerId = playerId; + _cards = new HashSet(cards); + } + + @Override + public String getText(LotroGame game) { + return null; + } + + @Override + public Type getType() { + return null; + } + + @Override + public boolean isPlayableInFull(LotroGame game) { + return true; + } + + @Override + public void playEffect(LotroGame game) { + SubAction subAction = new SubAction(_action); + subAction.appendEffect( + new ChooseAndPutNextCardFromDeckOnBottomOfDeck(subAction, _cards)); + processSubAction(game, subAction); + } + + private class ChooseAndPutNextCardFromDeckOnBottomOfDeck extends ChooseArbitraryCardsEffect { + private Collection _remainingCards; + private SubAction _subAction; + + public ChooseAndPutNextCardFromDeckOnBottomOfDeck(SubAction subAction, Collection remainingCards) { + super(_playerId, "Choose a card to put on bottom of your deck", remainingCards, 1, 1); + _subAction = subAction; + _remainingCards = remainingCards; + } + + @Override + protected void cardsSelected(LotroGame game, Collection selectedCards) { + for (PhysicalCard selectedCard : selectedCards) { + _subAction.appendEffect( + new PutCardFromDeckOnBottomOfDeckEffect(_source, selectedCard)); + _remainingCards.remove(selectedCard); + if (_remainingCards.size() > 0) + _subAction.appendEffect( + new ChooseAndPutNextCardFromDeckOnBottomOfDeck(_subAction, _remainingCards)); + } + } + } +} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/elven/Card12_016.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/elven/Card12_016.java new file mode 100644 index 000000000..2d33a1840 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/elven/Card12_016.java @@ -0,0 +1,73 @@ +package com.gempukku.lotro.cards.set12.elven; + +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.AddUntilEndOfPhaseModifierEffect; +import com.gempukku.lotro.cards.effects.PutCardsFromDeckBeneathDrawDeckEffect; +import com.gempukku.lotro.cards.effects.RevealTopCardsOfDrawDeckEffect; +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.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect; +import com.gempukku.lotro.logic.modifiers.StrengthModifier; + +import java.util.List; + +/** + * Set: Black Rider + * Side: Free + * Culture: Elven + * Twilight Cost: 2 + * Type: Event • Skirmish + * Game Text: Spot an Elf to reveal cards from the top of your draw deck until you reveal a Shadow card. Make an Elf + * strength +2 for each card revealed. Place the revealed cards in any order on the bottom of your draw deck. + */ +public class Card12_016 extends AbstractEvent { + public Card12_016() { + super(Side.FREE_PEOPLE, 2, Culture.ELVEN, "Attunement", Phase.SKIRMISH); + } + + @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.canSpot(game, Race.ELF); + } + + @Override + public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) { + final PlayEventAction action = new PlayEventAction(self); + action.appendCost( + new ChooseActiveCardEffect(self, playerId, "Choose an Elf", Race.ELF) { + @Override + protected void cardSelected(LotroGame game, PhysicalCard card) { + final int count = getCardsToRevealCount(playerId, game); + action.appendEffect( + new RevealTopCardsOfDrawDeckEffect(self, playerId, count) { + @Override + protected void cardsRevealed(List cards) { + } + }); + action.appendEffect( + new AddUntilEndOfPhaseModifierEffect( + new StrengthModifier(self, card, count * 2), Phase.SKIRMISH)); + action.appendEffect( + new PutCardsFromDeckBeneathDrawDeckEffect(action, self, playerId, game.getGameState().getDeck(playerId).subList(0, count))); + } + }); + return action; + } + + private int getCardsToRevealCount(String playerId, LotroGame game) { + int count = 0; + for (PhysicalCard physicalCard : game.getGameState().getDeck(playerId)) { + count++; + if (physicalCard.getBlueprint().getSide() == Side.SHADOW) + break; + } + return count; + } +} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set5/gollum/Card5_028.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set5/gollum/Card5_028.java index 3758b774e..369f53404 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set5/gollum/Card5_028.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set5/gollum/Card5_028.java @@ -4,6 +4,7 @@ import com.gempukku.lotro.cards.AbstractCompanion; import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.actions.PlayPermanentAction; import com.gempukku.lotro.cards.effects.AddBurdenEffect; +import com.gempukku.lotro.cards.effects.PutCardsFromDeckBeneathDrawDeckEffect; import com.gempukku.lotro.cards.effects.RevealTopCardsOfDrawDeckEffect; import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; import com.gempukku.lotro.common.*; @@ -11,12 +12,7 @@ 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.actions.SubAction; -import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision; -import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; import com.gempukku.lotro.logic.effects.ChooseAndWoundCharactersEffect; -import com.gempukku.lotro.logic.timing.AbstractSuccessfulEffect; -import com.gempukku.lotro.logic.timing.Effect; import java.util.Collections; import java.util.List; @@ -49,7 +45,7 @@ public class Card5_028 extends AbstractCompanion { } @Override - protected List getExtraInPlayPhaseActions(final String playerId, final LotroGame game, PhysicalCard self) { + protected List getExtraInPlayPhaseActions(final String playerId, final LotroGame game, final PhysicalCard self) { if (PlayConditions.canUseFPCardDuringPhase(game, Phase.REGROUP, self) && PlayConditions.canExert(self, game, 2, Filters.gollumOrSmeagol)) { final ActivateCardAction action = new ActivateCardAction(self); @@ -60,11 +56,8 @@ public class Card5_028 extends AbstractCompanion { @Override protected void cardsRevealed(List cards) { int shadowCards = Filters.filter(cards, game.getGameState(), game.getModifiersQuerying(), Side.SHADOW).size(); - SubAction subAction = new SubAction(action); - for (int i = 0; i < cards.size(); i++) - action.appendEffect( - new PutCardsOnBottomInAnyOrderEffect(game, playerId, cards)); - game.getActionsEnvironment().addActionToStack(subAction); + action.appendEffect( + new PutCardsFromDeckBeneathDrawDeckEffect(action, self, playerId, cards)); for (int i = 0; i < shadowCards; i++) action.appendEffect( new ChooseAndWoundCharactersEffect(action, playerId, 1, 1, CardType.MINION)); @@ -74,49 +67,4 @@ public class Card5_028 extends AbstractCompanion { } return null; } - - private class PutCardsOnBottomInAnyOrderEffect extends AbstractSuccessfulEffect { - private LotroGame _game; - private String _playerId; - private List _cards; - - public PutCardsOnBottomInAnyOrderEffect(LotroGame game, String playerId, List cards) { - _game = game; - _playerId = playerId; - _cards = cards; - } - - @Override - public String getText(LotroGame game) { - return null; - } - - @Override - public Effect.Type getType() { - return null; - } - - @Override - public void playEffect(final LotroGame game) { - if (_cards.size() == 1) { - final PhysicalCard card = _cards.get(0); - game.getGameState().removeCardsFromZone(_playerId, Collections.singleton(card)); - game.getGameState().putCardOnBottomOfDeck(card); - } else if (_cards.size() > 1) { - game.getUserFeedback().sendAwaitingDecision( - _playerId, new ArbitraryCardsSelectionDecision(1, "Choose card to put on bottom of deck", _cards, 1, 1) { - @Override - public void decisionMade(String result) throws DecisionResultInvalidException { - final List selectedCards = getSelectedCardsByResponse(result); - if (selectedCards.size() == 1) { - PhysicalCard card = selectedCards.iterator().next(); - _cards.remove(card); - game.getGameState().removeCardsFromZone(_playerId, Collections.singleton(card)); - game.getGameState().putCardOnBottomOfDeck(card); - } - } - }); - } - } - } }