Shuffling cards from discard.

This commit is contained in:
marcins78@gmail.com
2011-10-14 09:39:45 +00:00
parent b4a34882e9
commit 26488f4267
9 changed files with 102 additions and 64 deletions

View File

@@ -0,0 +1,62 @@
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.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class ShuffleCardsFromDiscardIntoDeckEffect extends AbstractEffect {
private PhysicalCard _source;
private String _playerDeck;
private Collection<PhysicalCard> _cards;
public ShuffleCardsFromDiscardIntoDeckEffect(PhysicalCard source, String playerDeck, Collection<PhysicalCard> cards) {
_source = source;
_playerDeck = playerDeck;
_cards = cards;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public EffectResult.Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
for (PhysicalCard card : _cards) {
if (card.getZone() != Zone.DISCARD)
return false;
}
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
Set<PhysicalCard> toShuffleIn = new HashSet<PhysicalCard>();
for (PhysicalCard card : _cards) {
if (card.getZone() == Zone.DISCARD)
toShuffleIn.add(card);
}
if (toShuffleIn.size() > 0) {
game.getGameState().removeCardsFromZone(toShuffleIn);
game.getGameState().shuffleCardsIntoDeck(toShuffleIn, _playerDeck);
game.getGameState().sendMessage(getAppendedNames(toShuffleIn) + " is/are shuffled into " + _playerDeck + " deck");
}
return new FullEffectResult(null, toShuffleIn.size() == _cards.size(), toShuffleIn.size() == _cards.size());
}
}

View File

@@ -58,11 +58,13 @@ public class ShuffleCardsFromPlayOrStackedIntoDeckEffect extends AbstractEffect
Set<PhysicalCard> shuffleIn = new HashSet<PhysicalCard>(stacked);
shuffleIn.addAll(inPlay);
game.getGameState().removeCardsFromZone(shuffleIn);
if (shuffleIn.size() > 0) {
game.getGameState().removeCardsFromZone(shuffleIn);
game.getGameState().shuffleCardsIntoDeck(shuffleIn, _playerDeck);
game.getGameState().shuffleCardsIntoDeck(shuffleIn, _playerDeck);
game.getGameState().sendMessage(getAppendedNames(shuffleIn) + " is/are shuffled into " + _playerDeck + " deck");
game.getGameState().sendMessage(getAppendedNames(shuffleIn) + " is/are shuffled into " + _playerDeck + " deck");
}
return new FullEffectResult(null, shuffleIn.size() == _cards.size(), shuffleIn.size() == _cards.size());
}

View File

@@ -4,8 +4,7 @@ import com.gempukku.lotro.cards.AbstractAlly;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.cards.effects.ExertCharactersEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDiscardOnBottomOfDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -35,7 +34,7 @@ public class Card1_017 extends AbstractAlly {
}
@Override
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self)
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), self)) {
final ActivateCardAction action = new ActivateCardAction(self);
@@ -47,11 +46,8 @@ public class Card1_017 extends AbstractAlly {
new ChooseArbitraryCardsEffect(playerId, "Choose card to shuffle into draw deck", new LinkedList<PhysicalCard>(discardedDwarvenEvents), 1, 1) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
for (PhysicalCard selectedCard : selectedCards) {
action.appendEffect(
new PutCardFromDiscardOnBottomOfDeckEffect(selectedCard));
}
action.appendEffect(new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, selectedCards));
}
}
);

View File

@@ -3,8 +3,7 @@ package com.gempukku.lotro.cards.set1.sauron;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDiscardOnBottomOfDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.filters.Filters;
@@ -34,19 +33,15 @@ public class Card1_258 extends AbstractMinion {
}
@Override
public List<OptionalTriggerAction> getOptionalAfterTriggers(final String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
public List<OptionalTriggerAction> getOptionalAfterTriggers(final String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) {
if (PlayConditions.played(game.getGameState(), game.getModifiersQuerying(), effectResult, Filters.sameCard(self))) {
final OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendEffect(
new ChooseArbitraryCardsEffect(playerId, "Choose up to 2 WRAITH cards", game.getGameState().getDiscard(playerId), Filters.culture(Culture.WRAITH), 0, 2) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
for (PhysicalCard selectedCard : selectedCards) {
action.appendEffect(
new PutCardFromDiscardOnBottomOfDeckEffect(selectedCard));
}
action.appendEffect(
new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, selectedCards));
}
});
return Collections.singletonList(action);

View File

@@ -4,8 +4,7 @@ import com.gempukku.lotro.cards.AbstractAlly;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.cards.effects.ExertCharactersEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDiscardOnBottomOfDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.Block;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
@@ -37,7 +36,7 @@ public class Card1_284 extends AbstractAlly {
}
@Override
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, PhysicalCard self) {
protected List<? extends Action> getExtraInPlayPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self)
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), self)) {
final ActivateCardAction action = new ActivateCardAction(self);
@@ -46,11 +45,8 @@ public class Card1_284 extends AbstractAlly {
new ChooseArbitraryCardsEffect(playerId, "Choose SHIRE card", game.getGameState().getDiscard(playerId), Filters.culture(Culture.SHIRE), 1, 1) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
if (selectedCards.size() > 0) {
PhysicalCard card = selectedCards.iterator().next();
action.appendEffect(new PutCardFromDiscardOnBottomOfDeckEffect(card));
action.appendEffect(new ShuffleDeckEffect(playerId));
}
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, selectedCards));
}
}
);

View File

@@ -5,8 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.decisions.ForEachYouSpotDecision;
import com.gempukku.lotro.cards.effects.ChooseAndDiscardCardsFromPlayEffect;
import com.gempukku.lotro.cards.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDiscardOnBottomOfDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filter;
import com.gempukku.lotro.filters.Filters;
@@ -61,9 +60,8 @@ public class Card1_285 extends AbstractAttachableFPPossession {
new ChooseArbitraryCardsEffect(playerId, "Choose tales", new LinkedList<PhysicalCard>(talesInDiscard), shufflableTales, shufflableTales) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
for (PhysicalCard selectedCard : selectedCards)
action.appendEffect(new PutCardFromDiscardOnBottomOfDeckEffect(selectedCard));
action.appendEffect(new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, selectedCards));
}
});
}

View File

@@ -3,7 +3,10 @@ package com.gempukku.lotro.cards.set2.isengard;
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.*;
import com.gempukku.lotro.cards.effects.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.cards.effects.ChooseCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.ForEachBurdenYouSpotEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -37,7 +40,7 @@ public class Card2_041 extends AbstractEvent {
}
@Override
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
action.appendCost(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, Filters.race(Race.URUK_HAI)));
@@ -49,12 +52,8 @@ public class Card2_041 extends AbstractEvent {
new ChooseCardsFromDiscardEffect(playerId, burdensSpotted, burdensSpotted, Filters.type(CardType.MINION)) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
for (PhysicalCard card : cards) {
action.appendEffect(
new PutCardFromDiscardOnBottomOfDeckEffect(card));
}
action.appendEffect(
new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, cards));
}
});
}

View File

@@ -2,7 +2,10 @@ package com.gempukku.lotro.cards.set3.dwarven;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.*;
import com.gempukku.lotro.cards.effects.ChooseCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
import com.gempukku.lotro.cards.effects.RevealRandomCardsFromHandEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Side;
@@ -33,7 +36,7 @@ public class Card3_006 extends AbstractEvent {
}
@Override
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseOpponentEffect(playerId) {
@@ -50,12 +53,8 @@ public class Card3_006 extends AbstractEvent {
new ChooseCardsFromDiscardEffect(playerId, 0, twilightCost, Filters.culture(Culture.DWARVEN)) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
for (PhysicalCard physicalCard : cards) {
action.appendEffect(
new PutCardFromDiscardOnBottomOfDeckEffect(physicalCard));
}
action.appendEffect(
new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, cards));
}
}
);

View File

@@ -4,8 +4,7 @@ import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ChoiceEffect;
import com.gempukku.lotro.cards.effects.ChooseCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.PutCardFromDiscardOnBottomOfDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleDeckEffect;
import com.gempukku.lotro.cards.effects.ShuffleCardsFromDiscardIntoDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
@@ -46,7 +45,7 @@ public class Card3_032 extends AbstractEvent {
}
@Override
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
List<Effect> possibleEffects = new LinkedList<Effect>();
possibleEffects.add(
@@ -58,12 +57,8 @@ public class Card3_032 extends AbstractEvent {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
for (PhysicalCard card : cards) {
action.appendEffect(
new PutCardFromDiscardOnBottomOfDeckEffect(card));
}
action.appendEffect(
new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, cards));
}
});
possibleEffects.add(
@@ -75,12 +70,8 @@ public class Card3_032 extends AbstractEvent {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
for (PhysicalCard card : cards) {
action.appendEffect(
new PutCardFromDiscardOnBottomOfDeckEffect(card));
}
action.appendEffect(
new ShuffleDeckEffect(playerId));
action.insertEffect(
new ShuffleCardsFromDiscardIntoDeckEffect(self, playerId, cards));
}
});
action.appendEffect(