diff --git a/Mage.Sets/src/mage/sets/gatecrash/EnterTheInfinite.java b/Mage.Sets/src/mage/sets/gatecrash/EnterTheInfinite.java index a53a1e0b98..b0710850a2 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/EnterTheInfinite.java +++ b/Mage.Sets/src/mage/sets/gatecrash/EnterTheInfinite.java @@ -27,6 +27,7 @@ */ package mage.sets.gatecrash; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; @@ -35,14 +36,17 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect; import mage.cards.Card; import mage.cards.CardImpl; -import mage.constants.*; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.PhaseStep; +import mage.constants.Rarity; import mage.game.Game; import mage.game.turn.Step; import mage.players.Player; import mage.target.common.TargetCardInHand; -import java.util.UUID; - /** * * @author LevelX2 @@ -53,8 +57,7 @@ public class EnterTheInfinite extends CardImpl { super(ownerId, 34, "Enter the Infinite", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{8}{U}{U}{U}{U}"); this.expansionSetCode = "GTC"; - - // Draw cards equal to the number of cards in your library, + // Draw cards equal to the number of cards in your library, this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(new CardsInControllerLibraryCount())); //then put a card from your hand on top of your library. this.getSpellAbility().addEffect(new PutCardOnLibraryEffect()); @@ -72,8 +75,8 @@ public class EnterTheInfinite extends CardImpl { } } - class CardsInControllerLibraryCount implements DynamicValue { + @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { if (sourceAbility != null) { @@ -119,14 +122,13 @@ class PutCardOnLibraryEffect extends OneShotEffect { @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) { TargetCardInHand target = new TargetCardInHand(); - player.chooseTarget(Outcome.ReturnToHand, target, source, game); - Card card = player.getHand().get(target.getFirstTarget(), game); + controller.chooseTarget(Outcome.ReturnToHand, target, source, game); + Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { - player.getHand().remove(card); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + controller.putCardsOnTopOfLibrary(new CardsImpl(card), game, source, false); } return true; } @@ -134,29 +136,27 @@ class PutCardOnLibraryEffect extends OneShotEffect { } } +class MaximumHandSizeEffect extends MaximumHandSizeControllerEffect { -class MaximumHandSizeEffect extends MaximumHandSizeControllerEffect{ - - public MaximumHandSizeEffect(){ + public MaximumHandSizeEffect() { super(Integer.MAX_VALUE, Duration.Custom, MaximumHandSizeControllerEffect.HandSizeModification.SET); staticText = "You have no maximum hand size until your next turn"; } - - public MaximumHandSizeEffect(final MaximumHandSizeEffect effect) { + + public MaximumHandSizeEffect(final MaximumHandSizeEffect effect) { super(effect); } - + @Override public boolean isInactive(Ability source, Game game) { - if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) - { + if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) { if (game.getActivePlayerId().equals(source.getControllerId())) { return true; } } return false; } - + @Override public MaximumHandSizeEffect copy() { return new MaximumHandSizeEffect(this); diff --git a/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java b/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java index 2fcfe39ffe..82e8cf7636 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java +++ b/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java @@ -147,7 +147,7 @@ class TheGreatAuroraEffect extends OneShotEffect { toBattlefield.addAll(target.getTargets()); } } - return controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); + return controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); } return false; } diff --git a/Mage.Sets/src/mage/sets/tempest/DreamCache.java b/Mage.Sets/src/mage/sets/tempest/DreamCache.java index 6d223175be..0aa934b4bf 100644 --- a/Mage.Sets/src/mage/sets/tempest/DreamCache.java +++ b/Mage.Sets/src/mage/sets/tempest/DreamCache.java @@ -30,12 +30,13 @@ package mage.sets.tempest; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; +import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInHand; @@ -50,7 +51,6 @@ public class DreamCache extends CardImpl { super(ownerId, 59, "Dream Cache", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{2}{U}"); this.expansionSetCode = "TMP"; - // Draw three cards, then put two cards from your hand both on top of your library or both on the bottom of your library. this.getSpellAbility().addEffect(new DreamCacheEffect()); } @@ -71,7 +71,7 @@ class DreamCacheEffect extends OneShotEffect { super(Outcome.DrawCard); this.staticText = "Draw three cards, then put two cards from your hand both on top of your library or both on the bottom of your library."; } - + public DreamCacheEffect(final DreamCacheEffect effect) { super(effect); } @@ -80,33 +80,26 @@ class DreamCacheEffect extends OneShotEffect { public DreamCacheEffect copy() { return new DreamCacheEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.drawCards(3, game); - - boolean putOnTop = player.chooseUse(Outcome.Neutral, "Put cards on top?", source, game); - putInLibrary(player, source, game, putOnTop); - putInLibrary(player, source, game, putOnTop); - + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + controller.drawCards(3, game); + boolean putOnTop = controller.chooseUse(Outcome.Neutral, "Put cards on top?", source, game); + TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard()); + controller.chooseTarget(Outcome.Detriment, target, source, game); + Cards cardsToLibrary = new CardsImpl(target.getTargets()); + if (!cardsToLibrary.isEmpty()) { + if (putOnTop) { + controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false); + } else { + controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false); + } + } return true; } return false; } - - private boolean putInLibrary(Player player, Ability source, Game game, boolean putOnTop) { - if (player.getHand().size() > 0) { - TargetCardInHand target = new TargetCardInHand(); - player.chooseTarget(Outcome.Detriment, target, source, game); - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - player.getHand().remove(card); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, putOnTop); - return true; - } - } - return false; - } + } diff --git a/Mage.Sets/src/mage/sets/venservskoth/SawtoothLoon.java b/Mage.Sets/src/mage/sets/venservskoth/SawtoothLoon.java index ccef7acff4..a4c3ff1e73 100644 --- a/Mage.Sets/src/mage/sets/venservskoth/SawtoothLoon.java +++ b/Mage.Sets/src/mage/sets/venservskoth/SawtoothLoon.java @@ -35,12 +35,13 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ReturnToHandChosenControlledPermanentEffect; import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; +import mage.filter.FilterCard; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.ColorPredicate; @@ -58,8 +59,8 @@ public class SawtoothLoon extends CardImpl { static { Predicates.or( - new ColorPredicate(ObjectColor.WHITE), - new ColorPredicate(ObjectColor.BLUE)); + new ColorPredicate(ObjectColor.WHITE), + new ColorPredicate(ObjectColor.BLUE)); } public SawtoothLoon(UUID ownerId) { @@ -110,21 +111,15 @@ class SawtoothLoonEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { controller.drawCards(2, game); - putOnLibrary(controller, source, game); - putOnLibrary(controller, source, game); + TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard()); + controller.chooseTarget(Outcome.Detriment, target, source, game); + Cards cardsToLibrary = new CardsImpl(target.getTargets()); + if (!cardsToLibrary.isEmpty()) { + controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false); + } return true; } return false; } - private boolean putOnLibrary(Player player, Ability source, Game game) { - TargetCardInHand target = new TargetCardInHand(); - player.chooseTarget(Outcome.ReturnToHand, target, source, game); - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - player.getHand().remove(card); - player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, false, false); - } - return true; - } } diff --git a/Mage.Sets/src/mage/sets/worldwake/JaceTheMindSculptor.java b/Mage.Sets/src/mage/sets/worldwake/JaceTheMindSculptor.java index d68cd5c7ed..26c00ef4c8 100644 --- a/Mage.Sets/src/mage/sets/worldwake/JaceTheMindSculptor.java +++ b/Mage.Sets/src/mage/sets/worldwake/JaceTheMindSculptor.java @@ -41,6 +41,7 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; +import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; @@ -148,27 +149,19 @@ class JaceTheMindSculptorEffect2 extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.drawCards(3, game); - putOnLibrary(player, source, game); - putOnLibrary(player, source, game); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + controller.drawCards(3, game); + TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard()); + controller.chooseTarget(Outcome.Detriment, target, source, game); + Cards cardsToLibrary = new CardsImpl(target.getTargets()); + if (!cardsToLibrary.isEmpty()) { + controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, true); + } return true; } return false; } - - private boolean putOnLibrary(Player player, Ability source, Game game) { - TargetCardInHand target = new TargetCardInHand(); - player.chooseTarget(Outcome.ReturnToHand, target, source, game); - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - player.getHand().remove(card); - player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false); - } - return true; - } - } class JaceTheMindSculptorEffect3 extends OneShotEffect { diff --git a/Mage/src/mage/abilities/effects/common/search/SearchTargetGraveyardHandLibraryForCardNameAndExileEffect.java b/Mage/src/mage/abilities/effects/common/search/SearchTargetGraveyardHandLibraryForCardNameAndExileEffect.java index dd9c3c94e6..3f14a35fd3 100644 --- a/Mage/src/mage/abilities/effects/common/search/SearchTargetGraveyardHandLibraryForCardNameAndExileEffect.java +++ b/Mage/src/mage/abilities/effects/common/search/SearchTargetGraveyardHandLibraryForCardNameAndExileEffect.java @@ -27,12 +27,10 @@ */ package mage.abilities.effects.common.search; -import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.constants.Outcome; @@ -98,14 +96,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getLogName()); TargetCard target = new TargetCard((graveyardExileOptional ? 0 : cardsCount), cardsCount, Zone.GRAVEYARD, filter); if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) { - List targets = target.getTargets(); - for (UUID targetId : targets) { - Card targetCard = targetPlayer.getGraveyard().get(targetId, game); - if (targetCard != null) { - targetPlayer.getGraveyard().remove(targetCard); - controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.GRAVEYARD, true); - } - } + controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game); } } @@ -114,14 +105,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getLogName()); TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter); if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) { - List targets = target.getTargets(); - for (UUID targetId : targets) { - Card targetCard = targetPlayer.getHand().get(targetId, game); - if (targetCard != null) { - targetPlayer.getHand().remove(targetCard); - controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.HAND, true); - } - } + controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game); } // cards in Library @@ -131,15 +115,8 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName()); TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter); if (controller.choose(Outcome.Exile, cardsInLibrary, targetLib, game)) { - List targets = targetLib.getTargets(); - for (UUID targetId : targets) { - Card targetCard = targetPlayer.getLibrary().remove(targetId, game); - if (targetCard != null) { - controller.moveCardToExileWithInfo(targetCard, null, null, source.getSourceId(), game, Zone.LIBRARY, true); - } - } + controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game); } - targetPlayer.shuffleLibrary(game); }