From 0f4294a66c02fdf62fd6698df3bd16530f541e03 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 8 Jan 2016 14:02:02 +0100 Subject: [PATCH] Midnight Ritual - Changes to card movement handling. --- .../sets/mercadianmasques/MidnightRitual.java | 50 +++++++++---------- .../sets/saviorsofkamigawa/DeathDenied.java | 9 ++-- ...ReturnFromGraveyardToHandTargetEffect.java | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/MidnightRitual.java b/Mage.Sets/src/mage/sets/mercadianmasques/MidnightRitual.java index 2b87d59bfe..799caabd38 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/MidnightRitual.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/MidnightRitual.java @@ -32,13 +32,16 @@ import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Rarity; -import mage.filter.common.FilterCreatureCard; -import mage.cards.Card; 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.token.ZombieToken; +import mage.players.Player; import mage.target.common.TargetCardInYourGraveyard; /** @@ -48,22 +51,20 @@ import mage.target.common.TargetCardInYourGraveyard; public class MidnightRitual extends CardImpl { private final FilterCreatureCard filter = new FilterCreatureCard("creature card from your graveyard"); - + public MidnightRitual(UUID ownerId) { super(ownerId, 146, "Midnight Ritual", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{2}{B}"); this.expansionSetCode = "MMQ"; - // Exile X target creature cards from your graveyard. + // Exile X target creature cards from your graveyard. // For each creature card exiled this way, put a 2/2 black Zombie creature token onto the battlefield. this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(filter)); this.getSpellAbility().addEffect(new MidnightRitualEffect()); } - + @Override - public void adjustTargets(Ability ability, Game game) - { - if (ability instanceof SpellAbility) - { + public void adjustTargets(Ability ability, Game game) { + if (ability instanceof SpellAbility) { ability.getTargets().clear(); ability.addTarget(new TargetCardInYourGraveyard(ability.getManaCostsToPay().getX(), filter)); } @@ -80,33 +81,32 @@ public class MidnightRitual extends CardImpl { } class MidnightRitualEffect extends OneShotEffect { - + public MidnightRitualEffect() { super(Outcome.Neutral); this.staticText = "Exile X target creature cards from your graveyard. For each creature card exiled this way, put a 2/2 black Zombie creature token onto the battlefield"; } - - public MidnightRitualEffect(final MidnightRitualEffect effect) - { + + public MidnightRitualEffect(final MidnightRitualEffect effect) { super(effect); } - + @Override public MidnightRitualEffect copy() { return new MidnightRitualEffect(this); } - + @Override - public boolean apply(Game game, Ability source) - { - for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { - Card card = game.getCard(targetId); - if (card != null) { - if (card.moveToExile(null, null, source.getSourceId(), game)) { - new ZombieToken().putOntoBattlefield(1, game, source.getSourceId(), card.getOwnerId()); - } + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Cards cardsToExile = new CardsImpl(getTargetPointer().getTargets(game, source)); + controller.moveCards(cardsToExile, Zone.EXILED, source, game); + if (!cardsToExile.isEmpty()) { + new ZombieToken().putOntoBattlefield(cardsToExile.size(), game, source.getSourceId(), controller.getId()); } + return true; } - return true; + return false; } } diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/DeathDenied.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/DeathDenied.java index e73c75a492..87f60a5cbe 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/DeathDenied.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/DeathDenied.java @@ -28,13 +28,13 @@ package mage.sets.saviorsofkamigawa; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterCreatureCard; import mage.game.Game; import mage.target.Target; @@ -51,7 +51,6 @@ public class DeathDenied extends CardImpl { this.expansionSetCode = "SOK"; this.subtype.add("Arcane"); - // Return X target creature cards from your graveyard to your hand. Effect effect = new ReturnFromGraveyardToHandTargetEffect(); effect.setText("Return X target creature cards from your graveyard to your hand"); @@ -65,8 +64,8 @@ public class DeathDenied extends CardImpl { if (ability instanceof SpellAbility) { ability.getTargets().clear(); int xValue = ability.getManaCostsToPay().getX(); - Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1?" creature cards":"creature card").append(" from your graveyard").toString())); - ability.addTarget(target); + Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1 ? " creature cards" : "creature card").append(" from your graveyard").toString())); + ability.addTarget(target); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java index 7e086481be..dcae802880 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java @@ -61,7 +61,7 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), null, Zone.HAND, source, game); + return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), Zone.HAND, source, game); } return false; }