diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndStackCardsFromDiscardEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndStackCardsFromDiscardEffect.java new file mode 100644 index 000000000..1eea0ef2b --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/choose/ChooseAndStackCardsFromDiscardEffect.java @@ -0,0 +1,83 @@ +package com.gempukku.lotro.cards.effects.choose; + +import com.gempukku.lotro.cards.effects.StackCardFromDiscardEffect; +import com.gempukku.lotro.cards.effects.StackCardFromHandEffect; +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.actions.SubAction; +import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision; +import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; +import com.gempukku.lotro.logic.timing.AbstractEffect; +import com.gempukku.lotro.logic.timing.Action; + +import java.util.Collection; +import java.util.List; + +public class ChooseAndStackCardsFromDiscardEffect extends AbstractEffect { + private Action _action; + private String _playerId; + private int _minimum; + private int _maximum; + private PhysicalCard _stackOn; + private Filter _filter; + + public ChooseAndStackCardsFromDiscardEffect(Action action, String playerId, int minimum, int maximum, PhysicalCard stackOn, Filter filter) { + _action = action; + _playerId = playerId; + _minimum = minimum; + _maximum = maximum; + _stackOn = stackOn; + _filter = filter; + } + + @Override + public Type getType() { + return null; + } + + @Override + public String getText(LotroGame game) { + return null; + } + + @Override + public boolean isPlayableInFull(LotroGame game) { + return Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter).size() >= _minimum; + } + + @Override + protected FullEffectResult playEffectReturningResult(final LotroGame game) { + Collection discard = Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter); + + final boolean success = discard.size() >= _minimum; + + if (discard.size() <= _minimum) { + SubAction subAction = new SubAction(_action); + for (PhysicalCard card : discard) + subAction.appendEffect(new StackCardFromHandEffect(card, _stackOn)); + game.getActionsEnvironment().addActionToStack(subAction); + stackFromDiscardCallback(discard); + } else { + game.getUserFeedback().sendAwaitingDecision(_playerId, + new ArbitraryCardsSelectionDecision(1, "Choose cards to stack", discard, _minimum, _maximum) { + @Override + public void decisionMade(String result) throws DecisionResultInvalidException { + List cards = getSelectedCardsByResponse(result); + SubAction subAction = new SubAction(_action); + for (PhysicalCard card : cards) + subAction.appendEffect(new StackCardFromDiscardEffect(card, _stackOn)); + game.getActionsEnvironment().addActionToStack(subAction); + stackFromDiscardCallback(cards); + } + }); + } + + return new FullEffectResult(null, success, success); + } + + public void stackFromDiscardCallback(Collection cardsStacked) { + + } +} \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set7/dwarven/Card7_012.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set7/dwarven/Card7_012.java new file mode 100644 index 000000000..5ca2a721e --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set7/dwarven/Card7_012.java @@ -0,0 +1,56 @@ +package com.gempukku.lotro.cards.set7.dwarven; + +import com.gempukku.lotro.cards.AbstractPermanent; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndStackCardsFromHandEffect; +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.effects.ChooseAndWoundCharactersEffect; +import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect; +import com.gempukku.lotro.logic.timing.Action; + +import java.util.Collections; +import java.util.List; + +/** + * Set: The Return of the King + * Side: Free + * Culture: Dwarven + * Twilight Cost: 2 + * Type: Condition • Support Area + * Game Text: Regroup: Exert a Dwarf companion to stack a card from your discard pile here. Skirmish: Wound a minion + * skirmishing a Dwarf once for each [DWARVEN] card stacked here. Discard this condition. + */ +public class Card7_012 extends AbstractPermanent { + public Card7_012() { + super(Side.FREE_PEOPLE, 2, CardType.CONDITION, Culture.DWARVEN, Zone.SUPPORT, "Preparations"); + } + + @Override + protected List getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) { + if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.REGROUP, self) + && PlayConditions.canExert(self, game, Race.DWARF, CardType.COMPANION)) { + ActivateCardAction action = new ActivateCardAction(self); + action.appendCost( + new ChooseAndExertCharactersEffect(action, playerId, 1, 1, Race.DWARF, CardType.COMPANION)); + action.appendEffect( + new ChooseAndStackCardsFromHandEffect(action, playerId, 1, 1, self, Filters.any)); + return Collections.singletonList(action); + } + if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)) { + ActivateCardAction action = new ActivateCardAction(self); + int count = Filters.filter(game.getGameState().getStackedCards(self), game.getGameState(), game.getModifiersQuerying(), Culture.DWARVEN).size(); + for (int i = 0; i < count; i++) + action.appendEffect( + new ChooseAndWoundCharactersEffect(action, playerId, 1, 1, CardType.MINION, Filters.inSkirmishAgainst(Race.DWARF))); + action.appendEffect( + new DiscardCardsFromPlayEffect(self, self)); + return Collections.singletonList(action); + } + return null; + } +}