From 083c4bc5d423aa38d47ca04c0b08587fad0340f3 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 15 Jul 2020 00:42:08 +0200 Subject: [PATCH] * Reworked some card movement to player methods (#4866). --- Mage.Sets/src/mage/cards/d/Deglamer.java | 8 +-- Mage.Sets/src/mage/cards/m/MnemonicNexus.java | 16 ++--- .../src/mage/cards/p/PerishTheThought.java | 13 ++-- Mage.Sets/src/mage/cards/p/PsychicSpiral.java | 28 +++------ Mage.Sets/src/mage/cards/p/PutAway.java | 62 +++---------------- Mage.Sets/src/mage/cards/r/Regression.java | 1 - Mage.Sets/src/mage/cards/r/Reminisce.java | 18 ++---- Mage.Sets/src/mage/cards/r/Repopulate.java | 13 ++-- .../src/mage/cards/r/ResearchDevelopment.java | 62 ++++--------------- Mage.Sets/src/mage/cards/r/Riftsweeper.java | 17 +++-- .../src/mage/cards/s/SenseisDiviningTop.java | 12 ++-- .../src/mage/cards/s/SereneRemembrance.java | 43 +++++-------- .../src/mage/cards/s/SignalTheClans.java | 31 +++++----- .../mage/cards/s/StreamOfConsciousness.java | 29 +++------ .../src/mage/cards/s/StruggleSurvive.java | 13 +--- .../src/mage/cards/s/SwayOfTheStars.java | 11 ++-- Mage.Sets/src/mage/cards/t/Terminus.java | 31 ++++++---- Mage.Sets/src/mage/cards/t/TimeSpiral.java | 17 ++--- Mage.Sets/src/mage/cards/u/UndyingBeast.java | 19 ++++-- Mage.Sets/src/mage/cards/v/VoidStalker.java | 40 +++++++----- .../src/mage/cards/v/VortexElemental.java | 17 ++--- Mage.Sets/src/mage/cards/w/WhiskAway.java | 17 +++-- Mage.Sets/src/mage/cards/w/Worldpurge.java | 12 +--- .../src/mage/cards/w/WriteIntoBeing.java | 8 +-- .../ShuffleIntoLibraryTargetEffect.java | 37 ++++++----- Mage/src/main/java/mage/players/Player.java | 43 +++++++------ .../main/java/mage/players/PlayerImpl.java | 2 +- 27 files changed, 247 insertions(+), 373 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/Deglamer.java b/Mage.Sets/src/mage/cards/d/Deglamer.java index 35c2351eb28..081301752a8 100644 --- a/Mage.Sets/src/mage/cards/d/Deglamer.java +++ b/Mage.Sets/src/mage/cards/d/Deglamer.java @@ -1,6 +1,6 @@ - package mage.cards.d; +import java.util.UUID; import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -8,8 +8,6 @@ import mage.constants.CardType; import mage.filter.StaticFilters; import mage.target.TargetPermanent; -import java.util.UUID; - /** * * @author LevelX2 @@ -17,7 +15,7 @@ import java.util.UUID; public final class Deglamer extends CardImpl { public Deglamer(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); // Choose target artifact or enchantment. Its owner shuffles it into their library. this.getSpellAbility().addEffect(new ShuffleIntoLibraryTargetEffect()); @@ -32,4 +30,4 @@ public final class Deglamer extends CardImpl { public Deglamer copy() { return new Deglamer(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/m/MnemonicNexus.java b/Mage.Sets/src/mage/cards/m/MnemonicNexus.java index 8acec9890e8..838cf76518e 100644 --- a/Mage.Sets/src/mage/cards/m/MnemonicNexus.java +++ b/Mage.Sets/src/mage/cards/m/MnemonicNexus.java @@ -1,15 +1,12 @@ - package mage.cards.m; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -20,7 +17,7 @@ import mage.players.Player; public final class MnemonicNexus extends CardImpl { public MnemonicNexus(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}"); // Each player shuffles their graveyard into their library. this.getSpellAbility().addEffect(new MnemonicNexusEffect()); @@ -50,16 +47,13 @@ class MnemonicNexusEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - if(sourcePlayer == null){ + if (sourcePlayer == null) { return false; } - for (UUID playerId: game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card: player.getGraveyard().getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - player.shuffleLibrary(source, game); + player.shuffleCardsToLibrary(player.getGraveyard(), game, source); } } return true; @@ -70,4 +64,4 @@ class MnemonicNexusEffect extends OneShotEffect { return new MnemonicNexusEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/p/PerishTheThought.java b/Mage.Sets/src/mage/cards/p/PerishTheThought.java index cd7770f577f..00a691c08a1 100644 --- a/Mage.Sets/src/mage/cards/p/PerishTheThought.java +++ b/Mage.Sets/src/mage/cards/p/PerishTheThought.java @@ -1,7 +1,7 @@ - package mage.cards.p; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; @@ -61,9 +61,10 @@ class PerishTheThoughtEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player targetOpponent = game.getPlayer(source.getFirstTarget()); - if (targetOpponent != null) { + MageObject sourceObject = source.getSourceObject(game); + if (targetOpponent != null && sourceObject != null) { if (!targetOpponent.getHand().isEmpty()) { - targetOpponent.revealCards("Perish the Thought", targetOpponent.getHand(), game); + targetOpponent.revealCards(sourceObject.getIdName(), targetOpponent.getHand(), game); Player you = game.getPlayer(source.getControllerId()); if (you != null) { TargetCard target = new TargetCard(Zone.HAND, filter); @@ -71,13 +72,13 @@ class PerishTheThoughtEffect extends OneShotEffect { if (you.choose(Outcome.Neutral, targetOpponent.getHand(), target, game)) { Card chosenCard = targetOpponent.getHand().get(target.getFirstTarget(), game); if (chosenCard != null) { - chosenCard.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - targetOpponent.shuffleLibrary(source, game); + targetOpponent.shuffleCardsToLibrary(chosenCard, game, source); } } - return true; + } } + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/p/PsychicSpiral.java b/Mage.Sets/src/mage/cards/p/PsychicSpiral.java index 6595fa697ee..2dc1abe54bf 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicSpiral.java +++ b/Mage.Sets/src/mage/cards/p/PsychicSpiral.java @@ -1,15 +1,12 @@ - package mage.cards.p; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; @@ -21,8 +18,7 @@ import mage.target.TargetPlayer; public final class PsychicSpiral extends CardImpl { public PsychicSpiral(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{U}"); - + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{U}"); // Shuffle all cards from your graveyard into your library. Target player puts that many cards from the top of their library into their graveyard. this.getSpellAbility().addTarget(new TargetPlayer()); @@ -43,7 +39,7 @@ class PsychicSpiralEffect extends OneShotEffect { public PsychicSpiralEffect() { super(Outcome.GainLife); - staticText = "Shuffle all cards from your graveyard into your library. Target player puts that many cards from the top of their library into their graveyard"; + staticText = "Shuffle all cards from your graveyard into your library. Target player mills that many cards"; } public PsychicSpiralEffect(final PsychicSpiralEffect effect) { @@ -52,19 +48,13 @@ class PsychicSpiralEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - int cardsInGraveyard = player.getGraveyard().size(); - for (Card card: player.getGraveyard().getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - player.shuffleLibrary(source, game); - + Player controller = game.getPlayer(source.getControllerId()); + Player targetPlayer = game.getPlayer(source.getFirstTarget()); + if (controller != null && targetPlayer != null) { + int cardsInGraveyard = controller.getGraveyard().size(); + controller.shuffleCardsToLibrary(controller.getGraveyard(), game, source); if (cardsInGraveyard > 0) { - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { - targetPlayer.millCards(cardsInGraveyard, source, game); - } + targetPlayer.millCards(cardsInGraveyard, source, game); } return true; } @@ -75,4 +65,4 @@ class PsychicSpiralEffect extends OneShotEffect { public PsychicSpiralEffect copy() { return new PsychicSpiralEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/p/PutAway.java b/Mage.Sets/src/mage/cards/p/PutAway.java index 0f4c6da129f..333525b37eb 100644 --- a/Mage.Sets/src/mage/cards/p/PutAway.java +++ b/Mage.Sets/src/mage/cards/p/PutAway.java @@ -1,21 +1,15 @@ package mage.cards.p; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import java.util.UUID; +import mage.abilities.effects.common.CounterTargetEffect; +import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.game.stack.Spell; -import mage.players.Player; +import mage.filter.StaticFilters; import mage.target.TargetSpell; import mage.target.common.TargetCardInYourGraveyard; - -import java.util.UUID; +import mage.target.targetpointer.SecondTargetPointer; /** * @author jeffwadsworth @@ -25,11 +19,13 @@ public final class PutAway extends CardImpl { public PutAway(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); - // Counter target spell. You may shuffle up to one target card from your graveyard into your library. - this.getSpellAbility().addEffect(new PutAwayEffect()); + this.getSpellAbility().addEffect(new CounterTargetEffect()); + this.getSpellAbility().addEffect(new ShuffleIntoLibraryTargetEffect(true) + .setTargetPointer(new SecondTargetPointer()) + .setText("you may shuffle up to one target card from your graveyard into your library")); this.getSpellAbility().addTarget(new TargetSpell()); - this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, new FilterCard())); + this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD)); } @@ -42,41 +38,3 @@ public final class PutAway extends CardImpl { return new PutAway(this); } } - -class PutAwayEffect extends OneShotEffect { - - boolean countered = false; - - public PutAwayEffect() { - super(Outcome.Neutral); - this.staticText = "Counter target spell. You may shuffle up to one target card from your graveyard into your library"; - } - - public PutAwayEffect(final PutAwayEffect effect) { - super(effect); - } - - @Override - public PutAwayEffect copy() { - return new PutAwayEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Spell spell = game.getStack().getSpell(source.getFirstTarget()); - if (spell != null && game.getStack().counter(spell.getId(), source.getSourceId(), game)) { - countered = true; - } - - Card card = game.getCard(source.getTargets().get(1).getFirstTarget()); - Player you = game.getPlayer(source.getControllerId()); - if (you != null && card != null) { - if (you.chooseUse(Outcome.Benefit, "Do you wish to shuffle up to one target card from your graveyard into your library?", source, game) - && game.getState().getZone(card.getId()).match(Zone.GRAVEYARD)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - you.shuffleLibrary(source, game); - } - } - return countered; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/r/Regression.java b/Mage.Sets/src/mage/cards/r/Regression.java index bd4257d50b8..8369966c5e7 100644 --- a/Mage.Sets/src/mage/cards/r/Regression.java +++ b/Mage.Sets/src/mage/cards/r/Regression.java @@ -1,4 +1,3 @@ - package mage.cards.r; import java.util.UUID; diff --git a/Mage.Sets/src/mage/cards/r/Reminisce.java b/Mage.Sets/src/mage/cards/r/Reminisce.java index c34ec68fb57..c825c764bd4 100644 --- a/Mage.Sets/src/mage/cards/r/Reminisce.java +++ b/Mage.Sets/src/mage/cards/r/Reminisce.java @@ -1,15 +1,12 @@ - package mage.cards.r; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; @@ -21,7 +18,7 @@ import mage.target.TargetPlayer; public final class Reminisce extends CardImpl { public Reminisce(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}"); // Target player shuffles their graveyard into their library. this.getSpellAbility().addEffect(new ReminisceEffect()); @@ -39,29 +36,26 @@ public final class Reminisce extends CardImpl { } class ReminisceEffect extends OneShotEffect { - + ReminisceEffect() { super(Outcome.Neutral); this.staticText = "Target player shuffles their graveyard into their library"; } - + ReminisceEffect(final ReminisceEffect effect) { super(effect); } - + @Override public ReminisceEffect copy() { return new ReminisceEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (player != null) { - for (Card card: player.getGraveyard().getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - player.shuffleLibrary(source, game); + player.shuffleCardsToLibrary(player.getGraveyard(), game, source); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/r/Repopulate.java b/Mage.Sets/src/mage/cards/r/Repopulate.java index 7ceaa5452a0..4e51a3804ff 100644 --- a/Mage.Sets/src/mage/cards/r/Repopulate.java +++ b/Mage.Sets/src/mage/cards/r/Repopulate.java @@ -1,17 +1,15 @@ package mage.cards.r; -import java.util.Set; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.CyclingAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.StaticFilters; import mage.game.Game; import mage.players.Player; @@ -58,12 +56,9 @@ class RepopulateEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { - Set cards = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game); - for (Card card : cards) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - player.shuffleLibrary(source, game); - return true; + return player.shuffleCardsToLibrary( + new CardsImpl(player.getGraveyard() + .getCards(StaticFilters.FILTER_CARD_CREATURE, game)), game, source); } return false; } diff --git a/Mage.Sets/src/mage/cards/r/ResearchDevelopment.java b/Mage.Sets/src/mage/cards/r/ResearchDevelopment.java index 6bfeeb052f3..54065c4f6bb 100644 --- a/Mage.Sets/src/mage/cards/r/ResearchDevelopment.java +++ b/Mage.Sets/src/mage/cards/r/ResearchDevelopment.java @@ -1,5 +1,7 @@ package mage.cards.r; +import java.util.Set; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; @@ -14,9 +16,6 @@ import mage.game.permanent.token.ResearchDevelopmentToken; import mage.players.Player; import mage.target.TargetCard; -import java.util.Set; -import java.util.UUID; - /** * @author magenoxx */ @@ -44,10 +43,6 @@ public final class ResearchDevelopment extends SplitCard { class ResearchEffect extends OneShotEffect { - private static final String choiceText = "Choose a card you own from outside the game"; - - private static final FilterCard filter = new FilterCard("card"); - public ResearchEffect() { super(Outcome.Benefit); this.staticText = "Choose up to four cards you own from outside the game and shuffle them into your library"; @@ -64,53 +59,20 @@ class ResearchEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - StringBuilder textToAsk = new StringBuilder(choiceText); - textToAsk.append(" (0)"); - int count = 0; - while (player.chooseUse(Outcome.Benefit, textToAsk.toString(), source, game)) { - Cards cards = player.getSideboard(); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (controller.chooseUse(Outcome.Benefit, staticText + "?", source, game)) { + Cards cards = controller.getSideboard(); if (cards.isEmpty()) { - game.informPlayer(player, "You have no cards outside the game."); - break; + game.informPlayer(controller, "You have no cards outside the game."); + return true; } - - Set filtered = cards.getCards(filter, game); - if (filtered.isEmpty()) { - game.informPlayer(player, "You have no " + filter.getMessage() + " outside the game."); - break; - } - - Cards filteredCards = new CardsImpl(); - for (Card card : filtered) { - filteredCards.add(card.getId()); - } - - TargetCard target = new TargetCard(Zone.OUTSIDE, filter); - if (player.choose(Outcome.Benefit, filteredCards, target, game)) { - Card card = player.getSideboard().get(target.getFirstTarget(), game); - if (card != null) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - count++; - textToAsk = new StringBuilder(choiceText); - textToAsk.append(" ("); - textToAsk.append(count); - textToAsk.append(')'); - } - } - - if (count == 4) { - break; + TargetCard target = new TargetCard(0, 4, Zone.OUTSIDE, new FilterCard("cards you own from outside the game")); + target.setNotTarget(true); + if (controller.choose(Outcome.Benefit, controller.getSideboard(), target, game)) { + controller.shuffleCardsToLibrary(new CardsImpl(target.getTargets()), game, source); } } - - game.informPlayers(player.getLogName() + " has chosen " + count + " card(s) to shuffle into their library."); - - if (count > 0) { - player.shuffleLibrary(source, game); - } - return true; } diff --git a/Mage.Sets/src/mage/cards/r/Riftsweeper.java b/Mage.Sets/src/mage/cards/r/Riftsweeper.java index 8fc19bea158..aa4f3fabd20 100644 --- a/Mage.Sets/src/mage/cards/r/Riftsweeper.java +++ b/Mage.Sets/src/mage/cards/r/Riftsweeper.java @@ -1,4 +1,3 @@ - package mage.cards.r; import java.util.UUID; @@ -12,11 +11,11 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.other.FaceDownPredicate; import mage.game.Game; +import mage.players.Player; import mage.target.common.TargetCardInExile; /** @@ -26,12 +25,13 @@ import mage.target.common.TargetCardInExile; public final class Riftsweeper extends CardImpl { private static final FilterCard filter = new FilterCard("face-up exiled card"); + static { filter.add(Predicates.not(FaceDownPredicate.instance)); } public Riftsweeper(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); this.subtype.add(SubType.ELF); this.subtype.add(SubType.SHAMAN); @@ -74,13 +74,12 @@ class RiftsweeperEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Card card = game.getCard(targetPointer.getFirst(game, source)); if (card != null) { - // remove exiting suspend counters + // remove existing suspend counters card.getCounters(game).clear(); - // move to exile - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - game.getPlayer(card.getOwnerId()).shuffleLibrary(source, game); - game.informPlayers("Riftsweeper: Choosen card was " + card.getName()); - return true; + Player owner = game.getPlayer(card.getOwnerId()); + if (owner != null) { + return owner.shuffleCardsToLibrary(card, game, source); + } } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SenseisDiviningTop.java b/Mage.Sets/src/mage/cards/s/SenseisDiviningTop.java index 33db73fc7b3..a7a405735b7 100644 --- a/Mage.Sets/src/mage/cards/s/SenseisDiviningTop.java +++ b/Mage.Sets/src/mage/cards/s/SenseisDiviningTop.java @@ -1,4 +1,3 @@ - package mage.cards.s; import java.util.UUID; @@ -16,6 +15,7 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; /** * @author LevelX @@ -24,7 +24,10 @@ public final class SenseisDiviningTop extends CardImpl { public SenseisDiviningTop(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + + // {1}: Look at the top three cards of your library, then put them back in any order. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LookLibraryControllerEffect(3, false, true), new ManaCostsImpl("{1}"))); + // {T}: Draw a card, then put Sensei's Divining Top on top of its owner's library. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapSourceCost()); ability.addEffect(new SenseisDiviningTopEffect()); this.addAbility(ability); @@ -45,7 +48,7 @@ class SenseisDiviningTopEffect extends OneShotEffect { public SenseisDiviningTopEffect() { super(Outcome.ReturnToHand); - staticText = ", then put Sensei's Divining Top on top of its owner's library"; + staticText = ", then put {this} on top of its owner's library"; } public SenseisDiviningTopEffect(final SenseisDiviningTopEffect effect) { @@ -60,8 +63,9 @@ class SenseisDiviningTopEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - return permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + Player owner = game.getPlayer(game.getOwnerId(source.getSourceId())); + if (permanent != null && owner != null) { + return owner.putCardsOnTopOfLibrary(permanent, game, source, true); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SereneRemembrance.java b/Mage.Sets/src/mage/cards/s/SereneRemembrance.java index d674b47ff88..6f4cd445f32 100644 --- a/Mage.Sets/src/mage/cards/s/SereneRemembrance.java +++ b/Mage.Sets/src/mage/cards/s/SereneRemembrance.java @@ -7,13 +7,14 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.StaticFilters; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInASingleGraveyard; import java.util.UUID; +import mage.cards.Cards; +import mage.cards.CardsImpl; /** * @author LevelX2 @@ -43,7 +44,7 @@ class SereneRemembranceEffect extends OneShotEffect { public SereneRemembranceEffect() { super(Outcome.Benefit); - this.staticText = "Shuffle Serene Remembrance and up to three target cards from a single graveyard into their owners' libraries"; + this.staticText = "Shuffle {this} and up to three target cards from a single graveyard into their owners' libraries"; } public SereneRemembranceEffect(final SereneRemembranceEffect effect) { @@ -57,35 +58,21 @@ class SereneRemembranceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - boolean result = false; - - // 3 cards to graveyard - Player graveyardPlayer = null; - for (UUID cardInGraveyard : targetPointer.getTargets(game, source)) { - Card card = game.getCard(cardInGraveyard); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card card = game.getCard(source.getSourceId()); if (card != null) { - for (Player player : game.getPlayers().values()) { - if (player.getGraveyard().contains(card.getId())) { - graveyardPlayer = player; - result |= card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } + controller.shuffleCardsToLibrary(card, game, source); + } + Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source)); + if (!cards.isEmpty()) { + Player owner = game.getPlayer(cards.getCards(game).iterator().next().getOwnerId()); + if (owner != null) { + owner.shuffleCardsToLibrary(cards, game, source); } } + return true; } - - // source card to graveyard - Card card = game.getCard(source.getSourceId()); - if (card != null) { - result |= card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - Player player = game.getPlayer(card.getOwnerId()); - if (player != null) { - player.shuffleLibrary(source, game); - } - if (graveyardPlayer != null && !graveyardPlayer.equals(player)) { - graveyardPlayer.shuffleLibrary(source, game); - } - } - - return result; + return false; } } diff --git a/Mage.Sets/src/mage/cards/s/SignalTheClans.java b/Mage.Sets/src/mage/cards/s/SignalTheClans.java index 0a9d34bad79..5775bbc25cf 100644 --- a/Mage.Sets/src/mage/cards/s/SignalTheClans.java +++ b/Mage.Sets/src/mage/cards/s/SignalTheClans.java @@ -56,39 +56,36 @@ class SignalTheClansEffect extends SearchEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { return false; } //Search your library for three creature cards - if (player.searchLibrary(target, source, game)) { + if (controller.searchLibrary(target, source, game)) { + boolean shuffleDone = false; if (!target.getTargets().isEmpty()) { - Cards cards = new CardsImpl(); - for (UUID cardId : target.getTargets()) { - Card card = player.getLibrary().remove(cardId, game); - if (card != null) { - cards.add(card); - } - } + Cards cards = new CardsImpl(target.getTargets()); //Reveal them - player.revealCards("Reveal", cards, game); + controller.revealCards(source, cards, game); Card cardsArray[] = cards.getCards(game).toArray(new Card[0]); //If you reveal three cards with different names if (Stream.of(cardsArray).map(MageObject::getName).collect(Collectors.toSet()).size() == 3) { //Choose one of them at random and put that card into your hand Card randomCard = cards.getRandom(game); - randomCard.moveToZone(Zone.HAND, source.getSourceId(), game, true); + controller.moveCards(randomCard, Zone.HAND, source, game); cards.remove(randomCard); } - //Shuffle the rest into your library - for (Card card : cards.getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + // Shuffle the rest into your library + if (!cards.isEmpty()) { + controller.shuffleCardsToLibrary(cards, game, source); + shuffleDone = true; } } - player.shuffleLibrary(source, game); + if (!shuffleDone) { + controller.shuffleLibrary(source, game); + } return true; } - player.shuffleLibrary(source, game); return false; } diff --git a/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java b/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java index ed7fd756ed5..3771b67568a 100644 --- a/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java +++ b/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java @@ -1,11 +1,13 @@ - package mage.cards.s; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; @@ -16,9 +18,6 @@ import mage.players.Player; import mage.target.TargetPlayer; import mage.target.common.TargetCardInGraveyard; -import java.util.List; -import java.util.UUID; - /** * * @author LevelX2 @@ -26,7 +25,7 @@ import java.util.UUID; public final class StreamOfConsciousness extends CardImpl { public StreamOfConsciousness(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); this.subtype.add(SubType.ARCANE); // Target player shuffles up to four target cards from their graveyard into their library. @@ -64,23 +63,11 @@ class StreamOfConsciousnessEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player != null) { - List targets = source.getTargets().get(1).getTargets(); - boolean shuffle = false; - for (UUID targetId : targets) { - Card card = game.getCard(targetId); - if (card != null) { - if (player.getGraveyard().contains(card.getId())) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - shuffle = true; - } - } - } - if (shuffle) { - player.shuffleLibrary(source, game); - } - return true; + Cards targets = new CardsImpl(source.getTargets().get(1).getTargets()); + targets.retainAll(player.getGraveyard()); + return player.shuffleCardsToLibrary(targets, game, source); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/StruggleSurvive.java b/Mage.Sets/src/mage/cards/s/StruggleSurvive.java index f9a9b6428a8..ca7b0720125 100644 --- a/Mage.Sets/src/mage/cards/s/StruggleSurvive.java +++ b/Mage.Sets/src/mage/cards/s/StruggleSurvive.java @@ -1,4 +1,3 @@ - package mage.cards.s; import java.util.UUID; @@ -8,14 +7,11 @@ import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.keyword.AftermathAbility; -import mage.cards.Card; -import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.cards.SplitCard; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SpellAbilityType; -import mage.constants.Zone; import mage.filter.common.FilterControlledLandPermanent; import mage.game.Game; import mage.players.Player; @@ -69,16 +65,11 @@ class SurviveEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - if(sourcePlayer != null) { + if (sourcePlayer != null) { for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getGraveyard().getCards(game)) { - if(card != null) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - } - player.shuffleLibrary(source, game); + player.shuffleCardsToLibrary(player.getGraveyard(), game, source); } } } diff --git a/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java b/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java index 5fd870424fd..d5f0563a633 100644 --- a/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java +++ b/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java @@ -1,8 +1,6 @@ - package mage.cards.s; import java.util.UUID; - import mage.abilities.Ability; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; @@ -10,6 +8,8 @@ import mage.abilities.effects.common.DrawCardAllEffect; import mage.abilities.effects.common.SetPlayerLifeAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -50,7 +50,7 @@ class SwayOfTheStarsEffect extends OneShotEffect { public SwayOfTheStarsEffect() { super(Outcome.Neutral); - staticText = "Each player shuffles their hand, graveyard, and permanents they own into their library, then draws seven cards. Each player's life total becomes 7"; + staticText = "Each player shuffles their hand, graveyard, and permanents they own into their library"; } public SwayOfTheStarsEffect(final SwayOfTheStarsEffect effect) { @@ -68,10 +68,11 @@ class SwayOfTheStarsEffect extends OneShotEffect { player.moveCards(player.getGraveyard(), Zone.LIBRARY, source, game); FilterPermanent filter = new FilterPermanent(); filter.add(new OwnerIdPredicate(playerId)); + Cards toLib = new CardsImpl(); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) { - permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + toLib.add(permanent); } - player.shuffleLibrary(source, game); + player.shuffleCardsToLibrary(toLib, game, source); } } } diff --git a/Mage.Sets/src/mage/cards/t/Terminus.java b/Mage.Sets/src/mage/cards/t/Terminus.java index 3fd08eba5d4..d66aff26f2e 100644 --- a/Mage.Sets/src/mage/cards/t/Terminus.java +++ b/Mage.Sets/src/mage/cards/t/Terminus.java @@ -1,7 +1,5 @@ - package mage.cards.t; -import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; @@ -9,12 +7,15 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.MiracleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; -import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.other.OwnerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; /** * @@ -23,13 +24,11 @@ import mage.game.permanent.Permanent; public final class Terminus extends CardImpl { public Terminus(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{W}{W}"); - - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{W}{W}"); // Put all creatures on the bottom of their owners' libraries. this.getSpellAbility().addEffect(new TerminusEffect()); - + // Miracle {W} this.addAbility(new MiracleAbility(this, new ManaCostsImpl("{W}"))); } @@ -61,10 +60,18 @@ class TerminusEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List permanents = game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source.getSourceId(), game); - for (Permanent permanent : permanents) { - permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + FilterCreaturePermanent filter = new FilterCreaturePermanent(); + filter.add(new OwnerIdPredicate(player.getId())); + Cards toLib = new CardsImpl(); + for (Permanent permanent : game.getBattlefield() + .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + toLib.add(permanent); + } + player.putCardsOnBottomOfLibrary(toLib, game, source, true); + } } return true; } diff --git a/Mage.Sets/src/mage/cards/t/TimeSpiral.java b/Mage.Sets/src/mage/cards/t/TimeSpiral.java index 8eec63e9708..a803041fa18 100644 --- a/Mage.Sets/src/mage/cards/t/TimeSpiral.java +++ b/Mage.Sets/src/mage/cards/t/TimeSpiral.java @@ -1,4 +1,3 @@ - package mage.cards.t; import java.util.UUID; @@ -8,12 +7,12 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardAllEffect; import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.UntapLandsEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -24,7 +23,7 @@ import mage.players.Player; public final class TimeSpiral extends CardImpl { public TimeSpiral(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); // Exile Time Spiral. Each player shuffles their graveyard and hand into their library, then draws seven cards. You untap up to six lands. this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); @@ -62,13 +61,9 @@ class TimeSpiralEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getHand().getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - for (Card card : player.getGraveyard().getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - player.shuffleLibrary(source, game); + Cards toLib = new CardsImpl(player.getHand()); + toLib.addAll(player.getGraveyard()); + player.shuffleCardsToLibrary(toLib, game, source); } } return true; diff --git a/Mage.Sets/src/mage/cards/u/UndyingBeast.java b/Mage.Sets/src/mage/cards/u/UndyingBeast.java index 201f45d8b4c..b9116c7a449 100644 --- a/Mage.Sets/src/mage/cards/u/UndyingBeast.java +++ b/Mage.Sets/src/mage/cards/u/UndyingBeast.java @@ -1,4 +1,3 @@ - package mage.cards.u; import java.util.UUID; @@ -10,10 +9,11 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -23,7 +23,7 @@ import mage.players.Player; public final class UndyingBeast extends CardImpl { public UndyingBeast(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); this.subtype.add(SubType.BEAST); this.power = new MageInt(3); this.toughness = new MageInt(2); @@ -62,10 +62,17 @@ class UndyingBeastEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) { - Player owner = game.getPlayer(card.getOwnerId()); - if(owner != null) { - return card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + Object object = this.getValue("permanentLeftBattlefield"); + if (object instanceof Permanent) { + Permanent permanent = (Permanent) object; + if (permanent.getZoneChangeCounter(game) + 1 == card.getZoneChangeCounter(game)) { + Player owner = game.getPlayer(card.getOwnerId()); + if (owner != null) { + return owner.putCardsOnTopOfLibrary(card, game, source, true); + } + } } + } return true; } diff --git a/Mage.Sets/src/mage/cards/v/VoidStalker.java b/Mage.Sets/src/mage/cards/v/VoidStalker.java index 514476c33db..1941bfe4ccd 100644 --- a/Mage.Sets/src/mage/cards/v/VoidStalker.java +++ b/Mage.Sets/src/mage/cards/v/VoidStalker.java @@ -1,6 +1,7 @@ - package mage.cards.v; +import java.util.LinkedHashSet; +import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -11,8 +12,8 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; @@ -26,7 +27,7 @@ import mage.target.common.TargetCreaturePermanent; public final class VoidStalker extends CardImpl { public VoidStalker(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.subtype.add(SubType.ELEMENTAL); this.power = new MageInt(2); @@ -50,6 +51,7 @@ public final class VoidStalker extends CardImpl { } class VoidStalkerEffect extends OneShotEffect { + VoidStalkerEffect() { super(Outcome.ReturnToHand); staticText = "Put {this} and target creature on top of their owners' libraries, then those players shuffle their libraries"; @@ -61,19 +63,25 @@ class VoidStalkerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent p = game.getPermanent(targetPointer.getFirst(game, source)); - Permanent s = game.getPermanent(source.getSourceId()); - if (p != null) { - p.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - Player pl = game.getPlayer(p.getControllerId()); - if (pl != null) - pl.shuffleLibrary(source, game); + Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + Set toShuffle = new LinkedHashSet<>(); + if (targetCreature != null) { + Player owner = game.getPlayer(targetCreature.getOwnerId()); + if (owner != null) { + owner.putCardsOnTopOfLibrary(targetCreature, game, source, true); + toShuffle.add(owner); + } } - if (s != null) { - s.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - Player pl = game.getPlayer(s.getControllerId()); - if (pl != null) - pl.shuffleLibrary(source, game); + if (sourcePermanent != null) { + Player owner = game.getPlayer(sourcePermanent.getOwnerId()); + if (owner != null) { + owner.putCardsOnTopOfLibrary(sourcePermanent, game, source, true); + toShuffle.add(owner); + } + } + for (Player player : toShuffle) { + player.shuffleLibrary(source, game); } return true; } @@ -82,4 +90,4 @@ class VoidStalkerEffect extends OneShotEffect { public VoidStalkerEffect copy() { return new VoidStalkerEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/v/VortexElemental.java b/Mage.Sets/src/mage/cards/v/VortexElemental.java index 1194946fcd1..5217d92b932 100644 --- a/Mage.Sets/src/mage/cards/v/VortexElemental.java +++ b/Mage.Sets/src/mage/cards/v/VortexElemental.java @@ -1,4 +1,3 @@ - package mage.cards.v; import java.util.HashSet; @@ -12,9 +11,11 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.combat.MustBeBlockedByTargetSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.combat.Combat; @@ -30,7 +31,7 @@ import mage.target.common.TargetCreaturePermanent; public final class VortexElemental extends CardImpl { public VortexElemental(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}"); this.subtype.add(SubType.ELEMENTAL); this.power = new MageInt(0); @@ -80,7 +81,7 @@ class VortexElementalEffect extends OneShotEffect { Set playersToShuffle = new HashSet<>(); creaturesToReturn.add(source.getSourceId()); if (combat != null) { - for(CombatGroup combatGroup: combat.getGroups()) { + for (CombatGroup combatGroup : combat.getGroups()) { if (combatGroup.getAttackers().contains(source.getSourceId())) { creaturesToReturn.addAll(combatGroup.getBlockers()); } else if (combatGroup.getBlockers().contains(source.getSourceId())) { @@ -88,14 +89,15 @@ class VortexElementalEffect extends OneShotEffect { } } } - for (UUID creatureId: creaturesToReturn) { + for (UUID creatureId : creaturesToReturn) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { playersToShuffle.add(creature.getControllerId()); - creature.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); } } - for (UUID playerId: playersToShuffle){ + Cards toLib = new CardsImpl(creaturesToReturn); + controller.putCardsOnTopOfLibrary(toLib, game, source, false); + for (UUID playerId : playersToShuffle) { Player player = game.getPlayer(playerId); if (player != null) { player.shuffleLibrary(source, game); @@ -105,7 +107,6 @@ class VortexElementalEffect extends OneShotEffect { return true; } - return false; } } diff --git a/Mage.Sets/src/mage/cards/w/WhiskAway.java b/Mage.Sets/src/mage/cards/w/WhiskAway.java index ebc9e133a5b..d3a3c7336f5 100644 --- a/Mage.Sets/src/mage/cards/w/WhiskAway.java +++ b/Mage.Sets/src/mage/cards/w/WhiskAway.java @@ -1,4 +1,3 @@ - package mage.cards.w; import java.util.UUID; @@ -8,10 +7,10 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.common.FilterAttackingOrBlockingCreature; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.common.TargetCreaturePermanent; /** @@ -19,11 +18,11 @@ import mage.target.common.TargetCreaturePermanent; * @author fireshoes */ public final class WhiskAway extends CardImpl { - + private static final FilterAttackingOrBlockingCreature filter = new FilterAttackingOrBlockingCreature(); public WhiskAway(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); // Put target attacking or blocking creature on top of its owner's library. this.getSpellAbility().addEffect(new WhiskAwayEffect()); @@ -53,10 +52,10 @@ class WhiskAwayEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source)); - if (targetCreature != null) { - targetCreature.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - return true; + Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); + Player controller = game.getPlayer(source.getControllerId()); + if (targetCreature != null && controller != null) { + return controller.putCardsOnTopOfLibrary(targetCreature, game, source, true); } return false; } @@ -65,4 +64,4 @@ class WhiskAwayEffect extends OneShotEffect { public WhiskAwayEffect copy() { return new WhiskAwayEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/w/Worldpurge.java b/Mage.Sets/src/mage/cards/w/Worldpurge.java index 5fff60ffe75..7a05c398b4b 100644 --- a/Mage.Sets/src/mage/cards/w/Worldpurge.java +++ b/Mage.Sets/src/mage/cards/w/Worldpurge.java @@ -1,4 +1,3 @@ - package mage.cards.w; import java.util.HashSet; @@ -78,16 +77,11 @@ class WorldpurgeEffect extends OneShotEffect { int numberInHand = Math.min(7, hand.size()); TargetCardInHand target = new TargetCardInHand(0, numberInHand, new FilterCard("cards to keep in hand")); Cards cardsToLibrary = new CardsImpl(); + cardsToLibrary.addAll(player.getHand()); if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { - for (Card card : hand.getCards(game)) { - if (!target.getTargets().contains(card.getId())) { - cardsToLibrary.add(card); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - } - } + cardsToLibrary.removeAll(target.getTargets()); } - player.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false); - player.shuffleLibrary(source, game); + player.shuffleCardsToLibrary(cardsToLibrary, game, source); } } game.emptyManaPools(); diff --git a/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java b/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java index 0c452d69f69..166847feb51 100644 --- a/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java +++ b/Mage.Sets/src/mage/cards/w/WriteIntoBeing.java @@ -1,4 +1,3 @@ - package mage.cards.w; import java.util.UUID; @@ -84,12 +83,11 @@ class WriteIntoBeingEffect extends OneShotEffect { new ManifestEffect(1).apply(game, source); if (controller.getLibrary().hasCards()) { Card cardToPutBack = controller.getLibrary().getFromTop(game); - String position = "on top"; if (controller.chooseUse(Outcome.Detriment, "Put " + cardToPutBack.getName() + " on bottom of library?", source, game)) { - cardToPutBack.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); - position = "on bottom"; + controller.putCardsOnBottomOfLibrary(cardToPutBack, game, source, true); + } else { + controller.putCardsOnTopOfLibrary(cardToPutBack, game, source, true); } - game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts the other card " + position + " of their library"); } return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ShuffleIntoLibraryTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ShuffleIntoLibraryTargetEffect.java index 09ced2946b9..1ff0f8b936e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ShuffleIntoLibraryTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ShuffleIntoLibraryTargetEffect.java @@ -1,17 +1,12 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package mage.abilities.effects.common; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -20,17 +15,20 @@ import mage.players.Player; */ public class ShuffleIntoLibraryTargetEffect extends OneShotEffect { + boolean optional; + public ShuffleIntoLibraryTargetEffect() { - super(Outcome.Detriment); + this(false); } - public ShuffleIntoLibraryTargetEffect(String effectText) { + public ShuffleIntoLibraryTargetEffect(boolean optional) { super(Outcome.Detriment); - this.staticText = effectText; + this.optional = optional; } public ShuffleIntoLibraryTargetEffect(final ShuffleIntoLibraryTargetEffect effect) { super(effect); + this.optional = effect.optional; } @Override @@ -40,19 +38,26 @@ public class ShuffleIntoLibraryTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); + MageObject cardObject = game.getObject(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - if (permanent != null && controller != null) { - if (controller.moveCards(permanent, Zone.LIBRARY, source, game)) { - game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game); + if (cardObject != null && controller != null && cardObject instanceof Card) { + if (!optional + || controller.chooseUse(Outcome.Benefit, "Do you wish to shuffle " + cardObject.getIdName() + " into " + + (((Card) cardObject).getOwnerId().equals(source.getControllerId()) ? "your" : "its owners") + + " library?", source, game)) { + Player owner = game.getPlayer(((Card) cardObject).getOwnerId()); + if (owner != null) { + return owner.shuffleCardsToLibrary(((Card) cardObject), game, source); + } + return true; } - return true; } return false; } @Override - public String getText(Mode mode) { + public String getText(Mode mode + ) { if (staticText != null && !staticText.isEmpty()) { return staticText; } else { diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index 958e08a2caa..9e4478acb48 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -1,8 +1,11 @@ package mage.players; +import java.io.Serializable; +import java.util.*; import mage.MageItem; import mage.MageObject; import mage.MageObjectReference; +import mage.Mana; import mage.abilities.*; import mage.abilities.costs.AlternativeSourceCosts; import mage.abilities.costs.Cost; @@ -38,10 +41,6 @@ import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; import mage.util.Copyable; -import java.io.Serializable; -import java.util.*; -import mage.Mana; - /** * @author BetaSteward_at_googlemail.com */ @@ -366,8 +365,9 @@ public interface Player extends MageItem, Copyable { * @param game * @param noMana if it's a spell i can be cast without paying mana * @param ignoreTiming if it's cast during the resolution of another spell - * no sorcery or play land timing restriction are checked. For a land it has - * to be the turn of the player playing that card. + * no sorcery or play land timing restriction are + * checked. For a land it has to be the turn of the + * player playing that card. * @param reference mage object that allows to play the card * @return */ @@ -377,8 +377,9 @@ public interface Player extends MageItem, Copyable { * @param card the land card to play * @param game * @param ignoreTiming false - it won't be checked if the stack is empty and - * you are able to play a Sorcery. It's still checked, if you are able to - * play a land concerning the number of lands you already played. + * you are able to play a Sorcery. It's still checked, + * if you are able to play a land concerning the number + * of lands you already played. * @return */ boolean playLand(Card card, Game game, boolean ignoreTiming); @@ -446,11 +447,11 @@ public interface Player extends MageItem, Copyable { void revealCards(Ability source, Cards cards, Game game); - void revealCards(String name, Cards cards, Game game); + void revealCards(String titelSuffix, Cards cards, Game game); - void revealCards(Ability source, String name, Cards cards, Game game); + void revealCards(Ability source, String titelSuffix, Cards cards, Game game); - void revealCards(String name, Cards cards, Game game, boolean postToLog); + void revealCards(String titelSuffix, Cards cards, Game game, boolean postToLog); /** * Adds the cards to the reveal window and adds the source object's id name @@ -532,10 +533,11 @@ public interface Player extends MageItem, Copyable { * @param cards - list of cards that have to be moved * @param game - game * @param anyOrder - true = if player can determine the order of the cards - * else false = random order - * 401.4. If an effect puts two or more cards in a specific position in a library - * at the same time, the owner of those cards may arrange them in any order. - * That library’s owner doesn’t reveal the order in which the cards go into the library. + * else false = random order 401.4. If an effect puts two or + * more cards in a specific position in a library at the + * same time, the owner of those cards may arrange them in + * any order. That library’s owner doesn’t reveal the order + * in which the cards go into the library. * @param source - source ability * @return */ @@ -636,9 +638,9 @@ public interface Player extends MageItem, Copyable { void untap(Game game); ManaOptions getManaAvailable(Game game); - + void addAvailableTriggeredMana(List netManaAvailable); - + List> getAvailableTriggeredMana(); List getPlayable(Game game, boolean hidden); @@ -747,9 +749,10 @@ public interface Player extends MageItem, Copyable { * @param game * @param tapped the cards are tapped on the battlefield * @param faceDown the cards are face down in the to zone - * @param byOwner the card is moved (or put onto battlefield) by the owner - * of the card and if target zone is battlefield controls the permanent - * (instead of the controller of the source) + * @param byOwner the card is moved (or put onto battlefield) by the + * owner of the card and if target zone is battlefield + * controls the permanent (instead of the controller + * of the source) * @param appliedEffects * @return */ diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index ccd31a5cc9f..32cf353f32e 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -967,7 +967,7 @@ public abstract class PlayerImpl implements Player, Serializable { if (cards.isEmpty()) { return true; } - game.informPlayers(getName() + " shuffels " + CardUtil.numberToText(cards.size(), "a") + game.informPlayers(getLogName() + " shuffels " + CardUtil.numberToText(cards.size(), "a") + " card" + (cards.size() == 1 ? "" : "s") + " into their library."); boolean status = moveCards(cards, Zone.LIBRARY, source, game);