diff --git a/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java b/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java index 13f59c35e1a..68e4320e8b6 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java +++ b/Mage.Sets/src/mage/sets/magicorigins/LilianaDefiantNecromancer.java @@ -139,7 +139,8 @@ class LilianaDefiantNecromancerEmblem extends Emblem { // You get an emblem with "Whenever a creature you control dies, return it to the battlefield under your control at the beginning of the next end step." public LilianaDefiantNecromancerEmblem() { this.setName("Emblem - Liliana"); - this.getAbilities().add(new DiesCreatureTriggeredAbility(new LilianaDefiantNecromancerEmblemEffect(), false, filter, true)); + Ability ability = new DiesCreatureTriggeredAbility(Zone.COMMAND, new LilianaDefiantNecromancerEmblemEffect(), false, filter, true); + this.getAbilities().add(ability); } } @@ -164,7 +165,7 @@ class LilianaDefiantNecromancerEmblemEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId())); + effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); effect.setText("return that card to the battlefield at the beginning of the next end step"); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY); delayedAbility.setSourceId(source.getSourceId()); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/emblems/EmblemsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/emblems/EmblemsTest.java index 66b7aa73c35..0c211862d2c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/emblems/EmblemsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/emblems/EmblemsTest.java @@ -14,8 +14,8 @@ import org.mage.test.serverside.base.CardTestPlayerBase; public class EmblemsTest extends CardTestPlayerBase { /** - * Venser The Sojourner: - * -8: You get an emblem with "Whenever you cast a spell, exile target permanent." + * Venser The Sojourner: -8: You get an emblem with "Whenever you cast a + * spell, exile target permanent." */ @Test public void testVenserTheSojournerEmblem() { @@ -40,8 +40,8 @@ public class EmblemsTest extends CardTestPlayerBase { } /** - * Sorin, Lord of Innistrad: - * -2: You get an emblem with "Creatures you control get +1/+0." + * Sorin, Lord of Innistrad: -2: You get an emblem with "Creatures you + * control get +1/+0." */ @Test public void testSorinLordOfInnistradEmblem() { @@ -67,8 +67,9 @@ public class EmblemsTest extends CardTestPlayerBase { } /** - * Tamiyo, the Moon Sage: - * -8: You get an emblem with "You have no maximum hand size" and "Whenever a card is put into your graveyard from anywhere, you may return it to your hand." + * Tamiyo, the Moon Sage: -8: You get an emblem with "You have no maximum + * hand size" and "Whenever a card is put into your graveyard from anywhere, + * you may return it to your hand." * * Tests "You have no maximum hand size" */ @@ -88,10 +89,12 @@ public class EmblemsTest extends CardTestPlayerBase { } /** - * Tamiyo, the Moon Sage: - * -8: You get an emblem with "You have no maximum hand size" and "Whenever a card is put into your graveyard from anywhere, you may return it to your hand." + * Tamiyo, the Moon Sage: -8: You get an emblem with "You have no maximum + * hand size" and "Whenever a card is put into your graveyard from anywhere, + * you may return it to your hand." * - * Tests "Whenever a card is put into your graveyard from anywhere, you may return it to your hand." + * Tests "Whenever a card is put into your graveyard from anywhere, you may + * return it to your hand." */ @Test public void testTamiyoTheMoonSageSecondEmblem() { @@ -119,4 +122,39 @@ public class EmblemsTest extends CardTestPlayerBase { } Assert.assertTrue("Couldn't find a card in hand: Elite Vanguard", found); } + + /** + * Liliana, Defiant Necromancer: -8: You get an emblem with "Whenever a + * creature you control dies, return it to the battlefield under your + * control at the beginning of the next end step."; + * + * Tests "Whenever a creature you control dies, return it to the battlefield + * under your control at the beginning of the next end step." + */ + @Test + public void testLilianaDefiantNecromancer() { + addCard(Zone.BATTLEFIELD, playerA, "Liliana, Defiant Necromancer"); + addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard"); + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2); + addCard(Zone.HAND, playerB, "Lightning Bolt", 2); + + addCounters(1, PhaseStep.UPKEEP, playerA, "Liliana, Defiant Necromancer", CounterType.LOYALTY, 6); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-8: You get an emblem"); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Elite Vanguard"); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Silvercoat Lion"); + + setStopAt(2, PhaseStep.UPKEEP); + execute(); + + assertEmblemCount(playerA, 1); + + assertPermanentCount(playerA, "Liliana, Defiant Necromancer", 1); + assertPermanentCount(playerA, "Elite Vanguard", 1); + assertGraveyardCount(playerB, "Silvercoat Lion", 1); + + assertHandCount(playerA, 0); + + } } diff --git a/Mage/src/mage/abilities/common/DiesCreatureTriggeredAbility.java b/Mage/src/mage/abilities/common/DiesCreatureTriggeredAbility.java index 6b4202de140..fe0a3240d55 100644 --- a/Mage/src/mage/abilities/common/DiesCreatureTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/DiesCreatureTriggeredAbility.java @@ -26,7 +26,7 @@ public class DiesCreatureTriggeredAbility extends TriggeredAbilityImpl { this(effect, optional, new FilterCreaturePermanent("another creature")); filter.add(new AnotherPredicate()); } - + public DiesCreatureTriggeredAbility(Effect effect, boolean optional, boolean another, boolean setTargetPointer) { this(effect, optional, new FilterCreaturePermanent("another creature")); filter.add(new AnotherPredicate()); @@ -38,12 +38,16 @@ public class DiesCreatureTriggeredAbility extends TriggeredAbilityImpl { } public DiesCreatureTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter, boolean setTargetPointer) { - super(Zone.BATTLEFIELD, effect, optional); + this(Zone.BATTLEFIELD, effect, optional, filter, setTargetPointer); + } + + public DiesCreatureTriggeredAbility(Zone zone, Effect effect, boolean optional, FilterCreaturePermanent filter, boolean setTargetPointer) { + super(zone, effect, optional); this.filter = filter; this.setTargetPointer = setTargetPointer; } - public DiesCreatureTriggeredAbility(DiesCreatureTriggeredAbility ability) { + public DiesCreatureTriggeredAbility(final DiesCreatureTriggeredAbility ability) { super(ability); this.filter = ability.filter; this.setTargetPointer = ability.setTargetPointer;