Fix and test token saga zcc tracking

This commit is contained in:
Steven Knipe 2025-08-10 18:19:41 -07:00
parent 4683e5c05a
commit 2552dcf633
2 changed files with 73 additions and 1 deletions

View file

@ -79,4 +79,73 @@ public class ThePrincessTakesFlightTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Memnite", 1);
assertGraveyardCount(playerA, flight, 1);
}
@Test
public void test_TokenCopy() {
addCard(Zone.HAND, playerA, flight, 1);
addCard(Zone.HAND, playerA, "Swords to Plowshares", 1);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1);
addCard(Zone.BATTLEFIELD, playerA, "Ondu Spiritdancer", 1);
addCard(Zone.BATTLEFIELD, playerB, "Memnite", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, flight);
setChoice(playerA, "I - ");
addTarget(playerA, "Memnite");
setChoice(playerA, true);
addTarget(playerA, "Grizzly Bears");
checkExileCount("after I, exiled Memnite", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Memnite", 1);
checkExileCount("after I, exiled Grizzly Bears", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Grizzly Bears", 1);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Swords to Plowshares", "Ondu Spiritdancer");
// turn 3
setChoice(playerA, "II - ");
// No targets available
// turn 5
setChoice(playerA, "III - ");
setStrictChooseMode(true);
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertExileCount(playerA, "Grizzly Bears", 0);
assertExileCount(playerB, "Memnite", 0);
assertPermanentCount(playerA, "Grizzly Bears", 1);
assertPermanentCount(playerB, "Memnite", 1);
}
@Test
public void test_SpellCopy() {
addCard(Zone.HAND, playerA, flight, 1);
addCard(Zone.HAND, playerA, "Swords to Plowshares", 1);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1);
addCard(Zone.BATTLEFIELD, playerA, "The Sixth Doctor", 1);
addCard(Zone.BATTLEFIELD, playerB, "Memnite", 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, flight);
addTarget(playerA, "Memnite");
addTarget(playerA, "Grizzly Bears");
checkExileCount("after I, exiled Memnite", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Memnite", 1);
checkExileCount("after I, exiled Grizzly Bears", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Grizzly Bears", 1);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Swords to Plowshares", "The Sixth Doctor");
// turn 3
setChoice(playerA, "II - ");
// No targets available
// turn 5
setChoice(playerA, "III - ");
setStrictChooseMode(true);
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertExileCount(playerA, "Grizzly Bears", 0);
assertExileCount(playerB, "Memnite", 0);
assertPermanentCount(playerA, "Grizzly Bears", 1);
assertPermanentCount(playerB, "Memnite", 1);
}
}

View file

@ -33,6 +33,7 @@ import mage.game.events.BatchEvent;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.game.stack.Spell;
import mage.game.stack.StackAbility;
import mage.players.Player;
@ -1707,13 +1708,15 @@ public abstract class AbilityImpl implements Ability {
private int getCurrentSourceObjectZoneChangeCounter(Game game){
int zcc = game.getState().getZoneChangeCounter(getSourceId());
if (game.getPermanentEntering(getSourceId()) != null){
Permanent p = game.getPermanentEntering(getSourceId());
if (p != null && !(p instanceof PermanentToken)){
// If the triggered ability triggered while the permanent is entering the battlefield
// then add 1 zcc so that it triggers as if the permanent was already on the battlefield
// So "Enters with counters" causes "Whenever counters are placed" to trigger with battlefield zcc
// Particularly relevant for Sagas, which always involve both
// Note that this does NOT apply to "As ~ ETB" effects, those still use the stack zcc
zcc += 1;
// However, tokens don't change their zcc upon entering the battlefield, so don't add for them
}
return zcc;
}