* Fixed that the new early way to add counters to permanents entering the battlefield (e.g. used for Undying) checked effects while the permanents was not already set to Zone battlefield. That caused e.g. the ability of Tatterkite not to work at that time.

This commit is contained in:
LevelX2 2015-08-30 10:04:36 +02:00
parent 0368c5287a
commit eb3aef7ee5
4 changed files with 64 additions and 38 deletions

View file

@ -32,7 +32,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.common.ruleModifying.CantRegenerateTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -61,7 +60,7 @@ public class Tatterkite extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Tatterkite can't have counters placed on it. // Tatterkite can't have counters placed on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantHaveCountersSourceEffect(Duration.WhileOnBattlefield, "it"))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantHaveCountersSourceEffect(Duration.WhileOnBattlefield)));
} }
@ -77,7 +76,7 @@ public class Tatterkite extends CardImpl {
class CantHaveCountersSourceEffect extends ContinuousRuleModifyingEffectImpl { class CantHaveCountersSourceEffect extends ContinuousRuleModifyingEffectImpl {
public CantHaveCountersSourceEffect(Duration duration, String objectText) { public CantHaveCountersSourceEffect(Duration duration) {
super(duration, Outcome.Detriment); super(duration, Outcome.Detriment);
staticText = "{this} can't have counters placed on it"; staticText = "{this} can't have counters placed on it";
} }
@ -91,14 +90,9 @@ class CantHaveCountersSourceEffect extends ContinuousRuleModifyingEffectImpl {
return new CantHaveCountersSourceEffect(this); return new CantHaveCountersSourceEffect(this);
} }
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ADD_COUNTER; return event.getType() == EventType.ADD_COUNTERS;
} }
@Override @Override

View file

@ -11,7 +11,8 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class UndyingTest extends CardTestPlayerBase { public class UndyingTest extends CardTestPlayerBase {
/** /**
* Tests boost weren't be applied second time when creature back to battlefield * Tests boost weren't be applied second time when creature back to
* battlefield
*/ */
@Test @Test
public void testWithBoost() { public void testWithBoost() {
@ -29,7 +30,8 @@ public class UndyingTest extends CardTestPlayerBase {
} }
/** /**
* Tests boost weren't be applied second time when creature back to battlefield * Tests boost weren't be applied second time when creature back to
* battlefield
*/ */
@Test @Test
public void testWithMassBoost() { public void testWithMassBoost() {
@ -76,9 +78,9 @@ public class UndyingTest extends CardTestPlayerBase {
assertPowerToughness(playerA, "Elite Vanguard", 3, 2); assertPowerToughness(playerA, "Elite Vanguard", 3, 2);
} }
/** /**
* Tests "Threads of Disloyalty enchanting Strangleroot Geist: after geist died it returns to the bf under opponent's control." * Tests "Threads of Disloyalty enchanting Strangleroot Geist: after geist
* died it returns to the bf under opponent's control."
*/ */
@Test @Test
public void testUndyingControlledReturnsToOwner() { public void testUndyingControlledReturnsToOwner() {
@ -113,10 +115,12 @@ public class UndyingTest extends CardTestPlayerBase {
} }
/** /**
* Tests "Target creature with Undying will be exiled by Anafenza before it returns to battlefield * Tests "Target creature with Undying will be exiled by Anafenza before it
* returns to battlefield
* *
* Anafenza the foremost doesn't exile an undying creature when dying at the same time as * Anafenza the foremost doesn't exile an undying creature when dying at the
* that undying one. The undying comes back to the field when he shouldn't. * same time as that undying one. The undying comes back to the field when
* he shouldn't.
*/ */
@Test @Test
public void testReplacementEffectPreventsReturnOfUndying() { public void testReplacementEffectPreventsReturnOfUndying() {
@ -147,11 +151,12 @@ public class UndyingTest extends CardTestPlayerBase {
} }
/** /**
* Tests "Target creature with Undying will be exiled by Anafenza before it returns to battlefield * Tests "Target creature with Undying will be exiled by Anafenza before it
* if both leave the battlefield at the same time * returns to battlefield if both leave the battlefield at the same time
* *
* Anafenza the foremost doesn't exile an undying creature when dying at the same time as * Anafenza the foremost doesn't exile an undying creature when dying at the
* that undying one. The undying comes back to the field when he shouldn't. * same time as that undying one. The undying comes back to the field when
* he shouldn't.
*/ */
@Test @Test
public void testReplacementEffectPreventsReturnOfUndyingWrath() { public void testReplacementEffectPreventsReturnOfUndyingWrath() {
@ -208,4 +213,33 @@ public class UndyingTest extends CardTestPlayerBase {
assertPowerToughness(playerA, "Silvercoat Lion", 4, 4); assertPowerToughness(playerA, "Silvercoat Lion", 4, 4);
} }
/**
* Tatterkite is getting counters on it, i have him in a edh deck with
* Mikaeus, the Lunarch and when Tatterkite dies it triggers the undying and
* he gets the +1/+1 counters
*/
@Test
public void testUndyingMikaeusAndTatterkite() {
addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
// Whenever a Human deals damage to you, destroy it.
// Other non-Human creatures you control get +1/+1 and have undying.
addCard(Zone.BATTLEFIELD, playerA, "Mikaeus, the Unhallowed", 1);
addCard(Zone.BATTLEFIELD, playerA, "Tatterkite", 1); // Artifact Creature - Scarecrow 2/1
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Tatterkite");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertPermanentCount(playerA, "Tatterkite", 1);
assertPermanentCount(playerA, "Mikaeus, the Unhallowed", 1);
assertPowerToughness(playerA, "Tatterkite", 3, 2);
}
} }

View file

@ -36,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class AddingCountersToPermanentsTest extends CardTestPlayerBase { public class AddingCountersToPermanentsTest extends CardTestPlayerBase {
@Test @Test
@ -66,7 +65,6 @@ public class AddingCountersToPermanentsTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Witch's Familiar", 1); assertPermanentCount(playerB, "Witch's Familiar", 1);
assertPowerToughness(playerB, "Witch's Familiar", 0, 1); assertPowerToughness(playerB, "Witch's Familiar", 0, 1);
} }
} }

View file

@ -602,10 +602,10 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
PermanentCard permanent = new PermanentCard(this, event.getPlayerId(), game); PermanentCard permanent = new PermanentCard(this, event.getPlayerId(), game);
// make sure the controller of all continuous effects of this card are switched to the current controller // make sure the controller of all continuous effects of this card are switched to the current controller
game.getContinuousEffects().setController(objectId, event.getPlayerId()); game.getContinuousEffects().setController(objectId, event.getPlayerId());
// check if there are counters to add to the permanent (e.g. from non replacement effects like Persist)
checkForCountersToAdd(permanent, game);
game.addPermanent(permanent); game.addPermanent(permanent);
setZone(Zone.BATTLEFIELD, game); setZone(Zone.BATTLEFIELD, game);
// check if there are counters to add to the permanent (e.g. from non replacement effects like Persist)
checkForCountersToAdd(permanent, game);
game.setScopeRelevant(true); game.setScopeRelevant(true);
permanent.setTapped(tapped); permanent.setTapped(tapped);
permanent.setFaceDown(facedown, game); permanent.setFaceDown(facedown, game);