Fix Lazav's copy ability "forgetting" about cards that change zones.

This commit is contained in:
Nathaniel Brandes 2015-04-28 18:58:48 -07:00
parent 97414233d9
commit 7648ca4b4f
2 changed files with 37 additions and 1 deletions

View file

@ -28,6 +28,7 @@
package mage.sets.gatecrash;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility;
@ -46,6 +47,7 @@ import mage.constants.TargetController;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -107,7 +109,7 @@ class LazavDimirEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
Card card = game.getCard(((FixedTarget)getTargetPointer()).getTarget());
Permanent permanent = game.getPermanent(source.getSourceId());
if (card == null || permanent == null) {
discard();

View file

@ -195,4 +195,38 @@ public class LazavDimirMastermindTest extends CardTestPlayerBase {
}
/**
* Tests if Lazav remains a copy of the creature after it is exiled
*/
@Test
public void testCopyCreatureExiled() {
addCard(Zone.BATTLEFIELD, playerA, "Lazav, Dimir Mastermind", 1);
// Codex Shredder - Artifact
// {T}: Target player puts the top card of his or her library into his or her graveyard.
// {5}, {T}, Sacrifice Codex Shredder: Return target card from your graveyard to your hand.
addCard(Zone.BATTLEFIELD, playerA, "Codex Shredder", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.HAND, playerA, "Rest in Peace", 1);
// Flying 3/2
addCard(Zone.LIBRARY, playerB, "Assault Griffin",5);
skipInitShuffling();
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Target player puts the top card of his or her library into his or her graveyard.", playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Rest in Peace");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Lazav, Dimir Mastermind", 1);
assertPowerToughness(playerA, "Lazav, Dimir Mastermind", 3, 2);
Permanent lazav = getPermanent("Lazav, Dimir Mastermind", playerA.getId());
Assert.assertTrue(lazav.getSubtype().contains("Griffin"));
Assert.assertTrue("Lazav, Dimir Mastermind must have flying",lazav.getAbilities().contains(FlyingAbility.getInstance()));
}
}