From 415700ccb2192ec2522797e37fa20f5e2ef30070 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 18 Oct 2015 23:33:23 +0200 Subject: [PATCH] * Some more changes for rework of ENTERS_THE_BATTLEFIELD event and card movement. --- Mage.Common/src/mage/utils/MageVersion.java | 2 +- .../src/mage/sets/alarareborn/Wargate.java | 13 +- .../sets/antiquities/TransmuteArtifact.java | 40 +++---- .../src/mage/sets/apocalypse/LifeDeath.java | 17 ++- .../sets/archenemy/MakeshiftMannequin.java | 17 +-- .../sets/avacynrestored/RestorationAngel.java | 16 +-- .../betrayersofkamigawa/GoryosVengeance.java | 4 +- .../IwamoriOfTheOpenFist.java | 19 +-- .../betrayersofkamigawa/PatronOfTheMoon.java | 11 +- .../sets/bornofthegods/Peregrination.java | 7 +- .../sets/championsofkamigawa/Reweave.java | 15 +-- .../championsofkamigawa/ThroughTheBreach.java | 2 +- .../src/mage/sets/coldsnap/ArcumDagsson.java | 16 +-- .../mage/sets/commander/KaaliaOfTheVast.java | 20 ++-- .../src/mage/sets/commander/KodamasReach.java | 6 +- .../sets/commander/TarielReckonerOfSouls.java | 2 +- .../commander2014/DarettiScrapSavant.java | 2 +- .../sets/commander2014/InfernalOffering.java | 14 +-- .../commander2014/NahiriTheLithomancer.java | 4 +- .../mage/sets/commander2014/ScrapMastery.java | 25 ++-- .../mage/sets/commander2014/WakeTheDead.java | 37 +++--- .../sets/commander2014/WaveOfVitriol.java | 33 +++-- .../src/mage/sets/conflux/PathToExile.java | 59 +++++---- .../mage/sets/conflux/SkywardEyeProphets.java | 4 +- .../sets/conspiracy/GrenzoDungeonWarden.java | 2 +- .../src/mage/sets/conspiracy/Victimize.java | 20 ++-- .../darkascension/MikaeusTheUnhallowed.java | 10 +- .../src/mage/sets/darksteel/Reshape.java | 20 ++-- .../mage/sets/dissension/CryptChampion.java | 16 +-- .../sets/dragonsmaze/BloodBaronOfVizkopa.java | 71 +++++------ .../sets/dragonsoftarkir/DeathmistRaptor.java | 6 +- .../sets/dragonsoftarkir/SwiftWarkite.java | 4 +- .../elvesvsgoblins/SkirkDrillSergeant.java | 18 ++- .../src/mage/sets/exodus/OathOfDruids.java | 17 ++- .../src/mage/sets/exodus/OathOfLieges.java | 2 +- .../fatereforged/GhastlyConscription.java | 18 +-- .../sets/fatereforged/JeskaiInfiltrator.java | 37 +++--- .../sets/fatereforged/RallyTheAncestors.java | 7 +- .../sets/fatereforged/TorrentElemental.java | 5 +- .../fatereforged/UginTheSpiritDragon.java | 9 +- .../mage/sets/fifthdawn/EndlessWhispers.java | 31 ++--- .../src/mage/sets/fifthdawn/MyrServitor.java | 22 ++-- .../src/mage/sets/fourthedition/TheRack.java | 4 +- .../mage/sets/futuresight/SwordOfTheMeek.java | 4 +- .../sets/gatecrash/ObzedatGhostCouncil.java | 2 +- .../src/mage/sets/iceage/DanceOfTheDead.java | 52 ++++---- .../src/mage/sets/innistrad/CaravanVigil.java | 7 +- .../src/mage/sets/innistrad/GhostQuarter.java | 14 +-- .../mage/sets/invasion/PhyrexianDelver.java | 2 +- .../mage/sets/invasion/ThicketElemental.java | 14 +-- .../mage/sets/judgment/WorldgorgerDragon.java | 22 ++-- .../sets/khansoftarkir/AshcloudPhoenix.java | 20 ++-- .../sets/khansoftarkir/KheruLichLord.java | 30 ++--- .../khansoftarkir/MeanderingTowershell.java | 26 ++-- .../sets/khansoftarkir/SeeTheUnwritten.java | 25 ++-- .../sets/lorwyn/IncandescentSoulstoke.java | 2 +- .../src/mage/sets/magic2010/HiveMind.java | 7 +- .../mage/sets/magic2010/OpenTheVaults.java | 42 +++---- .../mage/sets/magic2010/SphinxAmbassador.java | 12 +- .../src/mage/sets/magic2011/Cultivate.java | 6 +- .../mage/sets/magic2011/NecroticPlague.java | 19 ++- .../mage/sets/magic2015/BoonweaverGiant.java | 18 +-- .../magic2015/JaliraMasterPolymorphist.java | 4 +- .../mage/sets/magic2015/NissaWorldwaker.java | 23 ++-- .../sets/magic2015/YisanTheWandererBard.java | 25 ++-- .../sets/magicorigins/NissasPilgrimage.java | 4 +- .../sets/magicorigins/TheGreatAurora.java | 94 +++++++-------- .../sets/magicorigins/WoodlandBellower.java | 21 ++-- .../sets/mediainserts/MagisterOfWorth.java | 14 +-- .../mage/sets/mercadianmasques/Bribery.java | 10 +- .../src/mage/sets/mirage/ShallowGrave.java | 2 +- .../sets/mirrodin/ScytheOfTheWretched.java | 3 +- .../mirrodinbesieged/GreenSunsZenith.java | 25 ++-- .../mage/sets/modernmasters/ToothAndNail.java | 11 +- .../src/mage/sets/morningtide/Scapeshift.java | 42 +++---- .../sets/nemesis/LinSivviDefiantHero.java | 26 ++-- .../mage/sets/newphyrexia/BirthingPod.java | 23 ++-- .../sets/newphyrexia/MeliraSylvokOutcast.java | 26 ++-- .../src/mage/sets/odyssey/Zoologist.java | 22 ++-- .../sets/onslaught/PatriarchsBidding.java | 22 ++-- .../sets/onslaught/RiptideShapeshifter.java | 32 ++--- .../sets/ravnica/SistersOfStoneDeath.java | 8 +- .../returntoravnica/CorpsejackMenace.java | 5 +- .../sets/returntoravnica/VolatileRig.java | 2 +- .../sets/saviorsofkamigawa/EnduringIdeal.java | 23 ++-- .../saviorsofkamigawa/EternalDominion.java | 15 ++- .../FootstepsOfTheGoryo.java | 11 +- .../mage/sets/shadowmoor/ImpromptuRaid.java | 2 +- .../mage/sets/shadowmoor/PuppeteerClique.java | 10 +- .../sets/shardsofalara/TezzeretTheSeeker.java | 14 +-- .../src/mage/sets/tempest/CorpseDance.java | 35 +++--- .../src/mage/sets/tempest/LivingDeath.java | 28 +++-- .../mage/sets/tempest/StaunchDefenders.java | 6 +- .../sets/tenthedition/AcademyResearchers.java | 16 +-- .../sets/theros/AshiokNightmareWeaver.java | 12 +- .../mage/sets/theros/PyxisOfPandemonium.java | 9 +- .../src/mage/sets/theros/WhipOfErebos.java | 29 +++-- .../mage/sets/theros/XenagosTheReveler.java | 26 ++-- .../src/mage/sets/timespiral/LivingEnd.java | 25 ++-- .../mage/sets/urzasdestiny/Gamekeeper.java | 12 +- .../src/mage/sets/urzasdestiny/Replenish.java | 30 ++--- .../mage/sets/urzaslegacy/GoblinWelder.java | 8 +- .../src/mage/sets/urzassaga/CopperGnomes.java | 11 +- Mage.Sets/src/mage/sets/urzassaga/Exhume.java | 9 +- .../src/mage/sets/urzassaga/PlanarBirth.java | 19 +-- .../src/mage/sets/urzassaga/SneakAttack.java | 10 +- .../mage/sets/vintagemasters/ChaosWarp.java | 30 +++-- .../src/mage/sets/vintagemasters/Eureka.java | 3 +- .../sets/vintagemasters/MistmoonGriffin.java | 4 +- .../src/mage/sets/visions/Necromancy.java | 6 +- .../mage/sets/weatherlight/BoneDancer.java | 10 +- .../sets/worldwake/QuestForUlasTemple.java | 9 +- .../src/mage/sets/zendikar/SummoningTrap.java | 13 +- .../cards/abilities/keywords/PersistTest.java | 3 +- .../cards/abilities/keywords/UndyingTest.java | 4 +- .../cards/enchantments/OathOfLiegesTest.java | 1 + .../cards/triggers/WorldgorgerDragonTest.java | 113 +++++++++--------- .../java/org/mage/test/player/TestPlayer.java | 15 --- Mage/src/mage/abilities/AbilityImpl.java | 9 +- .../effects/common/CopyPermanentEffect.java | 2 +- .../PutLandFromHandOntoBattlefieldEffect.java | 14 +-- ...ourceFromGraveyardToBattlefieldEffect.java | 35 +++--- .../search/SearchLibraryPutInPlayEffect.java | 74 +++++------- ...rchLibraryPutInPlayTargetPlayerEffect.java | 35 +++--- .../effects/keyword/ManifestEffect.java | 6 +- .../keyword/ManifestTargetPlayerEffect.java | 4 +- .../mage/cards/repository/CardRepository.java | 2 +- Mage/src/mage/players/Player.java | 40 ------- Mage/src/mage/players/PlayerImpl.java | 30 +---- 129 files changed, 1029 insertions(+), 1265 deletions(-) diff --git a/Mage.Common/src/mage/utils/MageVersion.java b/Mage.Common/src/mage/utils/MageVersion.java index 5e79ba1e3ed..bc712e76d26 100644 --- a/Mage.Common/src/mage/utils/MageVersion.java +++ b/Mage.Common/src/mage/utils/MageVersion.java @@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable { public final static int MAGE_VERSION_MAJOR = 1; public final static int MAGE_VERSION_MINOR = 4; public final static int MAGE_VERSION_PATCH = 4; - public final static String MAGE_VERSION_MINOR_PATCH = "v8"; + public final static String MAGE_VERSION_MINOR_PATCH = "v9"; public final static String MAGE_VERSION_INFO = ""; private final int major; diff --git a/Mage.Sets/src/mage/sets/alarareborn/Wargate.java b/Mage.Sets/src/mage/sets/alarareborn/Wargate.java index db3728446e6..38654b08777 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/Wargate.java +++ b/Mage.Sets/src/mage/sets/alarareborn/Wargate.java @@ -28,14 +28,13 @@ package mage.sets.alarareborn; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.Filter; import mage.filter.common.FilterPermanentCard; @@ -54,10 +53,6 @@ public class Wargate extends CardImpl { super(ownerId, 129, "Wargate", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{G}{W}{U}"); this.expansionSetCode = "ARB"; - - - - // Search your library for a permanent card with converted mana cost X or less, put it onto the battlefield, then shuffle your library. this.getSpellAbility().addEffect(new WargateEffect()); } @@ -72,8 +67,8 @@ public class Wargate extends CardImpl { } } - class WargateEffect extends OneShotEffect { + WargateEffect() { super(Outcome.PutCreatureInPlay); staticText = "Search your library for a permanent card with converted mana cost X or less, put it onto the battlefield, then shuffle your library"; @@ -97,7 +92,7 @@ class WargateEffect extends OneShotEffect { if (target.getTargets().size() > 0) { Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java b/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java index d0b6d85fde4..7a12056f9a8 100644 --- a/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java +++ b/Mage.Sets/src/mage/sets/antiquities/TransmuteArtifact.java @@ -27,7 +27,6 @@ */ package mage.sets.antiquities; -import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.mana.GenericManaCost; @@ -43,7 +42,6 @@ import mage.filter.common.FilterControlledArtifactPermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.common.TargetArtifactPermanent; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetControlledPermanent; @@ -57,7 +55,6 @@ public class TransmuteArtifact extends CardImpl { super(ownerId, 58, "Transmute Artifact", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{U}{U}"); this.expansionSetCode = "ATQ"; - // Sacrifice an artifact. If you do, search your library for an artifact card. If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. If you don't, put it into its owner's graveyard. Then shuffle your library. this.getSpellAbility().addEffect(new TransmuteArtifactEffect()); } @@ -74,7 +71,6 @@ public class TransmuteArtifact extends CardImpl { class TransmuteArtifactEffect extends SearchEffect { - public TransmuteArtifactEffect() { super(new TargetCardInLibrary(new FilterArtifactCard()), Outcome.PutCardInPlay); staticText = "Sacrifice an artifact. If you do, search your library for an artifact card. If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. If you don't, put it into its owner's graveyard. Then shuffle your library"; @@ -95,41 +91,36 @@ class TransmuteArtifactEffect extends SearchEffect { if (controller == null) { return false; } - //Sacrifice an artifact. + //Sacrifice an artifact. int convertedManaCost = 0; boolean sacrifice = false; TargetControlledPermanent targetArtifact = new TargetControlledPermanent(new FilterControlledArtifactPermanent()); - if(controller.chooseTarget(Outcome.Sacrifice, targetArtifact, source, game)){ + if (controller.chooseTarget(Outcome.Sacrifice, targetArtifact, source, game)) { Permanent permanent = game.getPermanent(targetArtifact.getFirstTarget()); - if(permanent != null){ + if (permanent != null) { convertedManaCost = permanent.getManaCost().convertedManaCost(); sacrifice = permanent.sacrifice(source.getSourceId(), game); } - } - else - { + } else { return true; } - //If you do, search your library for an artifact card. + //If you do, search your library for an artifact card. if (sacrifice && controller.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { - for (UUID cardId: target.getTargets()) { + for (UUID cardId : target.getTargets()) { Card card = controller.getLibrary().getCard(cardId, game); if (card != null) { - //If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. - if(card.getManaCost().convertedManaCost() <= convertedManaCost){ - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); - } - else - { - //If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. + //If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. + if (card.getManaCost().convertedManaCost() <= convertedManaCost) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } else { + //If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. GenericManaCost cost = new GenericManaCost(card.getManaCost().convertedManaCost() - convertedManaCost); - if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){ - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); - } - else{ + if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } else { //If you don't, put it into its owner's graveyard. Then shuffle your library - controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + controller.moveCards(card, Zone.GRAVEYARD, source, game); } } } @@ -142,5 +133,4 @@ class TransmuteArtifactEffect extends SearchEffect { return false; } - } diff --git a/Mage.Sets/src/mage/sets/apocalypse/LifeDeath.java b/Mage.Sets/src/mage/sets/apocalypse/LifeDeath.java index 1db52a16d06..0cdede7a804 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/LifeDeath.java +++ b/Mage.Sets/src/mage/sets/apocalypse/LifeDeath.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.apocalypse; import java.util.UUID; @@ -34,11 +33,11 @@ import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect; import mage.cards.Card; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.cards.SplitCard; +import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterCreatureCard; @@ -52,7 +51,6 @@ import mage.target.common.TargetCardInYourGraveyard; * * @author LevelX2 */ - public class LifeDeath extends SplitCard { public LifeDeath(UUID ownerId) { @@ -61,8 +59,8 @@ public class LifeDeath extends SplitCard { // Life // All lands you control become 1/1 creatures until end of turn. They're still lands. - getLeftHalfCard().getSpellAbility().addEffect(new BecomesCreatureAllEffect(new LifeLandToken(), "lands", - new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn)); + getLeftHalfCard().getSpellAbility().addEffect(new BecomesCreatureAllEffect(new LifeLandToken(), "lands", + new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn)); // Death // Return target creature card from your graveyard to the battlefield. You lose life equal to its converted mana cost. @@ -83,6 +81,7 @@ public class LifeDeath extends SplitCard { } class LifeLandToken extends Token { + public LifeLandToken() { super("", "1/1 creatures"); cardType.add(CardType.CREATURE); @@ -115,10 +114,10 @@ class DeathEffect extends OneShotEffect { if (creatureCard != null && controller != null) { boolean result = false; if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) { - result = controller.putOntoBattlefieldWithInfo(creatureCard, game, Zone.GRAVEYARD, source.getSourceId()); - } + controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game); + } controller.loseLife(creatureCard.getManaCost().convertedManaCost(), game); - return result; + return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/archenemy/MakeshiftMannequin.java b/Mage.Sets/src/mage/sets/archenemy/MakeshiftMannequin.java index e6f6c9a72df..cf248de7b5d 100644 --- a/Mage.Sets/src/mage/sets/archenemy/MakeshiftMannequin.java +++ b/Mage.Sets/src/mage/sets/archenemy/MakeshiftMannequin.java @@ -44,6 +44,7 @@ import mage.constants.Rarity; import mage.constants.SubLayer; import mage.constants.Zone; import mage.counters.CounterType; +import mage.counters.Counters; import mage.filter.common.FilterCreatureCard; import mage.game.Game; import mage.game.permanent.Permanent; @@ -77,21 +78,21 @@ public class MakeshiftMannequin extends CardImpl { } class MakeshiftMannequinEffect extends OneShotEffect { - + MakeshiftMannequinEffect() { super(Outcome.PutCreatureInPlay); this.staticText = "Return target creature card from your graveyard to the battlefield with a mannequin counter on it. For as long as that creature has a mannequin counter on it, it has \"When this creature becomes the target of a spell or ability, sacrifice it.\""; } - + MakeshiftMannequinEffect(final MakeshiftMannequinEffect effect) { super(effect); } - + @Override public MakeshiftMannequinEffect copy() { return new MakeshiftMannequinEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -99,12 +100,14 @@ class MakeshiftMannequinEffect extends OneShotEffect { UUID cardId = this.getTargetPointer().getFirst(game, source); Card card = controller.getGraveyard().get(cardId, game); if (card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) { + Counters counters = new Counters(); + counters.addCounter(CounterType.MANNEQUIN.createInstance()); + game.setEnterWithCounters(cardId, counters); + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(cardId); if (permanent != null) { - permanent.addCounters(CounterType.MANNEQUIN.createInstance(), game); ContinuousEffect gainedEffect = new MakeshiftMannequinGainAbilityEffect(); - gainedEffect.setTargetPointer(new FixedTarget(cardId)); + gainedEffect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(gainedEffect, source); } } diff --git a/Mage.Sets/src/mage/sets/avacynrestored/RestorationAngel.java b/Mage.Sets/src/mage/sets/avacynrestored/RestorationAngel.java index bd3043c6e72..65582db1bf7 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/RestorationAngel.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/RestorationAngel.java @@ -51,7 +51,7 @@ import mage.target.common.TargetControlledCreaturePermanent; /** * * @author noxx - + * */ public class RestorationAngel extends CardImpl { @@ -71,7 +71,7 @@ public class RestorationAngel extends CardImpl { this.addAbility(FlashAbility.getInstance()); this.addAbility(FlyingAbility.getInstance()); - + // When Restoration Angel enters the battlefield, you may exile target non-Angel creature you control, then return that card to the battlefield under your control Ability ability = new EntersBattlefieldTriggeredAbility(new RestorationAngelEffect(), true); ability.addTarget(new TargetControlledCreaturePermanent(1, 1, filter, false)); @@ -111,11 +111,13 @@ class RestorationAngelEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null && sourcePermanent != null) { - controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true); - Card card = game.getCard(targetPointer.getFirst(game, source)); - if (card != null) { - Zone currentZone = game.getState().getZone(card.getId()); - return controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId()); + int zcc = permanent.getZoneChangeCounter(game); + controller.moveCards(permanent, Zone.EXILED, source, game); + Card card = game.getCard(permanent.getId()); + if (card != null + && card.getZoneChangeCounter(game) == zcc + 1 + && game.getState().getZone(card.getId()).equals(Zone.EXILED)) { + return controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java index c30dfb512fe..16bef199b09 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/GoryosVengeance.java @@ -110,12 +110,12 @@ class GoryosVengeanceEffect extends OneShotEffect { if (controller != null) { Card card = game.getCard(targetPointer.getFirst(game, source)); if (card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { // Haste ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); // Exile it at end of turn Effect exileEffect = new ExileTargetEffect("Exile " + permanent.getName() + " at the beginning of the next end step"); diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/IwamoriOfTheOpenFist.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/IwamoriOfTheOpenFist.java index 98bc1dbe5f7..b37336ee341 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/IwamoriOfTheOpenFist.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/IwamoriOfTheOpenFist.java @@ -84,26 +84,26 @@ public class IwamoriOfTheOpenFist extends CardImpl { class IwamoriOfTheOpenFistEffect extends OneShotEffect { private static final FilterCard filter = new FilterCard("legendary creature card"); - + static { filter.add(new SupertypePredicate("Legendary")); filter.add(new CardTypePredicate(CardType.CREATURE)); } - + public IwamoriOfTheOpenFistEffect() { super(Outcome.Detriment); this.staticText = "each opponent may put a legendary creature card from his or her hand onto the battlefield"; } - + public IwamoriOfTheOpenFistEffect(final IwamoriOfTheOpenFistEffect effect) { super(effect); } - + @Override public IwamoriOfTheOpenFistEffect copy() { return new IwamoriOfTheOpenFistEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -123,14 +123,7 @@ class IwamoriOfTheOpenFistEffect extends OneShotEffect { } } } - if (cards.size() > 0) { - for (Card card: cards.getCards(game)) { - Player player = game.getPlayer(card.getOwnerId()); - if (player != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); - } - } - } + controller.moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); return true; } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/PatronOfTheMoon.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/PatronOfTheMoon.java index 826408a71be..f6d16875adc 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/PatronOfTheMoon.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/PatronOfTheMoon.java @@ -35,8 +35,8 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.OfferingAbility; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -100,13 +100,8 @@ class PatronOfTheMoonEffect extends OneShotEffect { if (controller != null) { TargetCard target = new TargetCardInHand(0, 2, new FilterLandCard("up to two land cards to put onto the battlefield tapped")); controller.chooseTarget(outcome, controller.getHand(), target, source, game); - for (UUID cardId : target.getTargets()) { - Card card = game.getCard(cardId); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), true); - } - } - return true; + return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), + Zone.BATTLEFIELD, source, game, true, false, false, null); } return false; } diff --git a/Mage.Sets/src/mage/sets/bornofthegods/Peregrination.java b/Mage.Sets/src/mage/sets/bornofthegods/Peregrination.java index d5fdc7aca32..688d96d8083 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/Peregrination.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/Peregrination.java @@ -113,14 +113,13 @@ class PeregrinationEffect extends OneShotEffect { TargetCard target2 = new TargetCard(Zone.LIBRARY, filter); controller.choose(Outcome.Benefit, revealed, target2, game); Card card = revealed.get(target2.getFirstTarget(), game); - - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); revealed.remove(card); card = revealed.getCards(game).iterator().next(); - controller.moveCards(card, null, Zone.HAND, source, game); + controller.moveCards(card, Zone.HAND, source, game); } else if (target.getTargets().size() == 1) { Card card = revealed.getCards(game).iterator().next(); - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/Reweave.java b/Mage.Sets/src/mage/sets/championsofkamigawa/Reweave.java index 665831faad9..6a82d96309c 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/Reweave.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/Reweave.java @@ -28,6 +28,7 @@ package mage.sets.championsofkamigawa; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.SpliceOntoArcaneAbility; @@ -58,7 +59,6 @@ public class Reweave extends CardImpl { this.expansionSetCode = "CHK"; this.subtype.add("Arcane"); - // Target permanent's controller sacrifices it. If he or she does, that player reveals cards from the top of his or her library until he or she reveals a permanent card that shares a card type with the sacrificed permanent, puts that card onto the battlefield, then shuffles his or her library. this.getSpellAbility().addEffect(new ReweaveEffect()); Target target = new TargetPermanent(); @@ -97,9 +97,10 @@ class ReweaveEffect extends OneShotEffect { } @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget()); - if (permanent != null) { + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + MageObject sourceObject = source.getSourceObject(game); + if (permanent != null && sourceObject != null) { if (permanent.sacrifice(source.getSourceId(), game)) { Player permanentController = game.getPlayer(permanent.getControllerId()); if (permanentController != null) { @@ -122,11 +123,11 @@ class ReweaveEffect extends OneShotEffect { } } } while (!cardFound && library.size() > 0); - permanentController.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + permanentController.moveCards(card, Zone.BATTLEFIELD, source, game); } if (cards.size() > 0) { - permanentController.revealCards("Reweave", cards, game); + permanentController.revealCards(sourceObject.getIdName(), cards, game); if (cardFound && card != null) { cards.remove(card); } @@ -137,7 +138,7 @@ class ReweaveEffect extends OneShotEffect { return true; } return false; - } + } } return true; } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/ThroughTheBreach.java b/Mage.Sets/src/mage/sets/championsofkamigawa/ThroughTheBreach.java index bf4e4d5139b..f8510304312 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/ThroughTheBreach.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/ThroughTheBreach.java @@ -106,7 +106,7 @@ class ThroughTheBreachEffect extends OneShotEffect { if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); diff --git a/Mage.Sets/src/mage/sets/coldsnap/ArcumDagsson.java b/Mage.Sets/src/mage/sets/coldsnap/ArcumDagsson.java index 653bb2a81d0..7205351a470 100644 --- a/Mage.Sets/src/mage/sets/coldsnap/ArcumDagsson.java +++ b/Mage.Sets/src/mage/sets/coldsnap/ArcumDagsson.java @@ -56,8 +56,9 @@ import mage.target.common.TargetCardInLibrary; * @author emerald000 */ public class ArcumDagsson extends CardImpl { - + private static final FilterPermanent filter = new FilterArtifactPermanent("artifact creature"); + static { filter.add(new CardTypePredicate(CardType.CREATURE)); } @@ -88,26 +89,27 @@ public class ArcumDagsson extends CardImpl { } class ArcumDagssonEffect extends OneShotEffect { - + private static final FilterCard filter = new FilterArtifactCard("noncreature artifact card"); + static { filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); } - + ArcumDagssonEffect() { super(Outcome.Removal); this.staticText = "Target artifact creature's controller sacrifices it. That player may search his or her library for a noncreature artifact card, put it onto the battlefield, then shuffle his or her library"; } - + ArcumDagssonEffect(final ArcumDagssonEffect effect) { super(effect); } - + @Override public ArcumDagssonEffect copy() { return new ArcumDagssonEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Permanent artifactCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); @@ -120,7 +122,7 @@ class ArcumDagssonEffect extends OneShotEffect { if (player.searchLibrary(target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + player.moveCards(card, Zone.BATTLEFIELD, source, game); } } player.shuffleLibrary(game); diff --git a/Mage.Sets/src/mage/sets/commander/KaaliaOfTheVast.java b/Mage.Sets/src/mage/sets/commander/KaaliaOfTheVast.java index ae71daeb4db..bc05511f481 100644 --- a/Mage.Sets/src/mage/sets/commander/KaaliaOfTheVast.java +++ b/Mage.Sets/src/mage/sets/commander/KaaliaOfTheVast.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. @@ -148,20 +148,20 @@ class KaaliaOfTheVastEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, "Put an Angel, Demon, or Dragon creature card from your hand onto the battlefield tapped and attacking?", source, game)) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null || !controller.chooseUse(Outcome.PutCreatureInPlay, "Put an Angel, Demon, or Dragon creature card from your hand onto the battlefield tapped and attacking?", source, game)) { return false; } TargetCardInHand target = new TargetCardInHand(filter); - if (target.canChoose(player.getId(), game) && target.choose(getOutcome(), player.getId(), source.getSourceId(), game)) { + if (target.canChoose(controller.getId(), game) && target.choose(getOutcome(), controller.getId(), source.getSourceId(), game)) { if (target.getTargets().size() > 0) { UUID cardId = target.getFirstTarget(); Card card = game.getCard(cardId); if (card != null && game.getCombat() != null) { UUID defenderId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game); if (defenderId != null) { - player.getHand().remove(card); - player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), true); + controller.getHand().remove(card); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); Permanent creature = game.getPermanent(cardId); if (creature != null) { game.getCombat().addAttackerToCombat(card.getId(), defenderId, game); diff --git a/Mage.Sets/src/mage/sets/commander/KodamasReach.java b/Mage.Sets/src/mage/sets/commander/KodamasReach.java index 6b7883e9e8b..103a617285c 100644 --- a/Mage.Sets/src/mage/sets/commander/KodamasReach.java +++ b/Mage.Sets/src/mage/sets/commander/KodamasReach.java @@ -110,17 +110,17 @@ class KodamasReachEffect extends OneShotEffect { controller.choose(Outcome.Benefit, revealed, target2, game); Card card = revealed.get(target2.getFirstTarget(), game); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); revealed.remove(card); } card = revealed.getCards(game).iterator().next(); if (card != null) { - controller.moveCards(card, null, Zone.HAND, source, game); + controller.moveCards(card, Zone.HAND, source, game); } } else if (target.getTargets().size() == 1) { Card card = revealed.getCards(game).iterator().next(); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } } diff --git a/Mage.Sets/src/mage/sets/commander/TarielReckonerOfSouls.java b/Mage.Sets/src/mage/sets/commander/TarielReckonerOfSouls.java index 7cfe1e0b577..cb464431dbc 100644 --- a/Mage.Sets/src/mage/sets/commander/TarielReckonerOfSouls.java +++ b/Mage.Sets/src/mage/sets/commander/TarielReckonerOfSouls.java @@ -110,7 +110,7 @@ class TarielReckonerOfSoulsEffect extends OneShotEffect { } if (!creatureCards.isEmpty()) { Card card = creatureCards.getRandom(game); - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java b/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java index a4d4ceab35c..0f07b4a61ab 100644 --- a/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java +++ b/Mage.Sets/src/mage/sets/commander2014/DarettiScrapSavant.java @@ -164,7 +164,7 @@ class DarettiSacrificeEffect extends OneShotEffect { if (artifact != null && artifact.sacrifice(source.getSourceId(), game)) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { - return controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + return controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/commander2014/InfernalOffering.java b/Mage.Sets/src/mage/sets/commander2014/InfernalOffering.java index 18a0fef42cb..07816fa09d4 100644 --- a/Mage.Sets/src/mage/sets/commander2014/InfernalOffering.java +++ b/Mage.Sets/src/mage/sets/commander2014/InfernalOffering.java @@ -104,7 +104,7 @@ class InfernalOfferingSacrificeEffect extends OneShotEffect { if (opponent != null) { //Choose creatures to sacrifice Map toSacrifice = new HashMap<>(2); - for (UUID playerId : player.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) { if (playerId.equals(player.getId()) || playerId.equals(opponent.getId())) { target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true); if (target.choose(Outcome.Sacrifice, playerId, source.getControllerId(), game)) { @@ -154,16 +154,16 @@ class InfernalOfferingReturnEffect 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) { Target target = new TargetOpponent(true); target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game); Player opponent = game.getPlayer(target.getFirstTarget()); target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard")); - if (target.choose(Outcome.PutCreatureInPlay, player.getId(), source.getSourceId(), game)) { - Card card = player.getGraveyard().get(target.getFirstTarget(), game); + if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) { + Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } if (opponent != null) { @@ -171,7 +171,7 @@ class InfernalOfferingReturnEffect extends OneShotEffect { if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) { Card card = opponent.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { - opponent.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + opponent.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java b/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java index 890dd2eab04..eb480233616 100644 --- a/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java +++ b/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java @@ -186,14 +186,14 @@ class NahiriTheLithomancerSecondAbilityEffect extends OneShotEffect { controller.choose(outcome, target, source.getSourceId(), game); Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } else { Target target = new TargetCardInYourGraveyard(0, 1, filter); target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game); Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } return true; diff --git a/Mage.Sets/src/mage/sets/commander2014/ScrapMastery.java b/Mage.Sets/src/mage/sets/commander2014/ScrapMastery.java index 280abdd9587..f2512b5b703 100644 --- a/Mage.Sets/src/mage/sets/commander2014/ScrapMastery.java +++ b/Mage.Sets/src/mage/sets/commander2014/ScrapMastery.java @@ -28,14 +28,14 @@ package mage.sets.commander2014; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; 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; @@ -92,19 +92,16 @@ class ScrapMasteryEffect extends OneShotEffect { if (controller != null) { Map> exiledCards = new HashMap<>(); // exile artifacts from graveyard - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - Set cards = new HashSet<>(); - for (Card card : player.getGraveyard().getCards(new FilterArtifactCard(), game)) { - cards.add(card.getId()); - player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true); - } + Set cards = player.getGraveyard().getCards(new FilterArtifactCard(), game); + controller.moveCards(cards, Zone.EXILED, source, game); exiledCards.put(player.getId(), cards); } } // sacrifice all artifacts - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), playerId, game)) { @@ -113,15 +110,11 @@ class ScrapMasteryEffect extends OneShotEffect { } } // puts all cards he or she exiled this way onto the battlefield - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (UUID cardId : exiledCards.get(playerId)) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCards(card, Zone.EXILED, source, game); - } - } + Cards playersExiledCards = new CardsImpl(exiledCards.get(playerId)); + controller.moveCards(playersExiledCards, Zone.BATTLEFIELD, source, game); } } return true; diff --git a/Mage.Sets/src/mage/sets/commander2014/WakeTheDead.java b/Mage.Sets/src/mage/sets/commander2014/WakeTheDead.java index fc1c258ea11..eb7e9438ae7 100644 --- a/Mage.Sets/src/mage/sets/commander2014/WakeTheDead.java +++ b/Mage.Sets/src/mage/sets/commander2014/WakeTheDead.java @@ -37,8 +37,9 @@ import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.SacrificeTargetEffect; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; @@ -148,26 +149,22 @@ class WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEff @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - for (UUID targetId : getTargetPointer().getTargets(game, source)) { - Card card = game.getCard(targetId); - if (card != null) { - if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false)) { - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - permanent.changeControllerId(source.getControllerId(), game); - Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId()); - effect.setTargetPointer(new FixedTarget(permanent, game)); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); - } - - } + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source)); + controller.moveCards(cards, Zone.BATTLEFIELD, source, game); + for (UUID targetId : cards) { + Permanent creature = game.getPermanent(targetId); + if (creature != null) { + Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId()); + effect.setTargetPointer(new FixedTarget(creature, game)); + DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); + delayedAbility.setSourceId(source.getSourceId()); + delayedAbility.setControllerId(source.getControllerId()); + delayedAbility.setSourceObject(source.getSourceObject(game), game); + game.addDelayedTriggeredAbility(delayedAbility); } + } return true; } diff --git a/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java b/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java index 19994d3145c..bb5bb951b94 100644 --- a/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java +++ b/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java @@ -28,12 +28,15 @@ package mage.sets.commander2014; import java.util.HashMap; +import java.util.LinkedHashSet; import java.util.Map; +import java.util.Set; 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; @@ -86,9 +89,9 @@ class WaveOfVitriolEffect extends OneShotEffect { new CardTypePredicate(CardType.LAND), Predicates.not(new SupertypePredicate("Basic")) ) - )); } + public WaveOfVitriolEffect() { super(Outcome.Benefit); this.staticText = "Each player sacrifices all artifacts, enchantments, and nonbasic lands he or she controls. For each land sacrificed this way, its controller may search his or her library for a basic land card and put it onto the battlefield tapped. Then each player who searched his or her library this way shuffles it"; @@ -108,11 +111,11 @@ class WaveOfVitriolEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Map sacrificedLands = new HashMap<>(); - for(UUID playerId: controller.getInRange()) { + for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { int count = 0; - for(Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { if (permanent.sacrifice(source.getSourceId(), game) && permanent.getCardType().contains(CardType.LAND)) { count++; } @@ -123,25 +126,19 @@ class WaveOfVitriolEffect extends OneShotEffect { } } game.getState().handleSimultaneousEvent(game); - for(Map.Entry entry: sacrificedLands.entrySet()) { + Cards toBattlefield = new CardsImpl(); + Set playersToShuffle = new LinkedHashSet<>(); + for (Map.Entry entry : sacrificedLands.entrySet()) { if (entry.getKey().chooseUse(Outcome.PutLandInPlay, "Search your library for up to " + entry.getValue() + " basic lands?", source, game)) { Target target = new TargetCardInLibrary(0, entry.getValue(), new FilterBasicLandCard()); entry.getKey().chooseTarget(outcome, target, source, game); - for(UUID targetId: target.getTargets()) { - Card card = game.getCard(targetId); - if (card != null) { - entry.getKey().putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); - } - } - entry.getKey().shuffleLibrary(game); - } else { - entry.setValue(0); + toBattlefield.addAll(target.getTargets()); + playersToShuffle.add(entry.getKey()); } } - for(Map.Entry entry: sacrificedLands.entrySet()) { - if (entry.getValue() > 0) { - entry.getKey().shuffleLibrary(game); - } + controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); + for (Player player : playersToShuffle) { + player.shuffleLibrary(game); } return true; diff --git a/Mage.Sets/src/mage/sets/conflux/PathToExile.java b/Mage.Sets/src/mage/sets/conflux/PathToExile.java index bc78ddb72ef..63f6a0c889a 100644 --- a/Mage.Sets/src/mage/sets/conflux/PathToExile.java +++ b/Mage.Sets/src/mage/sets/conflux/PathToExile.java @@ -1,31 +1,30 @@ /* -* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are -* permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list -* of conditions and the following disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The views and conclusions contained in the software and documentation are those of the -* authors and should not be interpreted as representing official policies, either expressed -* or implied, of BetaSteward_at_googlemail.com. -*/ - + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ package mage.sets.conflux; import java.util.UUID; @@ -52,7 +51,7 @@ public class PathToExile extends CardImpl { public PathToExile(UUID ownerId) { super(ownerId, 15, "Path to Exile", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{W}"); - this.expansionSetCode = "CON"; + this.expansionSetCode = "CON"; // Exile target creature. Its controller may search his or her library for a basic land card, // put that card onto the battlefield tapped, then shuffle his or her library. @@ -93,13 +92,13 @@ class PathToExileEffect extends OneShotEffect { if (controller != null && permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); // if the zone change to exile gets replaced does not prevent the target controller to be able to search - controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); + controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for a basic land card?", source, game)) { TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard()); if (player.searchLibrary(target, game)) { Card card = player.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } } player.shuffleLibrary(game); diff --git a/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java b/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java index 09778edade8..e70912fe986 100644 --- a/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java +++ b/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java @@ -106,9 +106,9 @@ public class SkywardEyeProphets extends CardImpl { cards.add(card); controller.revealCards(sourceObject.getName(), cards, game); if (card.getCardType().contains(CardType.LAND)) { - return controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + return controller.moveCards(card, Zone.BATTLEFIELD, source, game); } else { - controller.moveCards(card, null, Zone.HAND, source, game); + controller.moveCards(card, Zone.HAND, source, game); } } return true; diff --git a/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java b/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java index 2a152f5c5d6..855d62758c7 100644 --- a/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java +++ b/Mage.Sets/src/mage/sets/conspiracy/GrenzoDungeonWarden.java @@ -106,7 +106,7 @@ class GrenzoDungeonWardenEffect extends OneShotEffect { if (card.getCardType().contains(CardType.CREATURE)) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null && card.getPower().getValue() <= sourcePermanent.getPower().getValue()) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/conspiracy/Victimize.java b/Mage.Sets/src/mage/sets/conspiracy/Victimize.java index 5f8a7bf3fc4..a49a512c2d3 100644 --- a/Mage.Sets/src/mage/sets/conspiracy/Victimize.java +++ b/Mage.Sets/src/mage/sets/conspiracy/Victimize.java @@ -31,8 +31,8 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -70,36 +70,32 @@ public class Victimize extends CardImpl { } class VictimizeEffect extends OneShotEffect { - + VictimizeEffect() { super(Outcome.PutCreatureInPlay); this.staticText = "Choose two target creature cards in your graveyard. Sacrifice a creature. If you do, return the chosen cards to the battlefield tapped"; } - + VictimizeEffect(final VictimizeEffect effect) { super(effect); } - + @Override public VictimizeEffect copy() { return new VictimizeEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature"))); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { - for (UUID targetId: getTargetPointer().getTargets(game, source)) { - Card card = game.getCard(targetId); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), true); - } - } + controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game), + Zone.BATTLEFIELD, source, game, true, false, false, null); } return true; } return false; - } + } } diff --git a/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java b/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java index 99831fe3acc..6b0ca36525a 100644 --- a/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java +++ b/Mage.Sets/src/mage/sets/darkascension/MikaeusTheUnhallowed.java @@ -28,10 +28,6 @@ package mage.sets.darkascension; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; @@ -41,6 +37,10 @@ import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.keyword.IntimidateAbility; import mage.abilities.keyword.UndyingAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -74,6 +74,7 @@ public class MikaeusTheUnhallowed extends CardImpl { this.addAbility(IntimidateAbility.getInstance()); // Whenever a Human deals damage to you, destroy it. this.addAbility(new MikaeusTheUnhallowedAbility()); + // Other non-Human creatures you control get +1/+1 and have undying. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(new UndyingAbility(), Duration.WhileOnBattlefield, filter, true))); @@ -109,7 +110,6 @@ class MikaeusTheUnhallowedAbility extends TriggeredAbilityImpl { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } - @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getTargetId().equals(this.controllerId)) { diff --git a/Mage.Sets/src/mage/sets/darksteel/Reshape.java b/Mage.Sets/src/mage/sets/darksteel/Reshape.java index 28303ac7d8d..c1472d3c268 100644 --- a/Mage.Sets/src/mage/sets/darksteel/Reshape.java +++ b/Mage.Sets/src/mage/sets/darksteel/Reshape.java @@ -28,15 +28,14 @@ package mage.sets.darksteel; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.Filter; import mage.filter.FilterCard; @@ -64,7 +63,6 @@ public class Reshape extends CardImpl { super(ownerId, 31, "Reshape", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{U}{U}"); this.expansionSetCode = "DST"; - // As an additional cost to cast Reshape, sacrifice an artifact. this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, false))); // Search your library for an artifact card with converted mana cost X or less and put it onto the battlefield. Then shuffle your library. @@ -94,8 +92,8 @@ class ReshapeSearchEffect 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) { return false; } //Set the mana cost one higher to 'emulate' a less than or equal to comparison. @@ -104,17 +102,17 @@ class ReshapeSearchEffect extends OneShotEffect { filter.add(new CardTypePredicate(CardType.ARTIFACT)); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, xValue)); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { + if (controller.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { - Card card = player.getLibrary().getCard(target.getFirstTarget(), game); + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return false; } diff --git a/Mage.Sets/src/mage/sets/dissension/CryptChampion.java b/Mage.Sets/src/mage/sets/dissension/CryptChampion.java index 894a5fdff35..7d29bfdf552 100644 --- a/Mage.Sets/src/mage/sets/dissension/CryptChampion.java +++ b/Mage.Sets/src/mage/sets/dissension/CryptChampion.java @@ -69,10 +69,10 @@ public class CryptChampion extends CardImpl { // Double strike this.addAbility(DoubleStrikeAbility.getInstance()); - + // When Crypt Champion enters the battlefield, each player puts a creature card with converted mana cost 3 or less from his or her graveyard onto the battlefield. this.addAbility(new EntersBattlefieldTriggeredAbility(new CryptChampionEffect())); - + // When Crypt Champion enters the battlefield, sacrifice it unless {R} was spent to cast it. this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeSourceUnlessConditionEffect(new ManaWasSpentCondition(ColoredManaSymbol.R)), false), new ManaSpentToCastWatcher()); } @@ -88,26 +88,26 @@ public class CryptChampion extends CardImpl { } class CryptChampionEffect extends OneShotEffect { - + CryptChampionEffect() { super(Outcome.PutCreatureInPlay); this.staticText = "each player puts a creature card with converted mana cost 3 or less from his or her graveyard onto the battlefield"; } - + CryptChampionEffect(final CryptChampionEffect effect) { super(effect); } - + @Override public CryptChampionEffect copy() { return new CryptChampionEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { FilterCard filter = new FilterCreatureCard("creature card with converted mana cost 3 or less from your graveyard"); @@ -117,7 +117,7 @@ class CryptChampionEffect extends OneShotEffect { if (target.canChoose(playerId, game) && player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + player.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java b/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java index 24af9bc9355..d675c36e768 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java @@ -25,17 +25,9 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.dragonsmaze; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.SubLayer; -import mage.constants.Zone; import mage.MageInt; import mage.ObjectColor; import mage.abilities.Ability; @@ -45,6 +37,13 @@ import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.LifelinkAbility; import mage.abilities.keyword.ProtectionAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.SubLayer; +import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.ColorPredicate; @@ -52,27 +51,21 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -/** - * - * @author LevelX2 - */ - - public class BloodBaronOfVizkopa extends CardImpl { private static final FilterCard filter = new FilterCard("white and from black"); + static { filter.add(Predicates.or( new ColorPredicate(ObjectColor.WHITE), new ColorPredicate(ObjectColor.BLACK))); } - public BloodBaronOfVizkopa (UUID ownerId) { + public BloodBaronOfVizkopa(UUID ownerId) { super(ownerId, 57, "Blood Baron of Vizkopa", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{3}{W}{B}"); this.expansionSetCode = "DGM"; this.subtype.add("Vampire"); - this.power = new MageInt(4); this.toughness = new MageInt(4); @@ -85,7 +78,7 @@ public class BloodBaronOfVizkopa extends CardImpl { } - public BloodBaronOfVizkopa (final BloodBaronOfVizkopa card) { + public BloodBaronOfVizkopa(final BloodBaronOfVizkopa card) { super(card); } @@ -97,7 +90,7 @@ public class BloodBaronOfVizkopa extends CardImpl { } class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl { - + public BloodBaronOfVizkopaEffect() { super(Duration.WhileOnBattlefield, Outcome.BoostCreature); staticText = "As long as you have 30 or more life and an opponent has 10 or less life, {this} gets +6/+6 and has flying"; @@ -117,21 +110,21 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl { if (conditionState(source, game)) { Permanent creature = game.getPermanent(source.getSourceId()); if (creature != null) { - switch (layer) { - case PTChangingEffects_7: - if (sublayer == SubLayer.ModifyPT_7c) { - creature.addPower(6); - creature.addToughness(6); - } - break; - case AbilityAddingRemovingEffects_6: - if (sublayer == SubLayer.NA) { - creature.addAbility(FlyingAbility.getInstance(), source.getSourceId(), game); - } - break; - default: - } - return true; + switch (layer) { + case PTChangingEffects_7: + if (sublayer == SubLayer.ModifyPT_7c) { + creature.addPower(6); + creature.addToughness(6); + } + break; + case AbilityAddingRemovingEffects_6: + if (sublayer == SubLayer.NA) { + creature.addAbility(FlyingAbility.getInstance(), source.getSourceId(), game); + } + break; + default: + } + return true; } } return false; @@ -140,10 +133,12 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl { protected boolean conditionState(Ability source, Game game) { Player player = game.getPlayer(source.getControllerId()); if (player != null && player.getLife() >= 30) { - for (UUID opponentId :player.getInRange()) { - Player opponent = game.getPlayer(opponentId); - if (opponent != null && opponent.getLife() < 11) { - return true; + for (UUID opponentId : player.getInRange()) { + if (player.hasOpponent(opponentId, game)) { + Player opponent = game.getPlayer(opponentId); + if (opponent != null && opponent.getLife() < 11) { + return true; + } } } } @@ -159,6 +154,6 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl { public boolean hasLayer(Layer layer) { return (layer.equals(Layer.AbilityAddingRemovingEffects_6) || layer.equals(layer.PTChangingEffects_7)); - } + } } diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java index 098a319ff68..629a1e35e6a 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java @@ -101,9 +101,9 @@ class DeathmistRaptorEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObjectIfItStillExists(game); if (controller != null && (sourceObject instanceof Card)) { - controller.putOntoBattlefieldWithInfo((Card) sourceObject, game, Zone.GRAVEYARD, source.getSourceId(), false, - controller.chooseUse(Outcome.Detriment, "Return " + sourceObject.getLogName() + " face down to battlefield (otherwise face up)?", source, game)); - return true; + return controller.moveCards((Card) sourceObject, Zone.BATTLEFIELD, source, game, false, + controller.chooseUse(Outcome.Detriment, "Return " + sourceObject.getLogName() + " face down to battlefield (otherwise face up)?", source, game), + false, null); } return false; } diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/SwiftWarkite.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/SwiftWarkite.java index 7cf4b87280b..bfd5b48ff0d 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/SwiftWarkite.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/SwiftWarkite.java @@ -122,7 +122,7 @@ class SwiftWarkiteEffect extends OneShotEffect { controller.choose(outcome, target, source.getSourceId(), game); Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent creature = game.getPermanent(card.getId()); if (creature != null) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); @@ -143,7 +143,7 @@ class SwiftWarkiteEffect extends OneShotEffect { target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game); Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); Permanent creature = game.getPermanent(card.getId()); if (creature != null) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); diff --git a/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java b/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java index 55756cd3dbf..c5abcd76b27 100644 --- a/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java +++ b/Mage.Sets/src/mage/sets/elvesvsgoblins/SkirkDrillSergeant.java @@ -37,7 +37,6 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DoIfCostPaid; import mage.cards.Card; import mage.cards.CardImpl; -import mage.cards.Cards; import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; @@ -108,23 +107,20 @@ class SkirkDrillSergeantEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); - if (player == null || sourceObject == null) { + if (controller == null || sourceObject == null) { return false; } - if (player.getLibrary().size() > 0) { - Card card = player.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); - cards.add(card); - player.revealCards(sourceObject.getName(), cards, game); - + if (controller.getLibrary().size() > 0) { + Card card = controller.getLibrary().getFromTop(game); + controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game); if (card != null) { if (filter.match(card, game)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } else { - player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + controller.moveCards(card, Zone.GRAVEYARD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java b/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java index e08f682393c..e613109d666 100644 --- a/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java +++ b/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java @@ -65,7 +65,6 @@ public class OathOfDruids extends CardImpl { super(ownerId, 115, "Oath of Druids", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); this.expansionSetCode = "EXO"; - // At the beginning of each player's upkeep, that player chooses target player who controls more creatures than he or she does and is his or her opponent. The first player may reveal cards from the top of his or her library until he or she reveals a creature card. If he or she does, that player puts that card onto the battlefield and all other cards revealed this way into his or her graveyard. Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfDruidsEffect(), TargetController.ANY, true); ability.addTarget(new TargetPlayer(1, 1, false, filter)); @@ -136,32 +135,32 @@ class OathOfDruidsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { MageObject sourceObject = game.getObject(source.getSourceId()); - Player player = game.getPlayer(source.getControllerId()); - if (player == null || sourceObject == null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null || sourceObject == null) { return false; } Cards revealed = new CardsImpl(); Card creatureCard = null; Cards nonCreatureCards = new CardsImpl(); //The first player may reveal cards from the top of his or her library - while (creatureCard == null && player.getLibrary().size() > 0) { - Card card = player.getLibrary().removeFromTop(game); + while (creatureCard == null && controller.getLibrary().size() > 0) { + Card card = controller.getLibrary().removeFromTop(game); revealed.add(card); - // until he or she reveals a creature card. + // until he or she reveals a creature card. if (card.getCardType().contains(CardType.CREATURE)) { creatureCard = card; } else { nonCreatureCards.add(card); } } - player.revealCards(sourceObject.getName(), revealed, game); + controller.revealCards(sourceObject.getIdName(), revealed, game); //If he or she does, that player puts that card onto the battlefield if (creatureCard != null) { - player.putOntoBattlefieldWithInfo(creatureCard, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game); } // and all other cards revealed this way into his or her graveyard - player.moveCards(nonCreatureCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + controller.moveCards(nonCreatureCards, Zone.GRAVEYARD, source, game); return true; } diff --git a/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java b/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java index f11e6b7823e..ad31783661b 100644 --- a/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java +++ b/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java @@ -65,7 +65,7 @@ public class OathOfLieges extends CardImpl { this.expansionSetCode = "EXO"; // At the beginning of each player's upkeep, that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library. - Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false, Outcome.PutLandInPlay); + Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false, true, Outcome.PutLandInPlay, true); effect.setText("that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library"); Ability ability = new BeginningOfUpkeepTriggeredAbility(effect, TargetController.ANY, true); ability.addTarget(new TargetPlayer(1, 1, false, filter)); diff --git a/Mage.Sets/src/mage/sets/fatereforged/GhastlyConscription.java b/Mage.Sets/src/mage/sets/fatereforged/GhastlyConscription.java index 333415da47a..746d4f6fe9f 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/GhastlyConscription.java +++ b/Mage.Sets/src/mage/sets/fatereforged/GhastlyConscription.java @@ -29,6 +29,8 @@ package mage.sets.fatereforged; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; import java.util.UUID; import mage.MageObjectReference; import mage.abilities.Ability; @@ -96,15 +98,18 @@ class GhastlyConscriptionEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (controller != null && targetPlayer != null) { ArrayList cardsToManifest = new ArrayList<>(); - for(Card card: targetPlayer.getGraveyard().getCards(new FilterCreatureCard(), game)) { + for (Card card : targetPlayer.getGraveyard().getCards(new FilterCreatureCard(), game)) { cardsToManifest.add(card); controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true); } + if (cardsToManifest.isEmpty()) { + return true; + } Collections.shuffle(cardsToManifest); game.informPlayers(controller.getLogName() + " shuffles the face-down pile"); Ability newSource = source.copy(); newSource.setWorksFaceDown(true); - for (Card card: cardsToManifest) { + for (Card card : cardsToManifest) { ManaCosts manaCosts = null; if (card.getCardType().contains(CardType.CREATURE)) { manaCosts = card.getSpellAbility().getManaCosts(); @@ -112,13 +117,12 @@ class GhastlyConscriptionEffect extends OneShotEffect { manaCosts = new ManaCostsImpl("{0}"); } } - MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game); + MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) { - game.informPlayers(new StringBuilder(controller.getLogName()) - .append(" puts facedown card from exile onto the battlefield").toString()); - } } + Set toBattlefield = new LinkedHashSet(); + toBattlefield.addAll(cardsToManifest); + controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/fatereforged/JeskaiInfiltrator.java b/Mage.Sets/src/mage/sets/fatereforged/JeskaiInfiltrator.java index 2b64b4db950..30fc48f26c6 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/JeskaiInfiltrator.java +++ b/Mage.Sets/src/mage/sets/fatereforged/JeskaiInfiltrator.java @@ -29,7 +29,9 @@ package mage.sets.fatereforged; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.MageObjectReference; @@ -74,7 +76,7 @@ public class JeskaiInfiltrator extends CardImpl { Effect effect = new ConditionalRestrictionEffect(new CantBeBlockedSourceEffect(), new OneControlledCreatureCondition()); effect.setText("{this} can't be blocked as long as you control no other creatures"); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); - + // Whenever Jeskai Infiltrator deals combat damage to a player, exile it and the top card of your library in a face-down pile, shuffle that pile, then manifest those cards. this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new JeskaiInfiltratorEffect(), false)); } @@ -90,35 +92,35 @@ public class JeskaiInfiltrator extends CardImpl { } class JeskaiInfiltratorEffect extends OneShotEffect { - + JeskaiInfiltratorEffect() { super(Outcome.PutCreatureInPlay); this.staticText = "exile it and the top card of your library in a face-down pile, shuffle that pile, then manifest those cards"; } - + JeskaiInfiltratorEffect(final JeskaiInfiltratorEffect effect) { super(effect); } - + @Override public JeskaiInfiltratorEffect copy() { return new JeskaiInfiltratorEffect(this); } - + @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) { List cardsToManifest = new ArrayList<>(2); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId()); - if (sourcePermanent != null && sourceCard != null) { - player.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true); + if (sourcePermanent != null && sourceCard != null) { + controller.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true); cardsToManifest.add(sourceCard); } - if (sourcePermanent!= null && player.getLibrary().size() > 0) { - Card cardFromLibrary = player.getLibrary().removeFromTop(game); - player.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); + if (sourcePermanent != null && controller.getLibrary().size() > 0) { + Card cardFromLibrary = controller.getLibrary().removeFromTop(game); + controller.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); cardsToManifest.add(cardFromLibrary); } Collections.shuffle(cardsToManifest); @@ -133,13 +135,12 @@ class JeskaiInfiltratorEffect extends OneShotEffect { manaCosts = new ManaCostsImpl("{0}"); } } - MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game); - game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); - if (player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) { - game.informPlayers(new StringBuilder(player.getLogName()) - .append(" puts facedown card from exile onto the battlefield").toString()); - } + MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game); + game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); } + Set toBattlefield = new LinkedHashSet(); + toBattlefield.addAll(cardsToManifest); + controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java b/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java index 100549a277a..564996f1e27 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java +++ b/Mage.Sets/src/mage/sets/fatereforged/RallyTheAncestors.java @@ -46,6 +46,7 @@ import mage.filter.Filter.ComparisonType; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; @@ -99,11 +100,13 @@ class RallyTheAncestorsEffect extends OneShotEffect { FilterCreatureCard filter = new FilterCreatureCard(); filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, xValue + 1)); Set cards = player.getGraveyard().getCards(filter, game); + player.moveCards(cards, Zone.BATTLEFIELD, source, game); for (Card card : cards) { if (card != null) { - if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) { + Permanent permanent = game.getPermanent(card.getId()); + if (permanent != null) { Effect exileEffect = new ExileTargetEffect("Exile those creatures at the beginning of your next upkeep"); - exileEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + exileEffect.setTargetPointer(new FixedTarget(permanent, game)); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(exileEffect); delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setControllerId(source.getControllerId()); diff --git a/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java b/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java index d9590de8ffa..662d434e6df 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java +++ b/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java @@ -97,6 +97,7 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect { this.tapped = tapped; setText(); } + public ReturnSourceFromExileToBattlefieldEffect(boolean tapped, boolean ownerControl) { super(Outcome.PutCreatureInPlay); this.tapped = tapped; @@ -135,7 +136,7 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect { return false; } - return player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), tapped); + return player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } private void setText() { @@ -144,7 +145,7 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect { sb.append(" tapped"); } if (ownerControl) { - sb.append(" under its owner's control"); + sb.append(" under its owner's control"); } staticText = sb.toString(); } diff --git a/Mage.Sets/src/mage/sets/fatereforged/UginTheSpiritDragon.java b/Mage.Sets/src/mage/sets/fatereforged/UginTheSpiritDragon.java index 2ebf0e1caa3..a7cbbf6bc0b 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/UginTheSpiritDragon.java +++ b/Mage.Sets/src/mage/sets/fatereforged/UginTheSpiritDragon.java @@ -35,8 +35,8 @@ import mage.abilities.costs.Cost; import mage.abilities.costs.common.PayVariableLoyaltyCost; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -154,12 +154,7 @@ class UginTheSpiritDragonEffect3 extends OneShotEffect { controller.drawCards(7, game); TargetCardInHand target = new TargetCardInHand(0, 7, new FilterPermanentCard("permanent cards")); if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { - for (UUID targetId : target.getTargets()) { - Card card = game.getCard(targetId); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getControllerId()); - } - } + controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/fifthdawn/EndlessWhispers.java b/Mage.Sets/src/mage/sets/fifthdawn/EndlessWhispers.java index df557686aee..2e772173bb2 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/EndlessWhispers.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/EndlessWhispers.java @@ -59,18 +59,17 @@ public class EndlessWhispers extends CardImpl { super(ownerId, 49, "Endless Whispers", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}"); this.expansionSetCode = "5DN"; - // Each creature has "When this creature dies, choose target opponent. That player puts this card from its owner's graveyard onto the battlefield under his or her control at the beginning of the next end step." DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnSourceToBattlefieldEffect()); Effect effect = new CreateDelayedTriggeredAbilityEffect(delayedAbility, true); effect.setText("choose target opponent. That player puts this card from its owner's graveyard onto the battlefield under his or her control at the beginning of the next end step"); Ability gainAbility = new DiesTriggeredAbility(effect); gainAbility.addTarget(new TargetOpponent()); - + effect = new GainAbilityAllEffect(gainAbility, Duration.WhileOnBattlefield, new FilterCreaturePermanent("Each creature")); effect.setText("Each creature has \"When this creature dies, choose target opponent. That player puts this card from its owner's graveyard onto the battlefield under his or her control at the beginning of the next end step.\""); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); - + } public EndlessWhispers(final EndlessWhispers card) { @@ -85,18 +84,17 @@ public class EndlessWhispers extends CardImpl { class ReturnSourceToBattlefieldEffect extends OneShotEffect { - public ReturnSourceToBattlefieldEffect() { this(false); } public ReturnSourceToBattlefieldEffect(boolean tapped) { super(Outcome.PutCreatureInPlay); - setText(); + staticText = "That player puts this card from its owner's graveyard onto the battlefield under his or her control"; } + public ReturnSourceToBattlefieldEffect(boolean tapped, boolean ownerControl) { super(Outcome.PutCreatureInPlay); - setText(); } public ReturnSourceToBattlefieldEffect(final ReturnSourceToBattlefieldEffect effect) { @@ -112,24 +110,19 @@ class ReturnSourceToBattlefieldEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { if (!game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) { return false; - } + } Card card = game.getCard(source.getSourceId()); if (card == null) { return false; } - + Player player = game.getPlayer(source.getFirstTarget()); - - if (player == null) { + + if (player == null) { return false; - } - - return player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false); + } + + return player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } - private void setText() { - StringBuilder sb = new StringBuilder("That player puts this card from its owner's graveyard onto the battlefield under his or her control"); - - } - -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/fifthdawn/MyrServitor.java b/Mage.Sets/src/mage/sets/fifthdawn/MyrServitor.java index f284a356e4c..33c27d2d941 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/MyrServitor.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/MyrServitor.java @@ -34,7 +34,6 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.condition.common.SourceOnBattlefieldCondition; import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; @@ -66,7 +65,7 @@ public class MyrServitor extends CardImpl { SourceOnBattlefieldCondition.getInstance(), "At the beginning of your upkeep, if {this} is on the battlefield, each player returns all cards named Myr Servitor from his or her graveyard to the battlefield" )); - + } public MyrServitor(final MyrServitor card) { @@ -80,39 +79,38 @@ public class MyrServitor extends CardImpl { } class MyrServitorReturnEffect extends OneShotEffect { - + private static final FilterCard filter = new FilterCard("cards named Myr Servitor"); - + static { filter.add(new NamePredicate("Myr Servitor")); } - + public MyrServitorReturnEffect() { super(Outcome.PutCardInPlay); this.staticText = "if {this} is on the battlefield, each player returns all cards named Myr Servitor from his or her graveyard to the battlefield"; } - + public MyrServitorReturnEffect(final MyrServitorReturnEffect effect) { super(effect); } - + @Override public MyrServitorReturnEffect copy() { return new MyrServitorReturnEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card: player.getGraveyard().getCards(filter, game)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); - } + controller.moveCards(player.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game); } } + return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/fourthedition/TheRack.java b/Mage.Sets/src/mage/sets/fourthedition/TheRack.java index a99f13634fa..bbbed87b4d3 100644 --- a/Mage.Sets/src/mage/sets/fourthedition/TheRack.java +++ b/Mage.Sets/src/mage/sets/fourthedition/TheRack.java @@ -96,7 +96,7 @@ class TheRackTriggeredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return new StringBuilder("At the beginning of the chosen player's upkeep, ").append(super.getRule()).toString(); + return "At the beginning of the chosen player's upkeep, " + super.getRule(); } } @@ -119,7 +119,7 @@ class TheRackEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID playerId = (UUID) game.getState().getValue(new StringBuilder(source.getSourceId().toString()).append("_player").toString()); + UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + "_player"); Player chosenPlayer = game.getPlayer(playerId); if (chosenPlayer != null) { int damage = 3 - chosenPlayer.getHand().size(); diff --git a/Mage.Sets/src/mage/sets/futuresight/SwordOfTheMeek.java b/Mage.Sets/src/mage/sets/futuresight/SwordOfTheMeek.java index eaaf39e852f..737dfd0139d 100644 --- a/Mage.Sets/src/mage/sets/futuresight/SwordOfTheMeek.java +++ b/Mage.Sets/src/mage/sets/futuresight/SwordOfTheMeek.java @@ -70,7 +70,7 @@ public class SwordOfTheMeek extends CardImpl { this.subtype.add("Equipment"); // Equipped creature gets +1/+2. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1,2,Duration.WhileOnBattlefield))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 2, Duration.WhileOnBattlefield))); // Equip {2} this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2))); // Whenever a 1/1 creature enters the battlefield under your control, you may return Sword of the Meek from your graveyard to the battlefield, then attach it to that creature. @@ -108,7 +108,7 @@ class SwordOfTheMeekEffect extends OneShotEffect { Card equipment = game.getCard(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (equipment != null && controller != null && game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) { - controller.putOntoBattlefieldWithInfo(equipment, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(equipment, Zone.BATTLEFIELD, source, game); Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null) { return permanent.addAttachment(equipment.getId(), game); diff --git a/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java b/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java index 4435598c20d..4ebfb6bdee6 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java +++ b/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java @@ -180,7 +180,7 @@ class ObzedatGhostCouncilReturnEffect extends OneShotEffect { // return it only from the own exile zone if (currentZone != null && currentZone.size() > 0) { Player owner = game.getPlayer(card.getOwnerId()); - if (owner != null && owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) { + if (owner != null && owner.moveCards(card, Zone.BATTLEFIELD, source, game)) { return true; } } diff --git a/Mage.Sets/src/mage/sets/iceage/DanceOfTheDead.java b/Mage.Sets/src/mage/sets/iceage/DanceOfTheDead.java index 5f308525d87..126046c1d68 100644 --- a/Mage.Sets/src/mage/sets/iceage/DanceOfTheDead.java +++ b/Mage.Sets/src/mage/sets/iceage/DanceOfTheDead.java @@ -78,13 +78,12 @@ public class DanceOfTheDead extends CardImpl { this.expansionSetCode = "ICE"; this.subtype.add("Aura"); - // Enchant creature card in a graveyard TargetCardInGraveyard auraTarget = new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")); this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addEffect(new DanceOfTheDeadAttachEffect(Outcome.PutCreatureInPlay)); Ability enchantAbility = new EnchantAbility(auraTarget.getTargetName()); - this.addAbility(enchantAbility); + this.addAbility(enchantAbility); // When Dance of the Dead enters the battlefield, if it's on the battlefield, it loses "enchant creature card in a graveyard" and gains "enchant creature put onto the battlefield with Dance of the Dead." Put enchanted creature card to the battlefield tapped under your control and attach Dance of the Dead to it. When Dance of the Dead leaves the battlefield, that creature's controller sacrifices it. Ability ability = new ConditionalTriggeredAbility( new EntersBattlefieldTriggeredAbility(new DanceOfTheDeadReAttachEffect(), false), @@ -92,18 +91,18 @@ public class DanceOfTheDead extends CardImpl { "When {this} enters the battlefield, if it's on the battlefield, it loses \"enchant creature card in a graveyard\" and gains \"enchant creature put onto the battlefield with {this}.\" Return enchanted creature card to the battlefield under your control and attach {this} to it."); ability.addEffect(new DanceOfTheDeadChangeAbilityEffect()); this.addAbility(ability); - this.addAbility(new LeavesBattlefieldTriggeredAbility(new DanceOfTheDeadLeavesBattlefieldTriggeredEffect(), false)); - + this.addAbility(new LeavesBattlefieldTriggeredAbility(new DanceOfTheDeadLeavesBattlefieldTriggeredEffect(), false)); + // Enchanted creature gets +1/+1 and doesn't untap during its controller's untap step. ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, 1, Duration.WhileOnBattlefield)); Effect effect = new DontUntapInControllersUntapStepEnchantedEffect(); effect.setText("and doesn't untap during its controller's untap step"); ability.addEffect(effect); this.addAbility(ability); - + // At the beginning of the upkeep of enchanted creature's controller, that player may pay {1}{B}. If he or she does, untap that creature. this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DanceOfTheDeadDoIfCostPaidEffect(), TargetController.CONTROLLER_ATTACHED_TO, false)); - + } public DanceOfTheDead(final DanceOfTheDead card) { @@ -117,36 +116,36 @@ public class DanceOfTheDead extends CardImpl { } class DanceOfTheDeadReAttachEffect extends OneShotEffect { - + public DanceOfTheDeadReAttachEffect() { super(Outcome.Benefit); this.staticText = "Return enchanted creature card to the battlefield under your control and attach {this} to it"; } - + public DanceOfTheDeadReAttachEffect(final DanceOfTheDeadReAttachEffect effect) { super(effect); } - + @Override public DanceOfTheDeadReAttachEffect copy() { return new DanceOfTheDeadReAttachEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent enchantment = game.getPermanent(source.getSourceId()); - + if (controller != null && enchantment != null) { Card cardInGraveyard = game.getCard(enchantment.getAttachedTo()); if (cardInGraveyard == null) { return true; } - + // put card into play - controller.putOntoBattlefieldWithInfo(cardInGraveyard, game, Zone.GRAVEYARD, source.getSourceId(), true); + controller.moveCards(cardInGraveyard, Zone.BATTLEFIELD, source, game, true, false, false, null); Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId()); - + FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with Dance of the Dead"); filter.add(new PermanentIdPredicate(cardInGraveyard.getId())); Target target = new TargetCreaturePermanent(filter); @@ -159,27 +158,27 @@ class DanceOfTheDeadReAttachEffect extends OneShotEffect { } return true; } - + return false; } } - + class DanceOfTheDeadLeavesBattlefieldTriggeredEffect extends OneShotEffect { - + public DanceOfTheDeadLeavesBattlefieldTriggeredEffect() { super(Outcome.Benefit); this.staticText = "enchanted creature's controller sacrifices it"; } - + public DanceOfTheDeadLeavesBattlefieldTriggeredEffect(final DanceOfTheDeadLeavesBattlefieldTriggeredEffect effect) { super(effect); } - + @Override public DanceOfTheDeadLeavesBattlefieldTriggeredEffect copy() { return new DanceOfTheDeadLeavesBattlefieldTriggeredEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -236,17 +235,16 @@ class DanceOfTheDeadAttachEffect extends OneShotEffect { class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements SourceEffect { private final static Ability newAbility = new EnchantAbility("creature put onto the battlefield with Dance of the Dead"); - + static { newAbility.setRuleAtTheTop(true); } - + public DanceOfTheDeadChangeAbilityEffect() { super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); staticText = "it loses \"enchant creature card in a graveyard\" and gains \"enchant creature put onto the battlefield with Dance of the Dead\""; } - public DanceOfTheDeadChangeAbilityEffect(final DanceOfTheDeadChangeAbilityEffect effect) { super(effect); } @@ -255,7 +253,7 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements public DanceOfTheDeadChangeAbilityEffect copy() { return new DanceOfTheDeadChangeAbilityEffect(this); } - + @Override public void init(Ability source, Game game) { super.init(source, game); @@ -267,7 +265,7 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements Permanent permanent = affectedObjectList.get(0).getPermanent(game);; if (permanent != null) { Ability abilityToRemove = null; - for (Ability ability: permanent.getAbilities()) { + for (Ability ability : permanent.getAbilities()) { if (ability instanceof EnchantAbility) { abilityToRemove = ability; } @@ -277,7 +275,7 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements } permanent.addAbility(newAbility, source.getSourceId(), game); return true; - } + } return false; } } @@ -309,4 +307,4 @@ class DanceOfTheDeadDoIfCostPaidEffect extends DoIfCostPaid { return new StringBuilder("that player may ").append(getCostText()) .append(". If he or she does, ").append(executingEffects.getText(mode)).toString(); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/innistrad/CaravanVigil.java b/Mage.Sets/src/mage/sets/innistrad/CaravanVigil.java index 4dc4e3bd417..7bbd95e03b1 100644 --- a/Mage.Sets/src/mage/sets/innistrad/CaravanVigil.java +++ b/Mage.Sets/src/mage/sets/innistrad/CaravanVigil.java @@ -96,13 +96,12 @@ class CaravanVigilEffect extends OneShotEffect { if (controller.searchLibrary(target, game)) { Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); + Cards cards = new CardsImpl(card); if (MorbidCondition.getInstance().apply(game, source) && controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to put the card onto the battlefield instead?", source, game)) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } else { - controller.moveCards(card, null, Zone.HAND, source, game); + controller.moveCards(card, Zone.HAND, source, game); } controller.revealCards(sourceObject.getIdName(), cards, game); } diff --git a/Mage.Sets/src/mage/sets/innistrad/GhostQuarter.java b/Mage.Sets/src/mage/sets/innistrad/GhostQuarter.java index aeba8786b36..5d05bc28c57 100644 --- a/Mage.Sets/src/mage/sets/innistrad/GhostQuarter.java +++ b/Mage.Sets/src/mage/sets/innistrad/GhostQuarter.java @@ -98,16 +98,16 @@ class GhostQuarterEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = (Permanent) game.getPermanentOrLKIBattlefield(source.getFirstTarget()); // if indestructible effect should work also if (permanent != null) { - Player player = game.getPlayer(permanent.getControllerId()); - if (player.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { + Player controller = game.getPlayer(permanent.getControllerId()); + if (controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard()); - if (player.searchLibrary(target, game)) { - Card card = player.getLibrary().getCard(target.getFirstTarget(), game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + if (card != null) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); } return true; } diff --git a/Mage.Sets/src/mage/sets/invasion/PhyrexianDelver.java b/Mage.Sets/src/mage/sets/invasion/PhyrexianDelver.java index eb4c4a5174d..1178f5af64c 100644 --- a/Mage.Sets/src/mage/sets/invasion/PhyrexianDelver.java +++ b/Mage.Sets/src/mage/sets/invasion/PhyrexianDelver.java @@ -98,7 +98,7 @@ class PhyrexianDelverEffect extends OneShotEffect { if (creatureCard != null && controller != null) { boolean result = false; if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) { - result = controller.putOntoBattlefieldWithInfo(creatureCard, game, Zone.GRAVEYARD, source.getSourceId()); + result = controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game);; } controller.loseLife(creatureCard.getManaCost().convertedManaCost(), game); return result; diff --git a/Mage.Sets/src/mage/sets/invasion/ThicketElemental.java b/Mage.Sets/src/mage/sets/invasion/ThicketElemental.java index 142a7b4fc14..e669ddd5ade 100644 --- a/Mage.Sets/src/mage/sets/invasion/ThicketElemental.java +++ b/Mage.Sets/src/mage/sets/invasion/ThicketElemental.java @@ -67,7 +67,7 @@ public class ThicketElemental extends CardImpl { // When Thicket Elemental enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library. TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ThicketElementalEffect()); this.addAbility(new ConditionalTriggeredAbility(ability, KickedCondition.getInstance(), - "When {this} enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library.")); + "When {this} enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library.")); } public ThicketElemental(final ThicketElemental card) { @@ -82,8 +82,6 @@ public class ThicketElemental extends CardImpl { class ThicketElementalEffect extends OneShotEffect { - - public ThicketElementalEffect() { super(Outcome.Benefit); staticText = "if {this} was kicked, reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and shuffle all other cards revealed this way into your library"; @@ -102,15 +100,13 @@ class ThicketElementalEffect extends OneShotEffect { while (controller.getLibrary().size() > 0) { Card card = controller.getLibrary().removeFromTop(game); if (card.getCardType().contains(CardType.CREATURE)) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); break; } revealedCards.add(card); } - controller.revealCards("ThicketElemental", revealedCards, game); - for (Card card: revealedCards.getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } + controller.revealCards(sourceObject.getIdName(), revealedCards, game); + controller.moveCards(revealedCards, Zone.LIBRARY, source, game); controller.shuffleLibrary(game); return true; } @@ -121,4 +117,4 @@ class ThicketElementalEffect extends OneShotEffect { public ThicketElementalEffect copy() { return new ThicketElementalEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/judgment/WorldgorgerDragon.java b/Mage.Sets/src/mage/sets/judgment/WorldgorgerDragon.java index 0256568c9cd..692fc29a17e 100644 --- a/Mage.Sets/src/mage/sets/judgment/WorldgorgerDragon.java +++ b/Mage.Sets/src/mage/sets/judgment/WorldgorgerDragon.java @@ -27,6 +27,8 @@ */ package mage.sets.judgment; +import java.util.LinkedHashSet; +import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.MageObject; @@ -44,10 +46,10 @@ import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.ExileZone; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.game.permanent.PermanentToken; import mage.players.Player; import mage.util.CardUtil; @@ -94,6 +96,7 @@ class WorldgorgerDragonEntersEffect extends OneShotEffect { static { filter.add(new ControllerPredicate(TargetController.YOU)); + filter.add(new AnotherPredicate()); } public WorldgorgerDragonEntersEffect() { @@ -112,11 +115,9 @@ class WorldgorgerDragonEntersEffect extends OneShotEffect { if (controller != null) { UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); if (exileId != null) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { - if (!permanent.getId().equals(source.getSourceId())) { // Another - controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true); - } - } + Set cardsToExile = new LinkedHashSet<>(); + cardsToExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)); + controller.moveCardsToExile(cardsToExile, source, game, true, exileId, sourceObject.getIdName()); return true; } } @@ -148,14 +149,7 @@ class WorldgorgerDragonLeavesEffect extends OneShotEffect { int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1; ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter)); if (exile != null) { - exile = exile.copy(); - for (UUID cardId : exile) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCards(card, Zone.EXILED, source, game); - } - } - return true; + return controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); } } return false; diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/AshcloudPhoenix.java b/Mage.Sets/src/mage/sets/khansoftarkir/AshcloudPhoenix.java index 115370c7f92..4a11b9fbfdc 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/AshcloudPhoenix.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/AshcloudPhoenix.java @@ -64,13 +64,13 @@ public class AshcloudPhoenix extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); - + // When Ashcloud Phoenix dies, return it to the battlefield face down under your control. this.addAbility(new DiesTriggeredAbility(new AshcloudPhoenixEffect())); - + // Morph {4}{R}{R} this.addAbility(new MorphAbility(this, new ManaCostsImpl<>("{4}{R}{R}"))); - + // When Ashcloud Phoenix is turned face up, it deals 2 damage to each player. Effect effect = new DamagePlayersEffect(2, TargetController.ANY); effect.setText("it deals 2 damage to each player"); @@ -88,30 +88,30 @@ public class AshcloudPhoenix extends CardImpl { } class AshcloudPhoenixEffect extends OneShotEffect { - + AshcloudPhoenixEffect() { super(Outcome.PutCreatureInPlay); this.staticText = "return it to the battlefield face down under your control"; } - + AshcloudPhoenixEffect(final AshcloudPhoenixEffect effect) { super(effect); } - + @Override public AshcloudPhoenixEffect copy() { return new AshcloudPhoenixEffect(this); } - + @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) { Card card = game.getCard(source.getSourceId()); if (card != null) { Player owner = game.getPlayer(card.getOwnerId()); if (owner != null && owner.getGraveyard().contains(card.getId())) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false, true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, true, false, null); } } return true; diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java b/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java index fa93f72f934..048f1d84fc0 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java @@ -112,45 +112,41 @@ class KheruLichLordEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Cards cards = new CardsImpl(); - for (Card card : controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game)) { - cards.add(card.getId()); - } - - if (cards.size() > 0) { - Card card = cards.getRandom(game); - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game)); + Card card = cards.getRandom(game); + if (card != null) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game); Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { + FixedTarget fixedTarget = new FixedTarget(permanent, game); ContinuousEffect effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(fixedTarget); game.addEffect(effect, source); effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(fixedTarget); game.addEffect(effect, source); effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(fixedTarget); game.addEffect(effect, source); ExileTargetEffect exileEffect = new ExileTargetEffect(); - exileEffect.setTargetPointer(new FixedTarget(permanent.getId())); + exileEffect.setTargetPointer(fixedTarget); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setSourceObject(source.getSourceObject(game), game); game.addDelayedTriggeredAbility(delayedAbility); - KheruLichLordReplacementEffect replacementEffect = new KheruLichLordReplacementEffect(); - replacementEffect.setTargetPointer(new FixedTarget(permanent.getId())); + KheruLichLordReplacementEffect replacementEffect = new KheruLichLordReplacementEffect(); + replacementEffect.setTargetPointer(fixedTarget); game.addEffect(replacementEffect, source); - } } return true; } - return false; } } @@ -183,11 +179,11 @@ class KheruLichLordReplacementEffect extends ReplacementEffectImpl { return true; } - @Override + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.ZONE_CHANGE; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java b/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java index 87bcfe85461..a51b22e36a8 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/MeanderingTowershell.java @@ -46,19 +46,21 @@ import mage.game.permanent.Permanent; import mage.players.Player; /** - * As Meandering Towershell returns to the battlefield because of the delayed triggered ability, - * you choose which opponent or opposing planeswalker it’s attacking. It doesn’t have to attack - * the same opponent or opposing planeswalker that it was when it was exiled. + * As Meandering Towershell returns to the battlefield because of the delayed + * triggered ability, you choose which opponent or opposing planeswalker it’s + * attacking. It doesn’t have to attack the same opponent or opposing + * planeswalker that it was when it was exiled. * - * If Meandering Towershell enters the battlefield attacking, it wasn’t declared as an attacking - * creature that turn. Abilities that trigger when a creature attacks, including its own triggered - * ability, won’t trigger. + * If Meandering Towershell enters the battlefield attacking, it wasn’t declared + * as an attacking creature that turn. Abilities that trigger when a creature + * attacks, including its own triggered ability, won’t trigger. * - * On the turn Meandering Towershell attacks and is exiled, raid abilities will see it as a creature - * that attacked. Conversely, on the turn Meandering Towershell enters the battlefield attacking, - * raid abilities will not. + * On the turn Meandering Towershell attacks and is exiled, raid abilities will + * see it as a creature that attacked. Conversely, on the turn Meandering + * Towershell enters the battlefield attacking, raid abilities will not. * - * If you attack with a Meandering Towershell that you don’t own, you’ll control it when it returns to the battlefield. + * If you attack with a Meandering Towershell that you don’t own, you’ll control + * it when it returns to the battlefield. * * @author LevelX2 */ @@ -75,7 +77,7 @@ public class MeanderingTowershell extends CardImpl { // Islandwalk this.addAbility(new IslandwalkAbility()); - // Whenever Meandering Towershell attacks, exile it. + // Whenever Meandering Towershell attacks, exile it. // Return it to the battlefield under your control tapped and attacking // at the beginning of the next declare attackers step on your next turn. this.addAbility(new AttacksTriggeredAbility(new MeanderingTowershellEffect(), false)); @@ -191,7 +193,7 @@ class MeanderingTowershellReturnEffect extends OneShotEffect { if (controller != null) { Card card = game.getCard(source.getSourceId()); if (card != null && game.getState().getZone(source.getSourceId()).equals(Zone.EXILED)) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); game.getCombat().addAttackingCreature(card.getId(), game); return true; } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java b/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java index bf66ae2db31..75c2c3dc55b 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/SeeTheUnwritten.java @@ -47,8 +47,6 @@ import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; - - /** * * @author LevelX2 @@ -59,15 +57,14 @@ public class SeeTheUnwritten extends CardImpl { super(ownerId, 149, "See the Unwritten", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{4}{G}{G}"); this.expansionSetCode = "KTK"; - // Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard. // Ferocious - If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one. this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new SeeTheUnwrittenEffect(1), - new SeeTheUnwrittenEffect(2), + new SeeTheUnwrittenEffect(2), new InvertCondition(FerociousCondition.getInstance()), - "Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard." + - "
Ferocious — If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one" )); + "Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard." + + "
Ferocious — If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one")); } public SeeTheUnwritten(final SeeTheUnwritten card) { @@ -89,9 +86,9 @@ class SeeTheUnwrittenEffect extends OneShotEffect { public SeeTheUnwrittenEffect(int numberOfCardsToPutIntoPlay) { super(Outcome.DrawCard); this.numberOfCardsToPutIntoPlay = numberOfCardsToPutIntoPlay; - this.staticText = "Reveal the top eight cards of your library. You may put " + - (numberOfCardsToPutIntoPlay == 1 ? "a creature card":"two creature cards") + - " from among them onto the battlefield. Put the rest into your graveyard"; + this.staticText = "Reveal the top eight cards of your library. You may put " + + (numberOfCardsToPutIntoPlay == 1 ? "a creature card" : "two creature cards") + + " from among them onto the battlefield. Put the rest into your graveyard"; } public SeeTheUnwrittenEffect(final SeeTheUnwrittenEffect effect) { @@ -126,24 +123,24 @@ class SeeTheUnwrittenEffect extends OneShotEffect { if (!cards.isEmpty()) { controller.revealCards(sourceObject.getName(), cards, game); if (creatureCardsFound > 0 && controller.chooseUse(outcome, "Put creature(s) into play?", source, game)) { - int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound); + int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound); TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, filter); if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) { - for(UUID creatureId: target.getTargets()) { + for (UUID creatureId : target.getTargets()) { Card card = game.getCard(creatureId); if (card != null) { cards.remove(card); - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } } - controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + controller.moveCards(cards, Zone.GRAVEYARD, source, game); } return true; } return false; } - + } diff --git a/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java b/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java index f3ceefded0e..719016c9804 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java +++ b/Mage.Sets/src/mage/sets/lorwyn/IncandescentSoulstoke.java @@ -128,7 +128,7 @@ class IncandescentSoulstokeEffect extends OneShotEffect { if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); diff --git a/Mage.Sets/src/mage/sets/magic2010/HiveMind.java b/Mage.Sets/src/mage/sets/magic2010/HiveMind.java index b33a3c8e8a2..36d56343ed8 100644 --- a/Mage.Sets/src/mage/sets/magic2010/HiveMind.java +++ b/Mage.Sets/src/mage/sets/magic2010/HiveMind.java @@ -27,9 +27,7 @@ */ package mage.sets.magic2010; -import java.util.Set; import java.util.UUID; - import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; @@ -130,13 +128,12 @@ class HiveMindEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Spell spell; spell = game.getStack().getSpell(((FixedTarget) getTargetPointer()).getTarget()); - if (spell == null) { // if spell e.g. was countered + if (spell == null) { // if spell e.g. was countered spell = (Spell) game.getLastKnownInformation(((FixedTarget) getTargetPointer()).getTarget(), Zone.STACK); } Player player = game.getPlayer(source.getControllerId()); if (spell != null && player != null) { - Set players = player.getInRange(); - for (UUID playerId : players) { + for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) { if (!playerId.equals(spell.getControllerId())) { Spell copy = spell.copySpell(); copy.setControllerId(playerId); diff --git a/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java b/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java index 7b44f6e0f01..192c5d22db8 100644 --- a/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java +++ b/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java @@ -27,18 +27,17 @@ */ package mage.sets.magic2010; -import java.util.LinkedList; -import java.util.Set; +import java.util.LinkedHashSet; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -52,7 +51,6 @@ public class OpenTheVaults extends CardImpl { super(ownerId, 21, "Open the Vaults", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{W}{W}"); this.expansionSetCode = "M10"; - // Return all artifact and enchantment cards from all graveyards to the battlefield under their owners' control. this.getSpellAbility().addEffect(new OpenTheVaultsEffect()); } @@ -85,33 +83,21 @@ class OpenTheVaultsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - LinkedList enchantments = new LinkedList(); - LinkedList artifacts = new LinkedList(); - - Set playerIds = player.getInRange(); - playerIds.add(player.getId()); - - for (UUID playerId : playerIds) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + LinkedHashSet cardsToReturn = new LinkedHashSet<>(); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Cards graveyard = game.getPlayer(playerId).getGraveyard(); for (UUID cardId : graveyard) { Card card = game.getCard(cardId); - if (card != null && card.getCardType().contains(CardType.ENCHANTMENT)) { - enchantments.add(card); - } - if (card != null && card.getCardType().contains(CardType.ARTIFACT)) { - artifacts.add(card); + if (card != null + && (card.getCardType().contains(CardType.ENCHANTMENT) || card.getCardType().contains(CardType.ARTIFACT))) { + cardsToReturn.add(card); } } } - - for (Card card : enchantments) { - card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), card.getOwnerId()); - } - for (Card card : artifacts) { - card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), card.getOwnerId()); - } + controller.moveCards(cardsToReturn, Zone.BATTLEFIELD, source, game, false, false, true, null); + return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/magic2010/SphinxAmbassador.java b/Mage.Sets/src/mage/sets/magic2010/SphinxAmbassador.java index 595a34013f8..c76befa295f 100644 --- a/Mage.Sets/src/mage/sets/magic2010/SphinxAmbassador.java +++ b/Mage.Sets/src/mage/sets/magic2010/SphinxAmbassador.java @@ -95,16 +95,16 @@ class SphinxAmbassadorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - if (player != null && targetPlayer != null && sourcePermanent != null) { + if (controller != null && targetPlayer != null && sourcePermanent != null) { TargetCardInLibrary target = new TargetCardInLibrary(); - player.searchLibrary(target, game, targetPlayer.getId()); + controller.searchLibrary(target, game, targetPlayer.getId()); Card card = game.getCard(target.getFirstTarget()); if (card != null) { - TreeSet choices = new TreeSet(); + TreeSet choices = new TreeSet<>(); Collection cards = game.getCards(); for (Card gameCard : cards) { if (gameCard.getOwnerId().equals(targetPlayer.getId())) { @@ -124,8 +124,8 @@ class SphinxAmbassadorEffect extends OneShotEffect { game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(", named card: [").append(cardName).append("]").toString()); if (!card.getName().equals(cardName) && card.getCardType().contains(CardType.CREATURE)) { - if (player.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), source, game)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + if (controller.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), source, game)) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/magic2011/Cultivate.java b/Mage.Sets/src/mage/sets/magic2011/Cultivate.java index b68d4a6bdeb..d8b36c43345 100644 --- a/Mage.Sets/src/mage/sets/magic2011/Cultivate.java +++ b/Mage.Sets/src/mage/sets/magic2011/Cultivate.java @@ -111,17 +111,17 @@ class CultivateEffect extends OneShotEffect { controller.choose(Outcome.Benefit, revealed, target2, game); Card card = revealed.get(target2.getFirstTarget(), game); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); revealed.remove(card); } card = revealed.getCards(game).iterator().next(); if (card != null) { - controller.moveCards(card, null, Zone.HAND, source, game); + controller.moveCards(card, Zone.HAND, source, game); } } else if (target.getTargets().size() == 1) { Card card = revealed.getCards(game).iterator().next(); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); } } diff --git a/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java b/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java index 58a741397a3..d9cdc57cb98 100644 --- a/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java +++ b/Mage.Sets/src/mage/sets/magic2011/NecroticPlague.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,12 +20,11 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.magic2011; import java.util.UUID; @@ -86,7 +85,7 @@ public class NecroticPlague extends CardImpl { Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA, Duration.WhileOnBattlefield); effect.setText("Enchanted creature has \"At the beginning of your upkeep, sacrifice this creature.\""); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); - this.addAbility(new DiesAttachedTriggeredAbility(new NecroticPlagueEffect(),"enchanted creature", false)); + this.addAbility(new DiesAttachedTriggeredAbility(new NecroticPlagueEffect(), "enchanted creature", false)); } @@ -94,7 +93,7 @@ public class NecroticPlague extends CardImpl { public void adjustTargets(Ability ability, Game game) { if (ability instanceof DiesAttachedTriggeredAbility) { Permanent attachedTo = null; - for (Effect effect :ability.getEffects()) { + for (Effect effect : ability.getEffects()) { attachedTo = (Permanent) effect.getValue("attachedTo"); } if (attachedTo != null) { @@ -122,8 +121,6 @@ public class NecroticPlague extends CardImpl { class NecroticPlagueEffect extends OneShotEffect { - - public NecroticPlagueEffect() { super(Outcome.PutCardInPlay); staticText = "its controller chooses target creature one of his or her opponents controls. Return {this} from its owner's graveyard to the battlefield attached to that creature"; @@ -143,7 +140,7 @@ class NecroticPlagueEffect extends OneShotEffect { Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (sourceEnchantmentCard != null && creature != null) { game.getState().setValue("attachTo:" + sourceEnchantmentCard.getId(), creature); - creatureController.putOntoBattlefieldWithInfo(sourceEnchantmentCard, game, Zone.GRAVEYARD, source.getSourceId()); + creatureController.moveCards(sourceEnchantmentCard, Zone.BATTLEFIELD, source, game); return creature.addAttachment(sourceEnchantmentCard.getId(), game); } } diff --git a/Mage.Sets/src/mage/sets/magic2015/BoonweaverGiant.java b/Mage.Sets/src/mage/sets/magic2015/BoonweaverGiant.java index 12075176452..d5f432ff10e 100644 --- a/Mage.Sets/src/mage/sets/magic2015/BoonweaverGiant.java +++ b/Mage.Sets/src/mage/sets/magic2015/BoonweaverGiant.java @@ -97,8 +97,8 @@ class BoonweaverGiantEffect 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) { return false; } @@ -108,18 +108,18 @@ class BoonweaverGiantEffect extends OneShotEffect { Card card = null; Zone zone = null; - if (player.chooseUse(Outcome.Neutral, "Search your graveyard for an Aura card?", source, game)) { + if (controller.chooseUse(Outcome.Neutral, "Search your graveyard for an Aura card?", source, game)) { TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter); - if (player.choose(Outcome.PutCardInPlay, player.getGraveyard(), target, game)) { + if (controller.choose(Outcome.PutCardInPlay, controller.getGraveyard(), target, game)) { card = game.getCard(target.getFirstTarget()); if (card != null) { zone = Zone.GRAVEYARD; } } } - if (card == null && player.chooseUse(Outcome.Neutral, "Search your Hand for an Aura card?", source, game)) { + if (card == null && controller.chooseUse(Outcome.Neutral, "Search your Hand for an Aura card?", source, game)) { TargetCardInHand target = new TargetCardInHand(filter); - if (player.choose(Outcome.PutCardInPlay, player.getHand(), target, game)) { + if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) { card = game.getCard(target.getFirstTarget()); if (card != null) { zone = Zone.HAND; @@ -128,13 +128,13 @@ class BoonweaverGiantEffect extends OneShotEffect { } if (card == null) { TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { + if (controller.searchLibrary(target, game)) { card = game.getCard(target.getFirstTarget()); if (card != null) { zone = Zone.LIBRARY; } } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); } // aura card found - attach it if (card != null) { @@ -142,7 +142,7 @@ class BoonweaverGiantEffect extends OneShotEffect { if (permanent != null) { game.getState().setValue("attachTo:" + card.getId(), permanent); } - player.putOntoBattlefieldWithInfo(card, game, zone, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); if (permanent != null) { return permanent.addAttachment(card.getId(), game); } diff --git a/Mage.Sets/src/mage/sets/magic2015/JaliraMasterPolymorphist.java b/Mage.Sets/src/mage/sets/magic2015/JaliraMasterPolymorphist.java index a9cd3d3260d..cc21944e5c5 100644 --- a/Mage.Sets/src/mage/sets/magic2015/JaliraMasterPolymorphist.java +++ b/Mage.Sets/src/mage/sets/magic2015/JaliraMasterPolymorphist.java @@ -132,10 +132,10 @@ class JaliraMasterPolymorphistEffect extends OneShotEffect { } while (library.size() > 0 && card != null && !filter.match(card, game)); // reveal cards if (!cards.isEmpty()) { - controller.revealCards(sourceObject.getName(), cards, game); + controller.revealCards(sourceObject.getIdName(), cards, game); } // put nonlegendary creature card to battlefield - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); // remove it from revealed card list cards.remove(card); // Put the rest on the bottom of your library in a random order diff --git a/Mage.Sets/src/mage/sets/magic2015/NissaWorldwaker.java b/Mage.Sets/src/mage/sets/magic2015/NissaWorldwaker.java index 00f8de29bc3..c1fc0b51a84 100644 --- a/Mage.Sets/src/mage/sets/magic2015/NissaWorldwaker.java +++ b/Mage.Sets/src/mage/sets/magic2015/NissaWorldwaker.java @@ -51,6 +51,7 @@ import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; import mage.players.Player; import mage.target.TargetPermanent; @@ -121,26 +122,30 @@ class NissaWorldwakerSearchEffect 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) { return false; } TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterBasicLandCard()); - if (player.searchLibrary(target, game)) { + if (controller.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { for (UUID cardId : target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); + Card card = controller.getLibrary().getCard(cardId, game); if (card != null) { - if (player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId())) { - ContinuousEffect effect = new BecomesCreatureTargetEffect(new NissaWorldwakerToken(), false, true, Duration.Custom); - effect.setTargetPointer(new FixedTarget(card.getId())); - game.addEffect(effect, source); + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { + Permanent land = game.getPermanent(card.getId()); + if (land != null) { + ContinuousEffect effect = new BecomesCreatureTargetEffect(new NissaWorldwakerToken(), false, true, Duration.Custom); + effect.setTargetPointer(new FixedTarget(land, game)); + game.addEffect(effect, source); + + } } } } } } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } } diff --git a/Mage.Sets/src/mage/sets/magic2015/YisanTheWandererBard.java b/Mage.Sets/src/mage/sets/magic2015/YisanTheWandererBard.java index c5c6d4568e9..978e17f81dd 100644 --- a/Mage.Sets/src/mage/sets/magic2015/YisanTheWandererBard.java +++ b/Mage.Sets/src/mage/sets/magic2015/YisanTheWandererBard.java @@ -35,7 +35,6 @@ import mage.abilities.costs.common.PutCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; @@ -86,40 +85,36 @@ public class YisanTheWandererBard extends CardImpl { } class YisanTheWandererBardEffect extends OneShotEffect { - + public YisanTheWandererBardEffect() { super(Outcome.Benefit); this.staticText = "Search your library for a creature card with converted mana cost equal to the number of verse counters on {this}, put it onto the battlefield, then shuffle your library"; } - + public YisanTheWandererBardEffect(final YisanTheWandererBardEffect effect) { super(effect); } - + @Override public YisanTheWandererBardEffect copy() { return new YisanTheWandererBardEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - if (sourcePermanent != null && player != null) { + if (sourcePermanent != null && controller != null) { int newConvertedCost = sourcePermanent.getCounters().getCount("verse"); FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost)); filter.add(new CardTypePredicate(CardType.CREATURE)); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { - for (UUID cardId : target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); - } - } + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/magicorigins/NissasPilgrimage.java b/Mage.Sets/src/mage/sets/magicorigins/NissasPilgrimage.java index 442643c5ffc..d6023fed3fa 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/NissasPilgrimage.java +++ b/Mage.Sets/src/mage/sets/magicorigins/NissasPilgrimage.java @@ -113,8 +113,8 @@ class NissasPilgrimageEffect extends OneShotEffect { Card card = cards.getRandom(game); if (card != null) { cards.remove(card); - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true); - controller.moveCards(cards, Zone.LIBRARY, Zone.HAND, source, game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null); + controller.moveCards(cards, Zone.HAND, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java b/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java index c6fc391ddf2..2fcfe39ffe4 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java +++ b/Mage.Sets/src/mage/sets/magicorigins/TheGreatAurora.java @@ -36,8 +36,9 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileSpellEffect; -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; @@ -92,63 +93,62 @@ class TheGreatAuroraEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { - Map> permanentsOwned = new HashMap<>(); - Collection permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game); - for (Permanent permanent : permanents) { - List list = permanentsOwned.get(permanent.getOwnerId()); - if (list == null) { - list = new ArrayList<>(); - permanentsOwned.put(permanent.getOwnerId(), list); - } - list.add(permanent); - } - - // shuffle permanents and hand cards into owner's library - Map permanentsCount = new HashMap<>(); - - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - int handCards = player.getHand().size(); - player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game); - List list = permanentsOwned.remove(player.getId()); - permanentsCount.put(playerId, handCards + (list != null ? list.size() : 0)); - for (Permanent permanent : list) { - player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true); + Map> permanentsOwned = new HashMap<>(); + Collection permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game); + for (Permanent permanent : permanents) { + List list = permanentsOwned.get(permanent.getOwnerId()); + if (list == null) { + list = new ArrayList<>(); + permanentsOwned.put(permanent.getOwnerId(), list); } - player.shuffleLibrary(game); + list.add(permanent); } - } - game.applyEffects(); // so effects from creatures that were on the battlefield won't trigger from draw or put into play + // shuffle permanents and hand cards into owner's library + Map permanentsCount = new HashMap<>(); - // Draw cards - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - int count = permanentsCount.get(playerId); - if (count > 0) { - player.drawCards(count, game); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + int handCards = player.getHand().size(); + player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game); + List list = permanentsOwned.remove(player.getId()); + permanentsCount.put(playerId, handCards + (list != null ? list.size() : 0)); + for (Permanent permanent : list) { + player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true); + } + player.shuffleLibrary(game); } } - } - // put lands onto the battlefield - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - TargetCard target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterLandCard("put any number of land cards from your hand onto the battlefield")); - player.chooseTarget(Outcome.PutLandInPlay, player.getHand(), target, source, game); - for (UUID cardId : target.getTargets()) { - Card card = game.getCard(cardId); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), false); + game.applyEffects(); // so effects from creatures that were on the battlefield won't trigger from draw or put into play + + // Draw cards + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + int count = permanentsCount.get(playerId); + if (count > 0) { + player.drawCards(count, game); } } - } + + // put lands onto the battlefield + Cards toBattlefield = new CardsImpl(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + TargetCard target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterLandCard("put any number of land cards from your hand onto the battlefield")); + player.chooseTarget(Outcome.PutLandInPlay, player.getHand(), target, source, game); + toBattlefield.addAll(target.getTargets()); + } + } + return controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); } - return true; + return false; } } diff --git a/Mage.Sets/src/mage/sets/magicorigins/WoodlandBellower.java b/Mage.Sets/src/mage/sets/magicorigins/WoodlandBellower.java index adfa437ce62..3df2f8848c2 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/WoodlandBellower.java +++ b/Mage.Sets/src/mage/sets/magicorigins/WoodlandBellower.java @@ -78,6 +78,7 @@ public class WoodlandBellower extends CardImpl { } class WoodlandBellowerEffect extends OneShotEffect { + WoodlandBellowerEffect() { super(Outcome.PutCreatureInPlay); staticText = "Search your library for a nonlegendary green creature card with converted mana cost 3 or less, put it onto the battlefield, then shuffle your library"; @@ -89,27 +90,25 @@ class WoodlandBellowerEffect 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) { return false; } FilterCard filter = new FilterCard("nonlegendary green creature card with converted mana cost 3 or less"); filter.add(new ColorPredicate(ObjectColor.GREEN)); - filter.add(new CardTypePredicate(CardType.CREATURE)); + filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(Predicates.not(new SupertypePredicate("Legendary"))); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 4)); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { + if (controller.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { - Card card = player.getLibrary().getCard(target.getFirstTarget(), game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); - } + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return false; } @@ -118,4 +117,4 @@ class WoodlandBellowerEffect extends OneShotEffect { return new WoodlandBellowerEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java b/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java index 8730131d3ba..0c293502e33 100644 --- a/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java +++ b/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java @@ -35,7 +35,6 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; @@ -109,8 +108,7 @@ class MagisterOfWorthVoteEffect extends OneShotEffect { if (player.chooseUse(Outcome.DestroyPermanent, "Choose grace?", source, game)) { graceCount++; game.informPlayers(player.getLogName() + " has chosen: grace"); - } - else { + } else { condemnationCount++; game.informPlayers(player.getLogName() + " has chosen: condemnation"); } @@ -130,7 +128,7 @@ class MagisterOfWorthVoteEffect extends OneShotEffect { class MagisterOfWorthDestroyEffect extends OneShotEffect { private static final FilterPermanent filter = new FilterCreaturePermanent("creatures other than {this}"); - + static { filter.add(new AnotherPredicate()); } @@ -175,12 +173,10 @@ class MagisterOfWorthReturnFromGraveyardEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card :player.getGraveyard().getCards(new FilterCreatureCard(), game)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); - } + player.moveCards(player.getGraveyard().getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game); } } return true; @@ -193,4 +189,4 @@ class MagisterOfWorthReturnFromGraveyardEffect extends OneShotEffect { return new MagisterOfWorthReturnFromGraveyardEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/Bribery.java b/Mage.Sets/src/mage/sets/mercadianmasques/Bribery.java index 199c4f5e1bc..c7aec373447 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/Bribery.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/Bribery.java @@ -27,7 +27,6 @@ */ package mage.sets.mercadianmasques; -import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -91,13 +90,8 @@ class BriberyEffect extends OneShotEffect { if (controller != null && opponent != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterCreatureCard("creature card")); if (controller.searchLibrary(target, game, opponent.getId())) { - List targets = target.getTargets(); - for (UUID targetId : targets) { - Card card = opponent.getLibrary().getCard(targetId, game); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); - } - } + Card card = opponent.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } opponent.shuffleLibrary(game); return true; diff --git a/Mage.Sets/src/mage/sets/mirage/ShallowGrave.java b/Mage.Sets/src/mage/sets/mirage/ShallowGrave.java index 67ef2954399..9ee5675fccf 100644 --- a/Mage.Sets/src/mage/sets/mirage/ShallowGrave.java +++ b/Mage.Sets/src/mage/sets/mirage/ShallowGrave.java @@ -100,7 +100,7 @@ class ShallowGraveEffect extends OneShotEffect { } } if (lastCreatureCard != null) { - if (controller.putOntoBattlefieldWithInfo(lastCreatureCard, game, Zone.GRAVEYARD, source.getSourceId())) { + if (controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game)) { Permanent returnedCreature = game.getPermanent(lastCreatureCard.getId()); if (returnedCreature != null) { FixedTarget fixedTarget = new FixedTarget(returnedCreature, game); diff --git a/Mage.Sets/src/mage/sets/mirrodin/ScytheOfTheWretched.java b/Mage.Sets/src/mage/sets/mirrodin/ScytheOfTheWretched.java index a0b0f53927a..67e45f89c1a 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/ScytheOfTheWretched.java +++ b/Mage.Sets/src/mage/sets/mirrodin/ScytheOfTheWretched.java @@ -158,8 +158,7 @@ class ScytheOfTheWretchedReanimateEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (card != null && controller != null) { - Zone currentZone = game.getState().getZone(card.getId()); - controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); Effect effect = new AttachEffect(Outcome.AddAbility); effect.setTargetPointer(new FixedTarget(card.getId())); effect.apply(game, source); diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java index eb95700b42a..03cb3e2fbf8 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/GreenSunsZenith.java @@ -25,18 +25,18 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.mirrodinbesieged; -import mage.constants.CardType; -import mage.constants.Rarity; +import java.util.UUID; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ShuffleSpellEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.Filter; import mage.filter.FilterCard; @@ -47,8 +47,6 @@ import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInLibrary; -import java.util.UUID; - /** * @author Loki */ @@ -77,6 +75,7 @@ public class GreenSunsZenith extends CardImpl { } class GreenSunsZenithSearchEffect extends OneShotEffect { + GreenSunsZenithSearchEffect() { super(Outcome.PutCreatureInPlay); staticText = "Search your library for a green creature card with converted mana cost X or less, put it onto the battlefield, then shuffle your library"; @@ -88,28 +87,28 @@ class GreenSunsZenithSearchEffect 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) { return false; } //Set the mana cost one higher to 'emulate' a less than or equal to comparison. int xValue = source.getManaCostsToPay().getX() + 1; FilterCard filter = new FilterCard("green creature card with converted mana cost " + xValue + " or less"); filter.add(new ColorPredicate(ObjectColor.GREEN)); - filter.add(new CardTypePredicate(CardType.CREATURE)); + filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, xValue)); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { + if (controller.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { - Card card = player.getLibrary().getCard(target.getFirstTarget(), game); + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return false; } diff --git a/Mage.Sets/src/mage/sets/modernmasters/ToothAndNail.java b/Mage.Sets/src/mage/sets/modernmasters/ToothAndNail.java index 86f2e6936b8..30762aeb3d7 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/ToothAndNail.java +++ b/Mage.Sets/src/mage/sets/modernmasters/ToothAndNail.java @@ -33,8 +33,8 @@ import mage.abilities.Mode; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.abilities.keyword.EntwineAbility; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -102,13 +102,8 @@ class ToothAndNailPutCreatureOnBattlefieldEffect extends OneShotEffect { TargetCardInHand target = new TargetCardInHand(0, 2, new FilterCreatureCard("creature cards")); if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { - for (UUID targetId : target.getTargets()) { - Card card = game.getCard(targetId); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), false); - } - } - return true; + return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game), + Zone.BATTLEFIELD, source, game, true, false, false, null); } return false; } diff --git a/Mage.Sets/src/mage/sets/morningtide/Scapeshift.java b/Mage.Sets/src/mage/sets/morningtide/Scapeshift.java index f1c69c592e4..5e7f57e6dd5 100644 --- a/Mage.Sets/src/mage/sets/morningtide/Scapeshift.java +++ b/Mage.Sets/src/mage/sets/morningtide/Scapeshift.java @@ -27,16 +27,14 @@ */ package mage.sets.morningtide; -import java.util.List; import java.util.UUID; - +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; import mage.constants.Zone; import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterLandCard; @@ -56,7 +54,6 @@ public class Scapeshift extends CardImpl { super(ownerId, 136, "Scapeshift", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{G}{G}"); this.expansionSetCode = "MOR"; - // Sacrifice any number of lands. Search your library for that many land cards, put them onto the battlefield tapped, then shuffle your library. this.getSpellAbility().addEffect(new ScapeshiftEffect()); } @@ -71,12 +68,11 @@ public class Scapeshift extends CardImpl { } } - class ScapeshiftEffect extends OneShotEffect { public ScapeshiftEffect() { super(Outcome.Neutral); - staticText = "Sacrifice any number of lands. Search your library for that many land cards, put them onto the battlefield tapped, then shuffle your library"; + staticText = "Sacrifice any number of lands. Search your library for that many land cards, put them onto the battlefield tapped, then shuffle your library"; } public ScapeshiftEffect(final ScapeshiftEffect effect) { @@ -90,35 +86,29 @@ class ScapeshiftEffect 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) { return false; } int amount = 0; TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true); - if(player.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)){ - for(Object uuid : sacrificeLand.getTargets()){ - Permanent land = game.getPermanent((UUID)uuid); - if(land != null){ + if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) { + for (Object uuid : sacrificeLand.getTargets()) { + Permanent land = game.getPermanent((UUID) uuid); + if (land != null) { land.sacrifice(source.getSourceId(), game); amount++; } } } TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands")); - if (player.searchLibrary(target, game)) { - if (target.getTargets().size() > 0) { - for (UUID cardId: (List)target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getControllerId(), true); - } - } - } - player.shuffleLibrary(game); + if (controller.searchLibrary(target, game)) { + controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), + Zone.BATTLEFIELD, source, game, true, false, false, null); + controller.shuffleLibrary(game); return true; } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return false; } diff --git a/Mage.Sets/src/mage/sets/nemesis/LinSivviDefiantHero.java b/Mage.Sets/src/mage/sets/nemesis/LinSivviDefiantHero.java index efc9dcd7c22..3748ad54259 100644 --- a/Mage.Sets/src/mage/sets/nemesis/LinSivviDefiantHero.java +++ b/Mage.Sets/src/mage/sets/nemesis/LinSivviDefiantHero.java @@ -59,16 +59,16 @@ import mage.target.common.TargetCardInYourGraveyard; * @author fireshoes */ public class LinSivviDefiantHero extends CardImpl { - + private static final FilterCard filter = new FilterCard("Rebel card from your graveyard"); - + static { filter.add(new OwnerPredicate(TargetController.YOU)); filter.add(new SubtypePredicate("Rebel")); } - + static final String rule = "Put target Rebel card from your graveyard on the bottom of your library"; - + public LinSivviDefiantHero(UUID ownerId) { super(ownerId, 12, "Lin Sivvi, Defiant Hero", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); this.expansionSetCode = "NMS"; @@ -84,7 +84,7 @@ public class LinSivviDefiantHero extends CardImpl { new ManaCostsImpl("{X}")); ability.addCost(new TapSourceCost()); this.addAbility(ability); - + // {3}: Put target Rebel card from your graveyard on the bottom of your library. ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutOnLibraryTargetEffect(false, rule), new GenericManaCost(3)); ability.addTarget(new TargetCardInYourGraveyard(1, filter)); @@ -119,8 +119,8 @@ class LinSivviDefiantHeroEffect 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) { return false; } @@ -131,15 +131,15 @@ class LinSivviDefiantHeroEffect extends OneShotEffect { filter.add(new SubtypePredicate("Rebel")); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { - Card card = player.getLibrary().getCard(target.getFirstTarget(), game); + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/newphyrexia/BirthingPod.java b/Mage.Sets/src/mage/sets/newphyrexia/BirthingPod.java index 03790814187..8109def52a8 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/BirthingPod.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/BirthingPod.java @@ -28,9 +28,6 @@ package mage.sets.newphyrexia; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.common.ActivateAsSorceryActivatedAbility; import mage.abilities.costs.Cost; @@ -40,7 +37,9 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.Filter; import mage.filter.FilterCard; @@ -61,7 +60,6 @@ public class BirthingPod extends CardImpl { super(ownerId, 104, "Birthing Pod", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}{GP}"); this.expansionSetCode = "NPH"; - // {1}{GP}, {tap}, Sacrifice a creature: Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, put that card onto the battlefield, then shuffle your library. Activate this ability only any time you could cast a sorcery. Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new BirthingPodEffect(), new ManaCostsImpl("{1}{GP}")); ability.addCost(new TapSourceCost()); @@ -80,6 +78,7 @@ public class BirthingPod extends CardImpl { } class BirthingPodEffect extends OneShotEffect { + BirthingPodEffect() { super(Outcome.Benefit); staticText = "Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, put that card onto the battlefield, then shuffle your library"; @@ -101,22 +100,18 @@ class BirthingPodEffect extends OneShotEffect { break; } } - Player player = game.getPlayer(source.getControllerId()); - if (sacrificedPermanent != null && player != null) { + Player controller = game.getPlayer(source.getControllerId()); + if (sacrificedPermanent != null && controller != null) { int newConvertedCost = sacrificedPermanent.getManaCost().convertedManaCost() + 1; FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost)); filter.add(new CardTypePredicate(CardType.CREATURE)); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { - for (UUID cardId : target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); - } - } + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/newphyrexia/MeliraSylvokOutcast.java b/Mage.Sets/src/mage/sets/newphyrexia/MeliraSylvokOutcast.java index b43ddb45473..0e370f97e18 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/MeliraSylvokOutcast.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/MeliraSylvokOutcast.java @@ -29,13 +29,6 @@ package mage.sets.newphyrexia; import java.util.Set; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.SubLayer; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -43,6 +36,13 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.keyword.InfectAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.SubLayer; +import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; @@ -63,7 +63,6 @@ public class MeliraSylvokOutcast extends CardImpl { this.subtype.add("Human"); this.subtype.add("Scout"); - this.power = new MageInt(2); this.toughness = new MageInt(2); @@ -113,7 +112,7 @@ class MeliraSylvokOutcastEffect extends ReplacementEffectImpl { public boolean checksEventType(GameEvent event, Game game) { return event.getType() == EventType.ADD_COUNTER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { return event.getData().equals(CounterType.POISON.getName()) && event.getTargetId().equals(source.getControllerId()); @@ -141,16 +140,19 @@ class MeliraSylvokOutcastEffect2 extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { return true; } - + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == EventType.ADD_COUNTER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getData().equals(CounterType.M1M1.getName())) { Permanent perm = game.getPermanent(event.getTargetId()); + if (perm == null) { + perm = game.getPermanentEntering(event.getTargetId()); + } if (perm != null && perm.getCardType().contains(CardType.CREATURE) && perm.getControllerId().equals(source.getControllerId())) { return true; } @@ -181,7 +183,7 @@ class MeliraSylvokOutcastEffect3 extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { Set opponents = game.getOpponents(source.getControllerId()); - for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { if (opponents.contains(perm.getControllerId())) { perm.getAbilities().remove(InfectAbility.getInstance()); } diff --git a/Mage.Sets/src/mage/sets/odyssey/Zoologist.java b/Mage.Sets/src/mage/sets/odyssey/Zoologist.java index 5780599cfe9..cc7330b0491 100644 --- a/Mage.Sets/src/mage/sets/odyssey/Zoologist.java +++ b/Mage.Sets/src/mage/sets/odyssey/Zoologist.java @@ -29,6 +29,7 @@ package mage.sets.odyssey; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; @@ -36,7 +37,6 @@ import mage.abilities.costs.mana.ManaCostsImpl; 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; @@ -94,25 +94,23 @@ class ZoologistEffect 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()); + MageObject sourceObject = source.getSourceObject(game); + if (controller == null || sourceObject == null) { return false; } - if (player.getLibrary().size() > 0) { - Card card = player.getLibrary().getFromTop(game); - Cards cards = new CardsImpl(); - cards.add(card); - player.revealCards("Zoologist", cards, game); - + if (controller.getLibrary().size() > 0) { + Card card = controller.getLibrary().getFromTop(game); + controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game); if (card != null) { if (card.getCardType().contains(CardType.CREATURE)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } else { - player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); + controller.moveCards(card, Zone.GRAVEYARD, source, game); } } } - return false; + return true; } } diff --git a/Mage.Sets/src/mage/sets/onslaught/PatriarchsBidding.java b/Mage.Sets/src/mage/sets/onslaught/PatriarchsBidding.java index 42b4dfd2de0..61d54f0c357 100644 --- a/Mage.Sets/src/mage/sets/onslaught/PatriarchsBidding.java +++ b/Mage.Sets/src/mage/sets/onslaught/PatriarchsBidding.java @@ -35,7 +35,6 @@ import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; import mage.choices.Choice; @@ -78,7 +77,7 @@ class PatriarchsBiddingEffect extends OneShotEffect { public PatriarchsBiddingEffect() { super(Outcome.PutCreatureInPlay); - this.staticText = "Each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield."; + this.staticText = "each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield"; } public PatriarchsBiddingEffect(final PatriarchsBiddingEffect effect) { @@ -91,12 +90,12 @@ class PatriarchsBiddingEffect extends OneShotEffect { } @Override - public boolean apply(Game game, Ability ability) { - Player controller = game.getPlayer(ability.getControllerId()); - MageObject sourceObject = game.getObject(ability.getSourceId()); + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null) { Set chosenTypes = new HashSet<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); Choice typeChoice = new ChoiceImpl(true); typeChoice.setMessage("Choose a creature type"); @@ -108,24 +107,21 @@ class PatriarchsBiddingEffect extends OneShotEffect { } String chosenType = typeChoice.getChoice(); if (chosenType != null) { - game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has chosen " + chosenType); + game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType); chosenTypes.add(chosenType); } } - + List predicates = new ArrayList<>(); for (String type : chosenTypes) { predicates.add(new SubtypePredicate(type)); } FilterCard filter = new FilterCreatureCard(); filter.add(Predicates.or(predicates)); - - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getGraveyard().getCards(filter, game)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, ability.getSourceId()); - } + player.moveCards(player.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game); } } return true; diff --git a/Mage.Sets/src/mage/sets/onslaught/RiptideShapeshifter.java b/Mage.Sets/src/mage/sets/onslaught/RiptideShapeshifter.java index 0f4b766a2cd..72ff1eb3c97 100644 --- a/Mage.Sets/src/mage/sets/onslaught/RiptideShapeshifter.java +++ b/Mage.Sets/src/mage/sets/onslaught/RiptideShapeshifter.java @@ -29,6 +29,7 @@ package mage.sets.onslaught; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; @@ -79,47 +80,46 @@ public class RiptideShapeshifter extends CardImpl { } class RiptideShapeshifterEffect extends OneShotEffect { - + RiptideShapeshifterEffect() { super(Outcome.PutCreatureInPlay); this.staticText = "Choose a creature type. Reveal cards from the top of your library until you reveal a creature card of that type. Put that card onto the battlefield and shuffle the rest into your library"; } - + RiptideShapeshifterEffect(final RiptideShapeshifterEffect effect) { super(effect); } - + @Override public RiptideShapeshifterEffect copy() { return new RiptideShapeshifterEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { Choice choice = new ChoiceImpl(true); choice.setMessage("Choose a creature type:"); choice.setChoices(CardRepository.instance.getCreatureTypes()); - while (!player.choose(Outcome.BoostCreature, choice, game)) { - if (!player.canRespond()) { + while (!controller.choose(Outcome.BoostCreature, choice, game)) { + if (!controller.canRespond()) { return false; } } Cards revealedCards = new CardsImpl(); - while (player.getLibrary().size() > 0) { - Card card = player.getLibrary().removeFromTop(game); + while (controller.getLibrary().size() > 0) { + Card card = controller.getLibrary().removeFromTop(game); if (card.getCardType().contains(CardType.CREATURE) && card.getSubtype().contains(choice.getChoice())) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); break; } revealedCards.add(card); } - player.revealCards("Riptide Shapeshifter", revealedCards, game); - for (Card card: revealedCards.getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - player.shuffleLibrary(game); + controller.revealCards(sourceObject.getIdName(), revealedCards, game); + controller.moveCards(revealedCards, Zone.LIBRARY, source, game); + controller.shuffleLibrary(game); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/ravnica/SistersOfStoneDeath.java b/Mage.Sets/src/mage/sets/ravnica/SistersOfStoneDeath.java index 92302fb34a7..13fa2e682d0 100644 --- a/Mage.Sets/src/mage/sets/ravnica/SistersOfStoneDeath.java +++ b/Mage.Sets/src/mage/sets/ravnica/SistersOfStoneDeath.java @@ -43,7 +43,7 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; -import mage.filter.FilterCard; +import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.permanent.BlockedByIdPredicate; @@ -101,7 +101,7 @@ public class SistersOfStoneDeath extends CardImpl { class SistersOfStoneDeathEffect extends OneShotEffect { - private UUID exileId; + private final UUID exileId; public SistersOfStoneDeathEffect(UUID exileId) { super(Outcome.PutCreatureInPlay); @@ -117,7 +117,7 @@ class SistersOfStoneDeathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { CardsImpl cardsInExile = new CardsImpl(); - TargetCard target = new TargetCard(Zone.PICK, new FilterCard()); + TargetCard target = new TargetCard(Zone.EXILED, new FilterCreatureCard()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ExileZone exile = game.getExile().getExileZone(exileId); @@ -129,7 +129,7 @@ class SistersOfStoneDeathEffect extends OneShotEffect { } if (controller.choose(Outcome.PutCreatureInPlay, cardsInExile, target, game)) { Card chosenCard = game.getCard(target.getFirstTarget()); - return controller.moveCards(chosenCard, Zone.EXILED, source, game); + return controller.moveCards(chosenCard, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/returntoravnica/CorpsejackMenace.java b/Mage.Sets/src/mage/sets/returntoravnica/CorpsejackMenace.java index a5d959857b3..10bf030e45a 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/CorpsejackMenace.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/CorpsejackMenace.java @@ -40,7 +40,6 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -96,7 +95,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent == null) { - permanent = ((EntersTheBattlefieldEvent) event).getTarget(); + permanent = game.getPermanentEntering(event.getTargetId()); } if (permanent != null) { permanent.addCounters(CounterType.P1P1.createInstance(event.getAmount() * 2), game, event.getAppliedEffects()); @@ -112,7 +111,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getData().equals(CounterType.P1P1.getName())) { - Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); + Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent == null) { permanent = game.getPermanentEntering(event.getTargetId()); } diff --git a/Mage.Sets/src/mage/sets/returntoravnica/VolatileRig.java b/Mage.Sets/src/mage/sets/returntoravnica/VolatileRig.java index cc804adcfad..8a43a92c249 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/VolatileRig.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/VolatileRig.java @@ -195,7 +195,7 @@ class VolatileRigEffect2 extends OneShotEffect { for (Permanent permanent: permanents) { permanent.damage(4, source.getSourceId(), game, false, true); } - for (UUID playerId: player.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(player.getId(), game)) { Player damageToPlayer = game.getPlayer(playerId); if (damageToPlayer != null) { damageToPlayer.damage(4, source.getSourceId(), game, false, true); diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/EnduringIdeal.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/EnduringIdeal.java index b3483485a0a..02c4cf52ea5 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/EnduringIdeal.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/EnduringIdeal.java @@ -46,7 +46,7 @@ import mage.target.common.TargetCardInLibrary; /** * * @author jeffwadsworth - + * */ public class EnduringIdeal extends CardImpl { @@ -54,13 +54,12 @@ public class EnduringIdeal extends CardImpl { super(ownerId, 9, "Enduring Ideal", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{5}{W}{W}"); this.expansionSetCode = "SOK"; - // Search your library for an enchantment card and put it onto the battlefield. Then shuffle your library. this.getSpellAbility().addEffect(new EnduringIdealEffect()); - + // Epic this.getSpellAbility().addEffect(new EpicEffect()); - + } public EnduringIdeal(final EnduringIdeal card) { @@ -74,9 +73,9 @@ public class EnduringIdeal extends CardImpl { } class EnduringIdealEffect extends OneShotEffect { - + private static final FilterCard filter = new FilterCard(); - + static { filter.add(new CardTypePredicate(CardType.ENCHANTMENT)); } @@ -93,16 +92,16 @@ class EnduringIdealEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { boolean applied = false; - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { TargetCardInLibrary target = new TargetCardInLibrary(filter); - you.searchLibrary(target, game); + controller.searchLibrary(target, game); Card targetCard = game.getCard(target.getFirstTarget()); if (targetCard == null) { applied = false; - } else{ - applied = you.putOntoBattlefieldWithInfo(targetCard, game, Zone.LIBRARY, source.getSourceId()); - you.shuffleLibrary(game); + } else { + applied = controller.moveCards(targetCard, Zone.BATTLEFIELD, source, game); + controller.shuffleLibrary(game); } } return applied; diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/EternalDominion.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/EternalDominion.java index cd5d754421b..7b63cd400fe 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/EternalDominion.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/EternalDominion.java @@ -56,12 +56,11 @@ public class EternalDominion extends CardImpl { super(ownerId, 36, "Eternal Dominion", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{7}{U}{U}{U}"); this.expansionSetCode = "SOK"; - // Search target opponent's library for an artifact, creature, enchantment, or land card. // Put that card onto the battlefield under your control. Then that player shuffles his or her library. this.getSpellAbility().addEffect(new EternalDominionEffect()); this.getSpellAbility().addTarget(new TargetOpponent()); - + // Epic this.getSpellAbility().addEffect(new EpicEffect()); @@ -78,9 +77,9 @@ public class EternalDominion extends CardImpl { } class EternalDominionEffect extends OneShotEffect { - + private static final FilterCard filter = new FilterCard("an artifact, creature, enchantment, or land card"); - + static { filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE), @@ -101,13 +100,13 @@ class EternalDominionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { boolean applied = false; Player opponent = game.getPlayer(source.getFirstTarget()); - Player you = game.getPlayer(source.getControllerId()); - if (opponent != null && you != null) { + Player controller = game.getPlayer(source.getControllerId()); + if (opponent != null && controller != null) { TargetCardInLibrary target = new TargetCardInLibrary(filter); - you.searchLibrary(target, game, opponent.getId()); + controller.searchLibrary(target, game, opponent.getId()); Card targetCard = game.getCard(target.getFirstTarget()); if (targetCard != null) { - applied = you.putOntoBattlefieldWithInfo(targetCard, game, Zone.LIBRARY, source.getSourceId()); + applied = controller.moveCards(targetCard, Zone.BATTLEFIELD, source, game); } opponent.shuffleLibrary(game); } diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/FootstepsOfTheGoryo.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/FootstepsOfTheGoryo.java index 1e3be38179f..1fe60da5cad 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/FootstepsOfTheGoryo.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/FootstepsOfTheGoryo.java @@ -28,7 +28,6 @@ package mage.sets.saviorsofkamigawa; import java.util.UUID; - import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; @@ -37,7 +36,10 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.SacrificeTargetEffect; import mage.cards.Card; import mage.cards.CardImpl; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.game.Game; import mage.game.permanent.Permanent; @@ -93,7 +95,7 @@ class FootstepsOfTheGoryoEffect extends OneShotEffect { if (controller != null) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { // Sacrifice it at end of turn @@ -104,11 +106,10 @@ class FootstepsOfTheGoryoEffect extends OneShotEffect { delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setSourceObject(source.getSourceObject(game), game); game.addDelayedTriggeredAbility(delayedAbility); - return true; - } } } + return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java b/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java index 690b42690dd..de9ede0bc2d 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/ImpromptuRaid.java @@ -117,7 +117,7 @@ class ImpromptuRaidEffect extends OneShotEffect { controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game); return true; } - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); diff --git a/Mage.Sets/src/mage/sets/shadowmoor/PuppeteerClique.java b/Mage.Sets/src/mage/sets/shadowmoor/PuppeteerClique.java index 3fb47b66b54..c0568cfaf3a 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/PuppeteerClique.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/PuppeteerClique.java @@ -116,16 +116,16 @@ class PuppeteerCliqueEffect extends OneShotEffect { boolean result = false; Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { - Player you = game.getPlayer(source.getControllerId()); - if (you != null) { - if (you.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); - hasteEffect.setTargetPointer(new FixedTarget(permanent.getId())); + hasteEffect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(hasteEffect, source); ExileTargetEffect exileEffect = new ExileTargetEffect("exile " + permanent.getLogName()); - exileEffect.setTargetPointer(new FixedTarget(card.getId())); + exileEffect.setTargetPointer(new FixedTarget(permanent, game)); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU); delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setControllerId(source.getControllerId()); diff --git a/Mage.Sets/src/mage/sets/shardsofalara/TezzeretTheSeeker.java b/Mage.Sets/src/mage/sets/shardsofalara/TezzeretTheSeeker.java index af865ed4cee..d4a44c46efb 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/TezzeretTheSeeker.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/TezzeretTheSeeker.java @@ -107,8 +107,8 @@ class TezzeretTheSeekerEffect2 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) { return false; } @@ -123,15 +123,15 @@ class TezzeretTheSeekerEffect2 extends OneShotEffect { filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, cmc + 1)); TargetCardInLibrary target = new TargetCardInLibrary(filter); - if (player.searchLibrary(target, game)) { - Card card = player.getLibrary().getCard(target.getFirstTarget(), game); + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return true; } - player.shuffleLibrary(game); + controller.shuffleLibrary(game); return false; } } diff --git a/Mage.Sets/src/mage/sets/tempest/CorpseDance.java b/Mage.Sets/src/mage/sets/tempest/CorpseDance.java index a7589fdc5c7..0087bb59d0c 100644 --- a/Mage.Sets/src/mage/sets/tempest/CorpseDance.java +++ b/Mage.Sets/src/mage/sets/tempest/CorpseDance.java @@ -45,6 +45,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; @@ -58,7 +59,6 @@ public class CorpseDance extends CardImpl { super(ownerId, 10, "Corpse Dance", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{B}"); this.expansionSetCode = "TMP"; - // Buyback {2} this.addAbility(new BuybackAbility("{2}")); @@ -97,26 +97,29 @@ class CorpseDanceEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card lastCreatureCard = null; - for (Card card :controller.getGraveyard().getCards(game)) { + for (Card card : controller.getGraveyard().getCards(game)) { if (card.getCardType().contains(CardType.CREATURE)) { lastCreatureCard = card; } } if (lastCreatureCard != null) { - if (controller.putOntoBattlefieldWithInfo(lastCreatureCard, game, Zone.GRAVEYARD, source.getSourceId())) { - FixedTarget fixedTarget = new FixedTarget(lastCreatureCard.getId()); - // Gains Haste - ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); - hasteEffect.setTargetPointer(fixedTarget); - game.addEffect(hasteEffect, source); - // Exile it at end of turn - ExileTargetEffect exileEffect = new ExileTargetEffect(null,"",Zone.BATTLEFIELD); - exileEffect.setTargetPointer(fixedTarget); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + if (controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game)) { + Permanent creature = game.getPermanent(lastCreatureCard.getId()); + if (creature != null) { + FixedTarget fixedTarget = new FixedTarget(creature, game); + // Gains Haste + ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); + hasteEffect.setTargetPointer(fixedTarget); + game.addEffect(hasteEffect, source); + // Exile it at end of turn + ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); + exileEffect.setTargetPointer(fixedTarget); + DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); + delayedAbility.setSourceId(source.getSourceId()); + delayedAbility.setControllerId(source.getControllerId()); + delayedAbility.setSourceObject(source.getSourceObject(game), game); + game.addDelayedTriggeredAbility(delayedAbility); + } } } return true; diff --git a/Mage.Sets/src/mage/sets/tempest/LivingDeath.java b/Mage.Sets/src/mage/sets/tempest/LivingDeath.java index f3c071223d2..1980018d64a 100644 --- a/Mage.Sets/src/mage/sets/tempest/LivingDeath.java +++ b/Mage.Sets/src/mage/sets/tempest/LivingDeath.java @@ -27,6 +27,9 @@ */ package mage.sets.tempest; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; @@ -39,7 +42,6 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; -import mage.game.ExileZone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -89,27 +91,31 @@ class LivingDeathEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { + Map> exiledCards = new HashMap<>(); // move creature cards from graveyard to exile - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getGraveyard().getCards(new FilterCreatureCard(), game)) { - controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true); + Set cardsPlayer = player.getGraveyard().getCards(new FilterCreatureCard(), game); + if (!cardsPlayer.isEmpty()) { + exiledCards.put(player.getId(), cardsPlayer); + player.moveCards(cardsPlayer, Zone.EXILED, source, game); } } } + game.applyEffects(); // sacrifice all creatures for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { permanent.sacrifice(source.getSourceId(), game); } + game.applyEffects(); // put exiled cards to battlefield - ExileZone exileZone = game.getState().getExile().getExileZone(source.getSourceId()); - if (exileZone != null) { - for (Card card : exileZone.getCards(game)) { - Player player = game.getPlayer(card.getOwnerId()); - if (player != null) { - player.moveCards(card, Zone.EXILED, source, game); - player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + Set cardsPlayer = exiledCards.get(playerId); + if (cardsPlayer != null && !cardsPlayer.isEmpty()) { + player.moveCards(cardsPlayer, Zone.BATTLEFIELD, source, game, false, false, false, null); } } } diff --git a/Mage.Sets/src/mage/sets/tempest/StaunchDefenders.java b/Mage.Sets/src/mage/sets/tempest/StaunchDefenders.java index 39fe7dbece7..cfaeaa21ead 100644 --- a/Mage.Sets/src/mage/sets/tempest/StaunchDefenders.java +++ b/Mage.Sets/src/mage/sets/tempest/StaunchDefenders.java @@ -28,12 +28,12 @@ package mage.sets.tempest; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; /** * @@ -49,6 +49,8 @@ public class StaunchDefenders extends CardImpl { this.power = new MageInt(3); this.toughness = new MageInt(4); + + // When Staunch Defenders enters the battlefield, you gain 4 life. this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(4), false)); } diff --git a/Mage.Sets/src/mage/sets/tenthedition/AcademyResearchers.java b/Mage.Sets/src/mage/sets/tenthedition/AcademyResearchers.java index febe7582f76..f3d2fec5dd3 100644 --- a/Mage.Sets/src/mage/sets/tenthedition/AcademyResearchers.java +++ b/Mage.Sets/src/mage/sets/tenthedition/AcademyResearchers.java @@ -76,35 +76,35 @@ public class AcademyResearchers extends CardImpl { } class AcademyResearchersEffect extends OneShotEffect { - + AcademyResearchersEffect() { super(Outcome.PutCardInPlay); this.staticText = "you may put an Aura card from your hand onto the battlefield attached to {this}."; } - + AcademyResearchersEffect(final AcademyResearchersEffect effect) { super(effect); } - + @Override public AcademyResearchersEffect copy() { return new AcademyResearchersEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); - if (player != null && permanent != null){ + if (controller != null && permanent != null) { FilterCard filter = new FilterCard(); filter.add(new SubtypePredicate("Aura")); filter.add(new AuraCardCanAttachToPermanentId(permanent.getId())); TargetCardInHand target = new TargetCardInHand(0, 1, filter); - if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { Card auraInHand = game.getCard(target.getFirstTarget()); if (auraInHand != null) { game.getState().setValue("attachTo:" + auraInHand.getId(), permanent); - if (player.putOntoBattlefieldWithInfo(auraInHand, game, Zone.HAND, source.getSourceId())) { + if (controller.moveCards(auraInHand, Zone.BATTLEFIELD, source, game)) { permanent.addAttachment(auraInHand.getId(), game); } } diff --git a/Mage.Sets/src/mage/sets/theros/AshiokNightmareWeaver.java b/Mage.Sets/src/mage/sets/theros/AshiokNightmareWeaver.java index 18d2eaee092..f9749475e70 100644 --- a/Mage.Sets/src/mage/sets/theros/AshiokNightmareWeaver.java +++ b/Mage.Sets/src/mage/sets/theros/AshiokNightmareWeaver.java @@ -167,16 +167,14 @@ class AshiokNightmareWeaverPutIntoPlayEffect extends OneShotEffect { if (target.canChoose(source.getSourceId(), controller.getId(), game)) { if (controller.chooseTarget(Outcome.PutCreatureInPlay, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); - if (card != null && controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) { - // why is this change of controller neccessary? + if (card != null + && controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { - permanent.changeControllerId(source.getControllerId(), game); + ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect(); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addEffect(effect, source); } - - ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect(); - effect.setTargetPointer(new FixedTarget(card.getId())); - game.addEffect(effect, source); return true; } } diff --git a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java index 3b1e6e3e836..ae89cc24db2 100644 --- a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java +++ b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java @@ -39,6 +39,8 @@ import mage.abilities.costs.mana.GenericManaCost; 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; @@ -161,8 +163,8 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { } else { return true; } - - for (UUID playerId : controller.getInRange()) { + Cards cardsToBringIntoPlay = new CardsImpl(); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { String exileKey = playerId.toString() + CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()).toString(); @@ -173,13 +175,14 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { for (Card card : exileZone.getCards(game)) { card.setFaceDown(false, game); if (CardUtil.isPermanentCard(card)) { - player.moveCards(card, Zone.EXILED, source, game); + cardsToBringIntoPlay.add(card); } } } } } } + controller.moveCards(cardsToBringIntoPlay.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java b/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java index 6b345fdd021..8d9dd84c469 100644 --- a/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java +++ b/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java @@ -115,19 +115,22 @@ class WhipOfErebosEffect extends OneShotEffect { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && card != null) { - if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) { - // gains haste - ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); - effect.setTargetPointer(new FixedTarget(card.getId())); - game.addEffect(effect, source); - // Exile at begin of next end step - ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD); - exileEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); - DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); - delayedAbility.setSourceId(source.getSourceId()); - delayedAbility.setControllerId(source.getControllerId()); - delayedAbility.setSourceObject(source.getSourceObject(game), game); - game.addDelayedTriggeredAbility(delayedAbility); + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { + Permanent creature = game.getPermanent(card.getId()); + if (creature != null) { + // gains haste + ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); + effect.setTargetPointer(new FixedTarget(creature, game)); + game.addEffect(effect, source); + // Exile at begin of next end step + ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD); + exileEffect.setTargetPointer(new FixedTarget(creature, game)); + DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect); + delayedAbility.setSourceId(source.getSourceId()); + delayedAbility.setControllerId(source.getControllerId()); + delayedAbility.setSourceObject(source.getSourceObject(game), game); + game.addDelayedTriggeredAbility(delayedAbility); + } } return true; } diff --git a/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java b/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java index cb9bcd6c965..8dca6413956 100644 --- a/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java +++ b/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java @@ -38,7 +38,6 @@ import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.keyword.HasteAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; import mage.cards.CardsImpl; @@ -179,28 +178,19 @@ class XenagosExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - Cards cards = new CardsImpl(Zone.EXILED); - int count = Math.min(player.getLibrary().size(), 7); - for (int i = 0; i < count; i++) { - Card card = player.getLibrary().getFromTop(game); - cards.add(card); - card.moveToExile(null, null, source.getSourceId(), game); - } + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Cards exiledCards = new CardsImpl(); + exiledCards.addAll(controller.getLibrary().getTopCards(game, 7)); + controller.moveCards(exiledCards, Zone.EXILED, source, game); FilterCard filter = new FilterCard("creature and/or land cards to put onto the battlefield"); filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND))); TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.EXILED, filter); - if (cards.size() > 0 + if (exiledCards.size() > 0 && target1.canChoose(source.getSourceId(), source.getControllerId(), game) - && player.choose(Outcome.PutCardInPlay, cards, target1, game)) { - for (UUID targetId : target1.getTargets()) { - Card card = cards.get(targetId, game); - if (card != null) { - player.moveCards(card, Zone.EXILED, source, game); - } - } + && controller.choose(Outcome.PutCardInPlay, exiledCards, target1, game)) { + controller.moveCards(new CardsImpl(target1.getTargets()), Zone.BATTLEFIELD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java b/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java index de93d360d5a..cf26eed618f 100644 --- a/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java +++ b/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java @@ -27,6 +27,9 @@ */ package mage.sets.timespiral; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; @@ -41,7 +44,6 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; -import mage.game.ExileZone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -97,12 +99,15 @@ class LivingEndEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { + Map> exiledCards = new HashMap<>(); // move creature cards from graveyard to exile - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getGraveyard().getCards(new FilterCreatureCard(), game)) { - controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true); + Set cardsPlayer = player.getGraveyard().getCards(new FilterCreatureCard(), game); + if (!cardsPlayer.isEmpty()) { + exiledCards.put(player.getId(), cardsPlayer); + player.moveCards(cardsPlayer, Zone.EXILED, source, game); } } } @@ -111,12 +116,12 @@ class LivingEndEffect extends OneShotEffect { permanent.sacrifice(source.getSourceId(), game); } // put exiled cards to battlefield - ExileZone exileZone = game.getState().getExile().getExileZone(source.getSourceId()); - if (exileZone != null) { - for (Card card : exileZone.getCards(game)) { - Player player = game.getPlayer(card.getOwnerId()); - if (player != null) { - player.moveCards(card, Zone.EXILED, source, game); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + Set cardsPlayer = exiledCards.get(playerId); + if (cardsPlayer != null && !cardsPlayer.isEmpty()) { + player.moveCards(cardsPlayer, Zone.BATTLEFIELD, source, game, false, false, false, null); } } } diff --git a/Mage.Sets/src/mage/sets/urzasdestiny/Gamekeeper.java b/Mage.Sets/src/mage/sets/urzasdestiny/Gamekeeper.java index 71b6e21e76b..060dd763312 100644 --- a/Mage.Sets/src/mage/sets/urzasdestiny/Gamekeeper.java +++ b/Mage.Sets/src/mage/sets/urzasdestiny/Gamekeeper.java @@ -77,8 +77,6 @@ public class Gamekeeper extends CardImpl { class GamekeeperEffect extends OneShotEffect { - - public GamekeeperEffect() { super(Outcome.Benefit); staticText = "reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and put all other cards revealed this way into your graveyard"; @@ -98,15 +96,13 @@ class GamekeeperEffect extends OneShotEffect { while (controller.getLibrary().size() > 0) { Card card = controller.getLibrary().removeFromTop(game); if (card.getCardType().contains(CardType.CREATURE)) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); break; } revealedCards.add(card); } - controller.revealCards("Gamekeeper", revealedCards, game); - for (Card card: revealedCards.getCards(game)) { - card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true); - } + controller.revealCards(sourceObject.getIdName(), revealedCards, game); + controller.moveCards(revealedCards, Zone.GRAVEYARD, source, game); return true; } return false; @@ -116,4 +112,4 @@ class GamekeeperEffect extends OneShotEffect { public GamekeeperEffect copy() { return new GamekeeperEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/urzasdestiny/Replenish.java b/Mage.Sets/src/mage/sets/urzasdestiny/Replenish.java index ec46d722ec8..217f77fb07c 100644 --- a/Mage.Sets/src/mage/sets/urzasdestiny/Replenish.java +++ b/Mage.Sets/src/mage/sets/urzasdestiny/Replenish.java @@ -27,17 +27,15 @@ */ package mage.sets.urzasdestiny; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; +import mage.filter.common.FilterEnchantmentCard; import mage.game.Game; import mage.players.Player; @@ -51,7 +49,6 @@ public class Replenish extends CardImpl { super(ownerId, 15, "Replenish", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{W}"); this.expansionSetCode = "UDS"; - // Return all enchantment cards from your graveyard to the battlefield. this.getSpellAbility().addEffect(new ReplenishEffect()); } @@ -67,36 +64,27 @@ public class Replenish extends CardImpl { } class ReplenishEffect extends OneShotEffect { - + ReplenishEffect() { super(Outcome.PutCardInPlay); this.staticText = "Return all enchantment cards from your graveyard to the battlefield"; } - + ReplenishEffect(final ReplenishEffect effect) { super(effect); } - + @Override public ReplenishEffect copy() { return new ReplenishEffect(this); } - + @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - List cards = new ArrayList<>(0); - for (UUID cardId : player.getGraveyard()) { - Card card = game.getCard(cardId); - if (card != null && card.getCardType().contains(CardType.ENCHANTMENT)) { - cards.add(card); - } - } - for (Card card : cards) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); - } - return true; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + return controller.moveCards(controller.getGraveyard().getCards(new FilterEnchantmentCard(), source.getSourceId(), + source.getControllerId(), game), Zone.BATTLEFIELD, source, game); } return false; } diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/GoblinWelder.java b/Mage.Sets/src/mage/sets/urzaslegacy/GoblinWelder.java index d9ccd3e001c..a34a97f95e3 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/GoblinWelder.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/GoblinWelder.java @@ -30,7 +30,6 @@ package mage.sets.urzaslegacy; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.OneShotEffect; @@ -78,7 +77,6 @@ public class GoblinWelder extends CardImpl { public GoblinWelder copy() { return new GoblinWelder(this); } - public class GoblinWelderEffect extends OneShotEffect { @@ -87,7 +85,6 @@ public class GoblinWelder extends CardImpl { staticText = "Choose target artifact a player controls and target artifact card in that player's graveyard. If both targets are still legal as this ability resolves, that player simultaneously sacrifices the artifact and returns the artifact card to the battlefield"; } - public GoblinWelderEffect(final GoblinWelderEffect effect) { super(effect); } @@ -106,7 +103,7 @@ public class GoblinWelder extends CardImpl { && currentZone == Zone.GRAVEYARD && card.getOwnerId().equals(artifact.getControllerId())) { boolean sacrifice = artifact.sacrifice(source.getSourceId(), game); - boolean putOnBF = owner.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + boolean putOnBF = owner.moveCards(card, Zone.BATTLEFIELD, source, game); if (sacrifice || putOnBF) { return true; } @@ -121,7 +118,7 @@ public class GoblinWelder extends CardImpl { } } - + class GoblinWelderTarget extends TargetCardInGraveyard { public GoblinWelderTarget() { @@ -146,7 +143,6 @@ public class GoblinWelder extends CardImpl { } return false; } - @Override public GoblinWelderTarget copy() { diff --git a/Mage.Sets/src/mage/sets/urzassaga/CopperGnomes.java b/Mage.Sets/src/mage/sets/urzassaga/CopperGnomes.java index 2971de2eda7..145b521c5cb 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/CopperGnomes.java +++ b/Mage.Sets/src/mage/sets/urzassaga/CopperGnomes.java @@ -94,19 +94,18 @@ class PutArtifactOnBattlefieldEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null || !player.chooseUse(Outcome.PutCardInPlay, choiceText, source, game)) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null || !controller.chooseUse(Outcome.PutCardInPlay, choiceText, source, game)) { return false; } TargetCardInHand target = new TargetCardInHand(new FilterArtifactCard()); - if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); - return true; + return controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/urzassaga/Exhume.java b/Mage.Sets/src/mage/sets/urzassaga/Exhume.java index 4b853980dd8..6350318c19f 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/Exhume.java +++ b/Mage.Sets/src/mage/sets/urzassaga/Exhume.java @@ -52,7 +52,6 @@ public class Exhume extends CardImpl { super(ownerId, 134, "Exhume", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}"); this.expansionSetCode = "USG"; - // Each player puts a creature card from his or her graveyard onto the battlefield. this.getSpellAbility().addEffect(new ExhumeEffect()); } @@ -90,17 +89,17 @@ class ExhumeEffect extends OneShotEffect { return false; } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { FilterCreatureCard filterCreatureCard = new FilterCreatureCard("creature card from your graveyard"); filterCreatureCard.add(new OwnerIdPredicate(playerId)); TargetCardInGraveyard target = new TargetCardInGraveyard(filterCreatureCard); - if (target.canChoose(playerId, game) && - player.chooseTarget(outcome, target, source, game)) { + if (target.canChoose(playerId, game) + && player.chooseTarget(outcome, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + player.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/urzassaga/PlanarBirth.java b/Mage.Sets/src/mage/sets/urzassaga/PlanarBirth.java index fdd6644437e..7b298acc3d7 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/PlanarBirth.java +++ b/Mage.Sets/src/mage/sets/urzassaga/PlanarBirth.java @@ -30,8 +30,9 @@ package mage.sets.urzassaga; 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; @@ -65,33 +66,33 @@ public class PlanarBirth extends CardImpl { } class PlanarBirthEffect extends OneShotEffect { - + PlanarBirthEffect() { super(Outcome.PutLandInPlay); this.staticText = "Return all basic land cards from all graveyards to the battlefield tapped under their owners' control"; } - + PlanarBirthEffect(final PlanarBirthEffect effect) { super(effect); } - + @Override public PlanarBirthEffect copy() { return new PlanarBirthEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + Cards toBattlefield = new CardsImpl(); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card : player.getGraveyard().getCards(new FilterBasicLandCard(), source.getSourceId(), controller.getId(), game)) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), true); - } + toBattlefield.addAll(player.getGraveyard().getCards(new FilterBasicLandCard(), source.getSourceId(), controller.getId(), game)); } } + controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/urzassaga/SneakAttack.java b/Mage.Sets/src/mage/sets/urzassaga/SneakAttack.java index 3720511de42..4cb45d7a1fc 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/SneakAttack.java +++ b/Mage.Sets/src/mage/sets/urzassaga/SneakAttack.java @@ -96,14 +96,14 @@ class SneakAttackEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - if (player.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { TargetCardInHand target = new TargetCardInHand(new FilterCreatureCard()); - if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - if (player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) { + if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom); diff --git a/Mage.Sets/src/mage/sets/vintagemasters/ChaosWarp.java b/Mage.Sets/src/mage/sets/vintagemasters/ChaosWarp.java index 96230a129e5..d4e09af0c93 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/ChaosWarp.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/ChaosWarp.java @@ -35,20 +35,20 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; import mage.cards.CardsImpl; -import mage.players.Player; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; +import mage.filter.common.FilterPermanentCard; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.TargetPermanent; -import mage.filter.common.FilterPermanentCard; /** * * @author Mitchel Stein - * + * */ public class ChaosWarp extends CardImpl { @@ -56,14 +56,13 @@ public class ChaosWarp extends CardImpl { super(ownerId, 154, "Chaos Warp", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{R}"); this.expansionSetCode = "VMA"; - // The owner of target permanent shuffles it into his or her library, this.getSpellAbility().addEffect(new ChaosWarpShuffleIntoLibraryEffect()); this.getSpellAbility().addTarget(new TargetPermanent()); - //then reveals the top card of his or her library. + //then reveals the top card of his or her library. //If it's a permanent card, he or she puts it onto the battlefield. this.getSpellAbility().addEffect(new ChaosWarpRevealEffect()); - + } public ChaosWarp(final ChaosWarp card) { @@ -94,9 +93,9 @@ class ChaosWarpShuffleIntoLibraryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); + Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null) { - Player owner = game.getPlayer(permanent.getOwnerId()); + Player owner = game.getPlayer(permanent.getOwnerId()); if (owner != null) { owner.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true); owner.shuffleLibrary(game); @@ -108,10 +107,10 @@ class ChaosWarpShuffleIntoLibraryEffect extends OneShotEffect { } class ChaosWarpRevealEffect extends OneShotEffect { - -public ChaosWarpRevealEffect() { + + public ChaosWarpRevealEffect() { super(Outcome.PutCardInPlay); - this.staticText = "then reveals the top card of his or her library. If it's a permanent card, he or she puts it onto the battlefield."; + this.staticText = "then reveals the top card of his or her library. If it's a permanent card, he or she puts it onto the battlefield"; } public ChaosWarpRevealEffect(final ChaosWarpRevealEffect effect) { @@ -138,11 +137,10 @@ public ChaosWarpRevealEffect() { if (owner.getLibrary().size() > 0) { Card card = owner.getLibrary().getFromTop(game); if (card != null) { - Cards cards = new CardsImpl(); - cards.add(card); - owner.revealCards(sourceObject.getName(), cards, game); - if (new FilterPermanentCard().match(card, game)) { - owner.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + Cards cards = new CardsImpl(card); + owner.revealCards(sourceObject.getIdName(), cards, game); + if (new FilterPermanentCard().match(card, game)) { + owner.moveCards(card, Zone.BATTLEFIELD, source, game); } } } diff --git a/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java b/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java index c47f7887e12..d5dbfa28e5e 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java @@ -53,7 +53,6 @@ public class Eureka extends CardImpl { super(ownerId, 208, "Eureka", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{2}{G}{G}"); this.expansionSetCode = "VMA"; - // Starting with you, each player may put a permanent card from his or her hand onto the battlefield. Repeat this process until no one puts a card onto the battlefield. this.getSpellAbility().addEffect(new EurekaEffect()); } @@ -108,7 +107,7 @@ class EurekaEffect extends OneShotEffect { if (target.chooseTarget(outcome, currentPlayer.getId(), source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - currentPlayer.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); + currentPlayer.moveCards(card, Zone.BATTLEFIELD, source, game); firstInactivePlayer = null; } } diff --git a/Mage.Sets/src/mage/sets/vintagemasters/MistmoonGriffin.java b/Mage.Sets/src/mage/sets/vintagemasters/MistmoonGriffin.java index d6f979dca39..290f1681191 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/MistmoonGriffin.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/MistmoonGriffin.java @@ -97,13 +97,13 @@ class MistmoonGriffinEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card lastCreatureCard = null; - for (Card card :controller.getGraveyard().getCards(game)) { + for (Card card : controller.getGraveyard().getCards(game)) { if (card.getCardType().contains(CardType.CREATURE)) { lastCreatureCard = card; } } if (lastCreatureCard != null) { - return controller.putOntoBattlefieldWithInfo(lastCreatureCard, game, Zone.GRAVEYARD, source.getSourceId()); + return controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/visions/Necromancy.java b/Mage.Sets/src/mage/sets/visions/Necromancy.java index f109d320e53..89910cb3ab9 100644 --- a/Mage.Sets/src/mage/sets/visions/Necromancy.java +++ b/Mage.Sets/src/mage/sets/visions/Necromancy.java @@ -196,13 +196,11 @@ class NecromancyReAttachEffect extends OneShotEffect { Permanent enchantment = game.getPermanent(source.getSourceId()); Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source)); if (controller != null && enchantment != null && cardInGraveyard != null) { - // put card into play - controller.putOntoBattlefieldWithInfo(cardInGraveyard, game, Zone.GRAVEYARD, source.getSourceId()); + controller.moveCards(cardInGraveyard, Zone.BATTLEFIELD, source, game); Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId()); - if (enchantedCreature != null) { enchantedCreature.addAttachment(enchantment.getId(), game); - FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with Necromancy"); + FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with " + enchantment.getIdName()); filter.add(new PermanentIdPredicate(cardInGraveyard.getId())); Target target = new TargetCreaturePermanent(filter); target.addTarget(enchantedCreature.getId(), source, game); diff --git a/Mage.Sets/src/mage/sets/weatherlight/BoneDancer.java b/Mage.Sets/src/mage/sets/weatherlight/BoneDancer.java index 85d29071310..45c623b43b8 100644 --- a/Mage.Sets/src/mage/sets/weatherlight/BoneDancer.java +++ b/Mage.Sets/src/mage/sets/weatherlight/BoneDancer.java @@ -92,15 +92,15 @@ class BoneDancerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player defendingPlayer = game.getPlayer(targetPointer.getFirst(game, source)); - if(controller != null && defendingPlayer != null) { + if (controller != null && defendingPlayer != null) { Card lastCreatureCard = null; - for(Card card : defendingPlayer.getGraveyard().getCards(game)) { - if(card.getCardType().contains(CardType.CREATURE)) { + for (Card card : defendingPlayer.getGraveyard().getCards(game)) { + if (card.getCardType().contains(CardType.CREATURE)) { lastCreatureCard = card; } } - if(lastCreatureCard != null) { - return controller.putOntoBattlefieldWithInfo(lastCreatureCard, game, Zone.GRAVEYARD, source.getSourceId()); + if (lastCreatureCard != null) { + controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game); } return true; } diff --git a/Mage.Sets/src/mage/sets/worldwake/QuestForUlasTemple.java b/Mage.Sets/src/mage/sets/worldwake/QuestForUlasTemple.java index d4ae627af11..95eaa8a0b70 100644 --- a/Mage.Sets/src/mage/sets/worldwake/QuestForUlasTemple.java +++ b/Mage.Sets/src/mage/sets/worldwake/QuestForUlasTemple.java @@ -62,7 +62,6 @@ public class QuestForUlasTemple extends CardImpl { super(ownerId, 35, "Quest for Ula's Temple", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{U}"); this.expansionSetCode = "WWK"; - // At the beginning of your upkeep, you may look at the top card of your library. If it's a creature card, you may reveal it and put a quest counter on Quest for Ula's Temple. this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new QuestForUlasTempleEffect(), TargetController.YOU, true)); @@ -140,7 +139,7 @@ class QuestForUlasTempleTriggeredAbility extends TriggeredAbilityImpl { } @Override -public boolean checkTrigger(GameEvent event, Game game) { + public boolean checkTrigger(GameEvent event, Game game) { Permanent quest = game.getPermanent(super.getSourceId()); return quest != null && quest.getCounters().getCount(CounterType.QUEST) >= 3; } @@ -178,12 +177,10 @@ class QuestForUlasTempleEffect2 extends OneShotEffect { if (controller != null) { TargetCardInHand target = new TargetCardInHand(filter); if (target.canChoose(source.getSourceId(), controller.getId(), game) - &&controller.chooseUse(Outcome.PutCreatureInPlay, query, source, game)) { + && controller.chooseUse(Outcome.PutCreatureInPlay, query, source, game)) { if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); - } + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } return true; diff --git a/Mage.Sets/src/mage/sets/zendikar/SummoningTrap.java b/Mage.Sets/src/mage/sets/zendikar/SummoningTrap.java index e2fd1b88a42..61aa2805786 100644 --- a/Mage.Sets/src/mage/sets/zendikar/SummoningTrap.java +++ b/Mage.Sets/src/mage/sets/zendikar/SummoningTrap.java @@ -28,12 +28,6 @@ package mage.sets.zendikar; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.WatcherScope; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.costs.AlternativeCostImpl; import mage.abilities.costs.Cost; @@ -43,6 +37,11 @@ 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.WatcherScope; +import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.game.Game; import mage.game.events.GameEvent; @@ -179,7 +178,7 @@ class SummoningTrapEffect extends OneShotEffect { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { cards.remove(card); - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId()); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } if (cards.size() > 0) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/PersistTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/PersistTest.java index e8fcc2a4487..85a451e4298 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/PersistTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/PersistTest.java @@ -195,8 +195,7 @@ public class PersistTest extends CardTestPlayerBase { assertPermanentCount(playerB, "Glen Elendra Archmage", 1); assertPowerToughness(playerB, "Glen Elendra Archmage", 1, 1); - assertPermanentCount(playerA, "Glen Elendra Archmage", 1); - assertPowerToughness(playerA, "Glen Elendra Archmage", 1, 1); + assertGraveyardCount(playerA, "Clever Impersonator", 1); } @Test diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java index 31fc57868bf..058b5e5bed1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/UndyingTest.java @@ -2,6 +2,7 @@ package org.mage.test.cards.abilities.keywords; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.counters.CounterType; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -238,7 +239,8 @@ public class UndyingTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Tatterkite", 1); assertPermanentCount(playerA, "Mikaeus, the Unhallowed", 1); - assertPowerToughness(playerA, "Tatterkite", 3, 2); + assertCounterCount("Tatterkite", CounterType.P1P1, 1); + assertPowerToughness(playerA, "Tatterkite", 4, 3); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/OathOfLiegesTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/OathOfLiegesTest.java index 2ad4dc07a44..df0c508f1e2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/OathOfLiegesTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/enchantments/OathOfLiegesTest.java @@ -78,6 +78,7 @@ public class OathOfLiegesTest extends CardTestPlayerBase { execute(); assertPermanentCount(playerA, "Oath of Lieges", 1); + assertPermanentCount(playerA, "Plains", 2); assertPermanentCount(playerB, "Plains", 2); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java index db1557a3bd4..f21dade9e3c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/WorldgorgerDragonTest.java @@ -5,7 +5,6 @@ */ package org.mage.test.cards.triggers; - import mage.constants.PhaseStep; import mage.constants.Zone; import org.junit.Assert; @@ -16,7 +15,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - public class WorldgorgerDragonTest extends CardTestPlayerBase { /** @@ -25,20 +23,23 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { @Test public void testDisabledEffectOnChangeZone() { addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6); + // Flying + // Trample + // When Worldgorger Dragon enters the battlefield, exile all other permanents you control. + // When Worldgorger Dragon leaves the battlefield, return the exiled cards to the battlefield under their owners' control. addCard(Zone.HAND, playerA, "Worldgorger Dragon"); - + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); addCard(Zone.BATTLEFIELD, playerA, "Gerrard's Battle Cry", 1); - + addCard(Zone.BATTLEFIELD, playerB, "Swamp", 2); // Destroy target nonartifact, nonblack creature. It can't be regenerated. addCard(Zone.HAND, playerB, "Terror", 1); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Worldgorger Dragon"); - + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Terror", "Worldgorger Dragon"); - + setStopAt(2, PhaseStep.BEGIN_COMBAT); execute(); @@ -47,30 +48,35 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { assertGraveyardCount(playerA, "Worldgorger Dragon", 1); assertGraveyardCount(playerB, "Terror", 1); - + assertPermanentCount(playerA, "Silvercoat Lion", 1); assertPermanentCount(playerA, "Gerrard's Battle Cry", 1); - + } - /** - 1. Cast Animate Dead, targeting the Dragon - 2. Dragon comes into play, it's ability goes on the stack. - 3. The ability resolves, and all my other permanents leave play - 4. Since Animate Dead left play, Dragon goes to the graveyard - 5. Since the Dragon left play, the land and Animate Dead return to play. Animate Dead triggers, targeting the Dragon. - 6. In response to Animate Dead's ability going on the stack, tap the lands for mana. - 7. Animate Dead resolves, Dragon comes into play, everything else leaves play. - 8. Steps 4-7 repeat endlessly. Your mana pool fills. - 9. You can interrupt the sequence to play an instant. + /* + * 1. Cast Animate Dead, targeting the Dragon + * 2. Dragon comes into play, it's ability goes on the stack. + * 3. The ability resolves, and all my other permanents leave play + * 4. Since Animate Dead left play, Dragon goes to the graveyard + * 5. Since the Dragon left play, the land and Animate Dead return to play. Animate Dead triggers, targeting the Dragon. + * 6. In response to Animate Dead's ability going on the stack, tap the lands for mana. + * 7. Animate Dead resolves, Dragon comes into play, everything else leaves play. + * 8. Steps 4-7 repeat endlessly. Your mana pool fills. + * 9. You can interrupt the sequence to play an instant. */ @Test public void testWithAnimateDead() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); - + // When Worldgorger Dragon enters the battlefield, exile all other permanents you control. // When Worldgorger Dragon leaves the battlefield, return the exiled cards to the battlefield under their owners' control. addCard(Zone.GRAVEYARD, playerA, "Worldgorger Dragon", 1); + // Enchant creature card in a graveyard + // When Animate Dead enters the battlefield, if it's on the battlefield, it loses "enchant creature card in a graveyard" + // and gains "enchant creature put onto the battlefield with Animate Dead." Return enchanted creature card to the battlefield + // under your control and attach Animate Dead to it. When Animate Dead leaves the battlefield, that creature's controller sacrifices it. + // Enchanted creature gets -1/-0. addCard(Zone.HAND, playerA, "Animate Dead"); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); // Instant {X}{R}{R} @@ -78,10 +84,9 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { addCard(Zone.HAND, playerA, "Volcanic Geyser", 1); // When Staunch Defenders enters the battlefield, you gain 4 life. addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon"); - + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); @@ -107,43 +112,44 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 22); setChoice(playerA, "X=20"); - + setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertLife(playerA, 20); + assertLife(playerA, 44); assertLife(playerB, 0); assertGraveyardCount(playerA, "Volcanic Geyser", 1); - + } - + /** - * v9: Worldgorger Dragon + Animate Dead is still acting up (yey complex rules interactions!). - * The first time you return Animate Dead from Worldgorger's exile, it works like it's supposed - * to. You have to pick a creature, and it brings it back. But if you pick Worldgorger Dragon - * again, it allows you to not pick a creature, and regardless of whether you choose to skip or pick - * a different creature, it always returns the first creature you picked. Kind of hard to explain, - * but here's how to reproduce: - * - * 1) Cast Animate Dead, targeting Worldgorger Dragon - * 2) Worldgorger Dragon will exile Animate Dead, killing the dragon and returning the permanents - * 3) Select Worldgorger again - * 4) Step 2 repeats - * 5) Attempt to select a different creature. Worldgorger Dragon is returned instead. - * + * v9: Worldgorger Dragon + Animate Dead is still acting up (yey complex + * rules interactions!). The first time you return Animate Dead from + * Worldgorger's exile, it works like it's supposed to. You have to pick a + * creature, and it brings it back. But if you pick Worldgorger Dragon + * again, it allows you to not pick a creature, and regardless of whether + * you choose to skip or pick a different creature, it always returns the + * first creature you picked. Kind of hard to explain, but here's how to + * reproduce: + * + * 1) Cast Animate Dead, targeting Worldgorger Dragon 2) Worldgorger Dragon + * will exile Animate Dead, killing the dragon and returning the permanents + * 3) Select Worldgorger again 4) Step 2 repeats 5) Attempt to select a + * different creature. Worldgorger Dragon is returned instead. + * */ @Test public void testWithAnimateDeadDifferentTargets() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); - + // When Worldgorger Dragon enters the battlefield, exile all other permanents you control. // When Worldgorger Dragon leaves the battlefield, return the exiled cards to the battlefield under their owners' control. addCard(Zone.GRAVEYARD, playerA, "Worldgorger Dragon", 1); addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion", 1); - // When Animate Dead enters the battlefield, if it's on the battlefield, it loses "enchant creature card in a graveyard" - // and gains "enchant creature put onto the battlefield with Animate Dead." Return enchanted creature card to the battlefield + // When Animate Dead enters the battlefield, if it's on the battlefield, it loses "enchant creature card in a graveyard" + // and gains "enchant creature put onto the battlefield with Animate Dead." Return enchanted creature card to the battlefield // under your control and attach Animate Dead to it. When Animate Dead leaves the battlefield, that creature's controller sacrifices it. addCard(Zone.HAND, playerA, "Animate Dead"); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); @@ -152,43 +158,42 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase { addCard(Zone.HAND, playerA, "Volcanic Geyser", 1); // When Staunch Defenders enters the battlefield, you gain 4 life. addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1); - + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); setChoice(playerA, "Worldgorger Dragon"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); setChoice(playerA, "Silvercoat Lion"); - activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); - - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 9); + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 9); setChoice(playerA, "X=9"); - + setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); assertGraveyardCount(playerA, "Volcanic Geyser", 1); - assertGraveyardCount(playerA, "Worldgorger Dragon", 1); + assertGraveyardCount(playerA, "Worldgorger Dragon", 1); assertPermanentCount(playerA, "Silvercoat Lion", 1); - + assertLife(playerA, 28); assertLife(playerB, 11); Assert.assertEquals("Mana pool", "[]", playerA.getManaAvailable(currentGame).toString()); - } - -} \ No newline at end of file + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 702e99ba355..2f80da8fa0d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -1799,21 +1799,6 @@ public class TestPlayer implements Player { return computerPlayer.moveCardToExileWithInfo(card, exileId, exileName, sourceId, game, fromZone, withName); } - @Override - public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) { - return computerPlayer.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId); - } - - @Override - public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped) { - return computerPlayer.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, tapped); - } - - @Override - public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped, boolean facedown) { - return computerPlayer.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, tapped, facedown); - } - @Override public boolean hasOpponent(UUID playerToCheckId, Game game) { return computerPlayer.hasOpponent(playerToCheckId, game); diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 619a400685d..d7b581515ba 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -952,16 +952,15 @@ public abstract class AbilityImpl implements Ability { // for singleton abilities like Flying we can't rely on abilities' source because it's only once in continuous effects // so will use the sourceId of the object itself that came as a parameter if it is not null if (object == null) { - object = game.getObject(getSourceId()); + object = game.getPermanentEntering(getSourceId()); + if (object == null) { + object = game.getObject(getSourceId()); + } } if (object != null && !object.getAbilities().contains(this)) { if (object instanceof Permanent) { return false; } else { - Permanent permanent = game.getPermanentEntering(getSourceId()); - if (permanent != null && permanent.getAbilities().contains(this)) { - return true; - } // check if it's an ability that is temporary gained to a card Abilities otherAbilities = game.getState().getAllOtherAbilities(this.getSourceId()); if (otherAbilities == null || !otherAbilities.contains(this)) { diff --git a/Mage/src/mage/abilities/effects/common/CopyPermanentEffect.java b/Mage/src/mage/abilities/effects/common/CopyPermanentEffect.java index bf1ef297244..865adb292e8 100644 --- a/Mage/src/mage/abilities/effects/common/CopyPermanentEffect.java +++ b/Mage/src/mage/abilities/effects/common/CopyPermanentEffect.java @@ -98,7 +98,7 @@ public class CopyPermanentEffect extends OneShotEffect { } else { Target target = new TargetPermanent(filter); target.setNotTarget(true); - if (target.canChoose(source.getControllerId(), game)) { + if (target.canChoose(source.getSourceId(), player.getId(), game)) { player.choose(Outcome.Copy, target, source.getSourceId(), game); copyFromPermanent = game.getPermanent(target.getFirstTarget()); } diff --git a/Mage/src/mage/abilities/effects/common/PutLandFromHandOntoBattlefieldEffect.java b/Mage/src/mage/abilities/effects/common/PutLandFromHandOntoBattlefieldEffect.java index 8d819291cc3..c08da1ba5b3 100644 --- a/Mage/src/mage/abilities/effects/common/PutLandFromHandOntoBattlefieldEffect.java +++ b/Mage/src/mage/abilities/effects/common/PutLandFromHandOntoBattlefieldEffect.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; import mage.abilities.Ability; @@ -50,10 +49,11 @@ public class PutLandFromHandOntoBattlefieldEffect extends OneShotEffect { public PutLandFromHandOntoBattlefieldEffect() { this(false); } + public PutLandFromHandOntoBattlefieldEffect(boolean tapped) { super(Outcome.PutLandInPlay); this.tapped = tapped; - staticText = "you may put a land card from your hand onto the battlefield" + (tapped ? " tapped":""); + staticText = "you may put a land card from your hand onto the battlefield" + (tapped ? " tapped" : ""); } public PutLandFromHandOntoBattlefieldEffect(final PutLandFromHandOntoBattlefieldEffect effect) { @@ -66,12 +66,12 @@ public class PutLandFromHandOntoBattlefieldEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Target target = new TargetCardInHand(new FilterLandCard("land card")); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && - controller.chooseUse(outcome, "Put land onto battlefield?", source, game) && - controller.choose(outcome, target, source.getSourceId(), game)) { + if (target.canChoose(source.getSourceId(), source.getControllerId(), game) + && controller.chooseUse(outcome, "Put land onto battlefield?", source, game) + && controller.choose(outcome, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), tapped); + controller.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null); } } return true; @@ -85,4 +85,4 @@ public class PutLandFromHandOntoBattlefieldEffect extends OneShotEffect { return new PutLandFromHandOntoBattlefieldEffect(this); } - } +} diff --git a/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java b/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java index a87f0360ff8..a1c3ebe28ab 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToBattlefieldEffect.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,19 +20,18 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -54,6 +53,7 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect this.tapped = tapped; setText(); } + public ReturnSourceFromGraveyardToBattlefieldEffect(boolean tapped, boolean ownerControl) { super(Outcome.PutCreatureInPlay); this.tapped = tapped; @@ -76,32 +76,31 @@ public class ReturnSourceFromGraveyardToBattlefieldEffect extends OneShotEffect public boolean apply(Game game, Ability source) { if (!game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) { return false; - } + } Card card = game.getCard(source.getSourceId()); if (card == null) { return false; } - - Player player; + + Player player; if (ownerControl) { player = game.getPlayer(card.getOwnerId()); } else { player = game.getPlayer(source.getControllerId()); - } - if (player == null) { + } + if (player == null) { return false; - } - - return player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), tapped); + } + return player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, true, null); } private void setText() { StringBuilder sb = new StringBuilder("return {this} from your graveyard to the battlefield"); if (tapped) { sb.append(" tapped"); - } + } if (ownerControl) { - sb.append(" under its owner's control"); + sb.append(" under its owner's control"); } staticText = sb.toString(); } diff --git a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayEffect.java b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayEffect.java index 6776adcc8ea..c92cbb7540e 100644 --- a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayEffect.java +++ b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayEffect.java @@ -1,38 +1,37 @@ /* -* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are -* permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list -* of conditions and the following disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The views and conclusions contained in the software and documentation are those of the -* authors and should not be interpreted as representing official policies, either expressed -* or implied, of BetaSteward_at_googlemail.com. -*/ - + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ package mage.abilities.effects.common.search; import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.SearchEffect; -import mage.cards.Card; +import mage.cards.CardsImpl; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; @@ -90,12 +89,8 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect { } if (player.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { - for (UUID cardId: target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), tapped); - } - } + player.moveCards(new CardsImpl(target.getTargets()).getCards(game), + Zone.BATTLEFIELD, source, game, true, false, false, null); } player.shuffleLibrary(game); return true; @@ -110,15 +105,13 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect { StringBuilder sb = new StringBuilder(); sb.append("search your library for "); if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) { - if ( target.getMaxNumberOfTargets() == Integer.MAX_VALUE ) { + if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) { sb.append("any number of ").append(" "); - } - else { + } else { sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" "); } sb.append(target.getTargetName()).append(" and put them onto the battlefield"); - } - else { + } else { sb.append("a ").append(target.getTargetName()).append(" and put it onto the battlefield"); } if (tapped) { @@ -126,8 +119,7 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect { } if (forceShuffle) { sb.append(". Then shuffle your library"); - } - else { + } else { sb.append(". If you do, shuffle your library"); } staticText = sb.toString(); diff --git a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java index 74cf05fbe9f..8c68601cb38 100644 --- a/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java +++ b/Mage/src/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.SearchEffect; -import mage.cards.Card; +import mage.cards.CardsImpl; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; @@ -20,11 +20,11 @@ import mage.target.common.TargetCardInLibrary; * * @author LevelX2 */ - public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { protected boolean tapped; protected boolean forceShuffle; + protected boolean ownerIsController; public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target) { this(target, false, true, Outcome.PutCardInPlay); @@ -43,9 +43,14 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { } public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome) { + this(target, tapped, forceShuffle, outcome, false); + } + + public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome, boolean ownerIsController) { super(target, outcome); this.tapped = tapped; this.forceShuffle = forceShuffle; + this.ownerIsController = ownerIsController; setText(); } @@ -53,6 +58,7 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { super(effect); this.tapped = effect.tapped; this.forceShuffle = effect.forceShuffle; + this.ownerIsController = effect.ownerIsController; } @Override @@ -62,26 +68,22 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player != null) { if (player.searchLibrary(target, game)) { if (target.getTargets().size() > 0) { - for (UUID cardId: target.getTargets()) { - Card card = player.getLibrary().getCard(cardId, game); - if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), tapped); - } - } + player.moveCards(new CardsImpl(target.getTargets()).getCards(game), + Zone.BATTLEFIELD, source, game, tapped, false, ownerIsController, null); } player.shuffleLibrary(game); return true; } - + if (forceShuffle) { player.shuffleLibrary(game); } } - + return false; } @@ -89,15 +91,13 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { StringBuilder sb = new StringBuilder(); sb.append("target player searches his or her library for "); if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) { - if ( target.getMaxNumberOfTargets() == Integer.MAX_VALUE ) { + if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) { sb.append("any number of ").append(" "); - } - else { + } else { sb.append("up to ").append(target.getMaxNumberOfTargets()).append(" "); } sb.append(target.getTargetName()).append(" and put them onto the battlefield"); - } - else { + } else { sb.append("a ").append(target.getTargetName()).append(" and put it onto the battlefield"); } if (tapped) { @@ -105,8 +105,7 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { } if (forceShuffle) { sb.append(". Then that player shuffles his or her library"); - } - else { + } else { sb.append(". If that player does, he or she shuffles his or her library"); } staticText = sb.toString(); diff --git a/Mage/src/mage/abilities/effects/keyword/ManifestEffect.java b/Mage/src/mage/abilities/effects/keyword/ManifestEffect.java index 71e6293628d..0640fc8ed85 100644 --- a/Mage/src/mage/abilities/effects/keyword/ManifestEffect.java +++ b/Mage/src/mage/abilities/effects/keyword/ManifestEffect.java @@ -86,13 +86,15 @@ public class ManifestEffect extends OneShotEffect { } MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); - controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true); + + } + controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null); + for (Card card : cards) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { permanent.setManifested(true); } } - game.applyEffects(); // to apply before ETB triggered or replace Effects are executed return true; } return false; diff --git a/Mage/src/mage/abilities/effects/keyword/ManifestTargetPlayerEffect.java b/Mage/src/mage/abilities/effects/keyword/ManifestTargetPlayerEffect.java index 897ff83f235..2e904878769 100644 --- a/Mage/src/mage/abilities/effects/keyword/ManifestTargetPlayerEffect.java +++ b/Mage/src/mage/abilities/effects/keyword/ManifestTargetPlayerEffect.java @@ -89,7 +89,9 @@ public class ManifestTargetPlayerEffect extends OneShotEffect { } MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); - targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true); + } + targetPlayer.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null); + for (Card card : cards) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { permanent.setManifested(true); diff --git a/Mage/src/mage/cards/repository/CardRepository.java b/Mage/src/mage/cards/repository/CardRepository.java index 0605160f496..ab5ff527376 100644 --- a/Mage/src/mage/cards/repository/CardRepository.java +++ b/Mage/src/mage/cards/repository/CardRepository.java @@ -61,7 +61,7 @@ public enum CardRepository { private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE"; private static final String VERSION_ENTITY_NAME = "card"; // raise this if db structure was changed - private static final long CARD_DB_VERSION = 41; + private static final long CARD_DB_VERSION = 42; // raise this if new cards were added to the server private static final long CARD_CONTENT_VERSION = 40; diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 60edef58aba..7cfa4444370 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -741,46 +741,6 @@ public interface Player extends MageItem, Copyable { */ boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName); - /** - * Uses putOntoBattlefield and posts also a info message about in the game - * log - * - * @param card - * @param game - * @param fromZone - * @param sourceId - * @return - */ - @Deprecated - boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId); - - /** - * Uses putOntoBattlefield and posts also a info message about in the game - * log - * - * @param card - * @param game - * @param fromZone - * @param sourceId - * @param tapped the card enters the battlefield tapped - * @return - */ - boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped); - - /** - * Uses putOntoBattlefield and posts also a info message about in the game - * log - * - * @param card - * @param game - * @param fromZone - * @param sourceId - * @param tapped the card enters the battlefield tapped - * @param facedown the card enters the battlefield facedown - * @return - */ - boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped, boolean facedown); - /** * Checks if the playerToCheckId is from an opponent in range * diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 2330bd54541..80129822440 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -3025,7 +3025,7 @@ public abstract class PlayerImpl implements Player, Serializable { List permanents = new ArrayList<>(); List permanentsEntered = new ArrayList<>(); for (Card card : cards) { - UUID controllingPlayerId = byOwner ? card.getOwnerId() : source.getControllerId(); + UUID controllingPlayerId = byOwner ? card.getOwnerId() : getId(); fromZone = game.getState().getZone(card.getId()); if (faceDown) { card.setFaceDown(true, game); @@ -3307,34 +3307,6 @@ public abstract class PlayerImpl implements Player, Serializable { return result; } - @Deprecated - @Override - public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) { - return this.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, false, false); - } - - @Deprecated - @Override - public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped) { - return this.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, tapped, false); - } - - @Deprecated - @Override - public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped, boolean facedown) { - boolean result = false; - if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped, facedown)) { - if (!game.isSimulation()) { - game.informPlayers(new StringBuilder(this.getLogName()) - .append(" puts ").append(facedown ? "a card face down " : card.getLogName()) - .append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ") - .append("onto the Battlefield").toString()); - } - result = true; - } - return result; - } - @Override public boolean hasOpponent(UUID playerToCheckId, Game game) { return !this.getId().equals(playerToCheckId) && game.isOpponent(this, playerToCheckId);