diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ShuffleCardsFromPlayIntoDeckEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ShuffleCardsFromPlayIntoDeckEffect.java new file mode 100644 index 000000000..287d8ef68 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ShuffleCardsFromPlayIntoDeckEffect.java @@ -0,0 +1,88 @@ +package com.gempukku.lotro.cards.effects; + +import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.GameUtils; +import com.gempukku.lotro.logic.timing.AbstractEffect; +import com.gempukku.lotro.logic.timing.results.DiscardCardsFromPlayResult; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public class ShuffleCardsFromPlayIntoDeckEffect extends AbstractEffect { + private PhysicalCard _source; + private String _playerDeck; + private Collection _cards; + + public ShuffleCardsFromPlayIntoDeckEffect(PhysicalCard source, String playerDeck, Collection cards) { + _source = source; + _playerDeck = playerDeck; + _cards = cards; + } + + @Override + public String getText(LotroGame game) { + return null; + } + + @Override + public Type getType() { + return null; + } + + @Override + public boolean isPlayableInFull(LotroGame game) { + for (PhysicalCard card : _cards) { + if (!card.getZone().isInPlay()) + return false; + } + + return true; + } + + @Override + protected FullEffectResult playEffectReturningResult(LotroGame game) { + Set goingToDiscard = new HashSet(); + Set discardedFromPlay = new HashSet(); + Set toShuffleIn = new HashSet(); + + for (PhysicalCard card : _cards) { + if (card.getZone().isInPlay()) { + toShuffleIn.add(card); + + goingToDiscard.addAll(game.getGameState().getStackedCards(card)); + goingToDiscard.addAll(game.getGameState().getAttachedCards(card)); + + discardedFromPlay.addAll(game.getGameState().getAttachedCards(card)); + } + } + + Set removeFromPlay = new HashSet(); + removeFromPlay.addAll(toShuffleIn); + removeFromPlay.addAll(goingToDiscard); + + if (toShuffleIn.size() > 0) { + game.getGameState().removeCardsFromZone(_source.getOwner(), removeFromPlay); + + game.getGameState().shuffleCardsIntoDeck(toShuffleIn, _playerDeck); + + for (PhysicalCard physicalCard : goingToDiscard) + game.getGameState().addCardToZone(game, physicalCard, Zone.DISCARD); + + for (PhysicalCard physicalCard : discardedFromPlay) + game.getActionsEnvironment().emitEffectResult(new DiscardCardsFromPlayResult(physicalCard)); + + game.getGameState().sendMessage(getAppendedNames(toShuffleIn) + " " + GameUtils.be(toShuffleIn) + " shuffled into " + _playerDeck + " deck"); + + cardsShuffledCallback(toShuffleIn); + } + + return new FullEffectResult(toShuffleIn.size() == _cards.size(), toShuffleIn.size() == _cards.size()); + } + + protected void cardsShuffledCallback(Set cardsShuffled) { + + } +} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/dwarven/Card15_004.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/dwarven/Card15_004.java new file mode 100644 index 000000000..2d4f513f3 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set15/dwarven/Card15_004.java @@ -0,0 +1,56 @@ +package com.gempukku.lotro.cards.set15.dwarven; + +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.ShuffleCardsFromPlayIntoDeckEffect; +import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; +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.effects.ChooseActiveCardEffect; +import com.gempukku.lotro.logic.effects.ChooseAndWoundCharactersEffect; + +import java.util.Collections; + +/** + * Set: The Hunters + * Side: Free + * Culture: Dwarven + * Twilight Cost: 2 + * Type: Event • Maneuver + * Game Text: Exert a Dwarf to shuffle a [DWARVEN] condition with one or more [DWARVEN] tokens on it into your + * draw deck. Wound a minion for each [DWARVEN] token that was on that condition. + */ +public class Card15_004 extends AbstractEvent { + public Card15_004() { + super(Side.FREE_PEOPLE, 2, Culture.DWARVEN, "The Fortunes of Balin's Folk", Phase.MANEUVER); + } + + @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.canExert(self, game, Race.DWARF); + } + + @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 ChooseAndExertCharactersEffect(action, playerId, 1, 1, Race.DWARF)); + action.appendEffect( + new ChooseActiveCardEffect(self, playerId, "Choose a DWARVEN condition", Culture.DWARVEN, CardType.CONDITION, Filters.hasToken(Token.DWARVEN)) { + @Override + protected void cardSelected(LotroGame game, PhysicalCard card) { + int tokens = game.getGameState().getTokenCount(card, Token.DWARVEN); + action.appendEffect( + new ShuffleCardsFromPlayIntoDeckEffect(self, playerId, Collections.singleton(card))); + for (int i = 0; i < tokens; i++) + action.appendEffect( + new ChooseAndWoundCharactersEffect(action, playerId, 1, 1, CardType.MINION)); + } + }); + return action; + } +}