From 0cf25a5c8eedb856b741738f9b462c893b7ccce7 Mon Sep 17 00:00:00 2001 From: LevelX2 <ludwig.hirth@online.de> Date: Mon, 24 Mar 2014 08:32:08 +0100 Subject: [PATCH] Minor changes to Phantasmal Image card and test. --- .../mage/sets/magic2012/PhantasmalImage.java | 26 +++++++++++-------- .../test/cards/copy/PhantasmalImageTest.java | 24 ++++++++++++++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2012/PhantasmalImage.java b/Mage.Sets/src/mage/sets/magic2012/PhantasmalImage.java index e42dacb782..5930621e33 100644 --- a/Mage.Sets/src/mage/sets/magic2012/PhantasmalImage.java +++ b/Mage.Sets/src/mage/sets/magic2012/PhantasmalImage.java @@ -28,10 +28,6 @@ package mage.sets.magic2012; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BecomesTargetTriggeredAbility; @@ -40,6 +36,10 @@ import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.SacrificeSourceEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -65,6 +65,9 @@ public class PhantasmalImage extends CardImpl<PhantasmalImage> { this.power = new MageInt(0); this.toughness = new MageInt(0); + // You may have Phantasmal Image enter the battlefield as a copy of any creature + // on the battlefield, except it's an Illusion in addition to its other types and + // it gains "When this creature becomes the target of a spell or ability, sacrifice it." Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect( new PhantasmalImageCopyEffect(), abilityText, true)); this.addAbility(ability); @@ -96,17 +99,18 @@ class PhantasmalImageCopyEffect extends OneShotEffect<PhantasmalImageCopyEffect> Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null) { Target target = new TargetPermanent(new FilterCreaturePermanent()); - if (target.canChoose(source.getControllerId(), game)) { - target.setRequired(true); - target.setNotTarget(true); + target.setRequired(true); + target.setNotTarget(true); + if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { player.choose(Outcome.Copy, target, source.getSourceId(), game); - UUID targetId = target.getFirstTarget(); - Permanent copyFromPermanent = game.getPermanent(targetId); + Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget()); if (copyFromPermanent != null) { game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() { @Override public Boolean apply(Game game, Permanent permanent) { - permanent.getSubtype().add("Illusion"); + if (!permanent.getSubtype().contains("Illusion")) { + permanent.getSubtype().add("Illusion"); + } permanent.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), game); return true; } @@ -123,4 +127,4 @@ class PhantasmalImageCopyEffect extends OneShotEffect<PhantasmalImageCopyEffect> public PhantasmalImageCopyEffect copy() { return new PhantasmalImageCopyEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java index 1612018a17..53f4c88014 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/PhantasmalImageTest.java @@ -12,7 +12,10 @@ import org.mage.test.serverside.base.CardTestPlayerBase; /** * @author noxx * - * Card: You may have {this} enter the battlefield as a copy of any creature on the battlefield, except it's an Illusion in addition to its other types and it gains "When this creature becomes the target of a spell or ability, sacrifice it." + * Card: You may have {this} enter the battlefield as a copy of any creature on the battlefield, except + * it's an Illusion in addition to its other types and it gains "When this creature becomes the target + * of a spell or ability, sacrifice it." + * */ public class PhantasmalImageTest extends CardTestPlayerBase { @@ -119,23 +122,38 @@ public class PhantasmalImageTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Illusionary Servant", 3); } + + // PhantasmalImageTest.testCopyAlreadyTransformed:143-> + // CardTestPlayerAPIImpl.assertPowerToughness:351->CardTestPlayerAPIImpl.assertPowerToughness:337 + // There is no such creature under player's control with specified power&toughness, player=PlayerA, + // cardName=Ravager of the Fells (found similar: 1, one of them: power=8 toughness=8) + /** * Tests copying already transformed creature * Makes sure it still has "When this creature becomes the target of a spell or ability, sacrifice it" */ @Test public void testCopyAlreadyTransformed() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 5); addCard(Zone.BATTLEFIELD, playerB, "Island", 2); addCard(Zone.BATTLEFIELD, playerB, "Forest", 2); addCard(Zone.HAND, playerB, "Phantasmal Image"); addCard(Zone.HAND, playerB, "Titanic Growth"); + // Creatures you control have hexproof. + addCard(Zone.HAND, playerA, "Asceticism"); + + // Whenever this creature enters the battlefield or transforms into + // Huntmaster of the Fells, put a 2/2 green Wolf creature token onto + // the battlefield and you gain 2 life. + // At the beginning of each upkeep, if no spells were cast last turn, transform Huntmaster of the Fells. addCard(Zone.BATTLEFIELD, playerA, "Huntmaster of the Fells"); castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Phantasmal Image"); - castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Titanic Growth", "Ravager of the Fells"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Asceticism"); + castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Titanic Growth", "Ravager of the Fells"); - setStopAt(2, PhaseStep.END_TURN); + setStopAt(3, PhaseStep.END_TURN); execute(); assertLife(playerB, 18);