From bc21b8d475bc7bbca349aa8589c82d0afb3deaec Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 31 May 2015 19:17:15 +0200 Subject: [PATCH] * Deathmist Raptor - Fixed that the return ability did wrongly also work if the Raptor had left the graveyard. --- .../sets/dragonsoftarkir/DeathmistRaptor.java | 11 ++--- ...va => ReturnToBattlefieldEffectsTest.java} | 40 ++++++++++++++++++- 2 files changed, 44 insertions(+), 7 deletions(-) rename Mage.Tests/src/test/java/org/mage/test/cards/triggers/{ReturnToBattlefieldUnderYourControlTargetEffectTest.java => ReturnToBattlefieldEffectsTest.java} (71%) diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java index ffde7596bcb..d6295186c56 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/DeathmistRaptor.java @@ -29,6 +29,7 @@ package mage.sets.dragonsoftarkir; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.TurnedFaceUpAllTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -63,7 +64,7 @@ public class DeathmistRaptor extends CardImpl { this.addAbility(DeathtouchAbility.getInstance()); // Whenever a permanent you control is turned face up, you may return Deathmist Raptor from your graveyard to the battlefield face up or face down. - this.addAbility(new TurnedFaceUpAllTriggeredAbility(Zone.GRAVEYARD, new DeathmistRaptorEffect(), new FilterControlledPermanent(), false, true)); + this.addAbility(new TurnedFaceUpAllTriggeredAbility(Zone.GRAVEYARD, new DeathmistRaptorEffect(), new FilterControlledPermanent("a permanent you control"), false, true)); // Megamorph {4}{G} this.addAbility(new MorphAbility(this, new ManaCostsImpl("{4}{G}"), true)); @@ -98,10 +99,10 @@ class DeathmistRaptorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Card card = game.getCard(source.getSourceId()); - if (controller != null && card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false, - controller.chooseUse(Outcome.Detriment, "Return " + card.getName() + " face down to battlefield (otherwise face up)?", game)); + 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)?", game)); return true; } return false; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ReturnToBattlefieldUnderYourControlTargetEffectTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ReturnToBattlefieldEffectsTest.java similarity index 71% rename from Mage.Tests/src/test/java/org/mage/test/cards/triggers/ReturnToBattlefieldUnderYourControlTargetEffectTest.java rename to Mage.Tests/src/test/java/org/mage/test/cards/triggers/ReturnToBattlefieldEffectsTest.java index fee25268faf..dc6b5f32a59 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ReturnToBattlefieldUnderYourControlTargetEffectTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/ReturnToBattlefieldEffectsTest.java @@ -37,7 +37,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * @author LevelX2 */ -public class ReturnToBattlefieldUnderYourControlTargetEffectTest extends CardTestPlayerBase { +public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase { @Test public void testSaffiEriksdotter() { @@ -115,5 +115,41 @@ public class ReturnToBattlefieldUnderYourControlTargetEffectTest extends CardTes assertExileCount("Arcbound Worker", 1); } - + /** + * With my opponent's Deathmist Raptor return-to-battlefield trigger on the stack, + * I exiled the Deathmist Raptor with Pharika, God of Affliction. However, the Deathmist Raptor + * returned to the battlefield from exile, though it should not have because it had + * changed zones so was a different object. + */ + @Test + public void testDeathmistRaptor() { + // Deathtouch + // Whenever a permanent you control is turned face up, you may return Deathmist Raptor from your graveyard to the battlefield face up or face down. + // Megamorph {4}{G} + addCard(Zone.GRAVEYARD, playerA, "Deathmist Raptor"); + addCard(Zone.HAND, playerA, "Pine Walker"); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); + + addCard(Zone.BATTLEFIELD, playerB, "Forest", 1); + addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1); + // {B}{G}: Exile target creature card from a graveyard. It's owner puts a 1/1 black and green Snake enchantment creature token with deathtouch onto the battlefield. + addCard(Zone.BATTLEFIELD, playerB, "Pharika, God of Affliction", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker"); + setChoice(playerA, "Yes"); // cast it face down as 2/2 creature + + activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "{4}{G}: Turn this face-down permanent face up."); + activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "{B}{G}: Exile target creature card from a graveyard", + "Deathmist Raptor", "Whenever a permanent you control is turned face up"); + + setStopAt(3, PhaseStep.END_TURN); + + execute(); + assertPermanentCount(playerB, "Pharika, God of Affliction", 1); + assertPermanentCount(playerA, "Snake", 1); + assertPermanentCount(playerA, "Pine Walker", 1); + + assertExileCount("Deathmist Raptor", 1); + + } } \ No newline at end of file