fix #13523 (trigger on becomes the target of recast spell) (#13740)

move findTargetingStackObject from CardUtil to Game, so saved data can be cleared with short living lki

add test cases
This commit is contained in:
xenohedron 2025-06-14 00:09:40 -04:00 committed by GitHub
parent 030e8ae5d3
commit 24f030fa71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 181 additions and 73 deletions

View file

@ -1,5 +1,6 @@
package org.mage.test.cards.abilities.keywords;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
@ -80,4 +81,115 @@ public class WardTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Roaming Throne", 1);
assertDamageReceived(playerB, "Roaming Throne", 0);
}
// Reported bug: #13523 - Ward not properly triggering when re-casting Aura
private static final String creature = "Owlin Shieldmage"; // 3/3 Flying, Ward - Pay 3 life
private static final String aura = "Kenrith's Transformation"; // 1G enchanted creature loses all abilities and is 3/3 Elk (also draw card on ETB)
private static final String spell = "Beast Within"; // 2G destroy permanent, controller gets 3/3 Beast
private static final String regrowth = "Regrowth"; // 1G return target card from graveyard to hand
@Test
public void wardRecastAuraNoPay() {
addCard(Zone.BATTLEFIELD, playerB, creature);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 9);
addCard(Zone.HAND, playerA, aura);
addCard(Zone.HAND, playerA, spell);
addCard(Zone.HAND, playerA, regrowth);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, creature);
setChoice(playerA, false); // don't pay for ward
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, regrowth, aura);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, creature);
setChoice(playerA, false); // don't pay for ward
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertLife(playerA, 20);
assertGraveyardCount(playerA, aura, 1);
assertGraveyardCount(playerA, regrowth, 1);
assertGraveyardCount(playerA, 2);
assertHandCount(playerA, spell, 1);
assertHandCount(playerA, 1);
assertAbility(playerB, creature, FlyingAbility.getInstance(), true);
}
@Test
public void wardRecastAuraPaySecond() {
addCard(Zone.BATTLEFIELD, playerB, creature);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 9);
addCard(Zone.HAND, playerA, aura);
addCard(Zone.HAND, playerA, spell);
addCard(Zone.HAND, playerA, regrowth);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, creature);
setChoice(playerA, false); // don't pay for ward
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, regrowth, aura);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, creature);
setChoice(playerA, true); // pay ward
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertLife(playerA, 17);
assertGraveyardCount(playerA, aura, 0);
assertGraveyardCount(playerA, regrowth, 1);
assertGraveyardCount(playerA, 1);
assertHandCount(playerA, spell, 1);
assertHandCount(playerA, 2); // one draw from aura entering
assertAttachedTo(playerB, aura, creature, true);
assertAbility(playerB, creature, FlyingAbility.getInstance(), false);
}
@Test
public void wardRecastAuraPayBoth() {
addCard(Zone.BATTLEFIELD, playerB, creature);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 9);
addCard(Zone.HAND, playerA, aura);
addCard(Zone.HAND, playerA, spell);
addCard(Zone.HAND, playerA, regrowth);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, creature);
setChoice(playerA, true); // pay for ward
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, spell, aura); // destroy aura
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, regrowth, aura);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, aura, creature);
setChoice(playerA, true); // pay ward
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertLife(playerA, 14);
assertGraveyardCount(playerA, spell, 1);
assertGraveyardCount(playerA, regrowth, 1);
assertGraveyardCount(playerA, 2);
assertHandCount(playerA, 2); // two draws from aura entering
assertAttachedTo(playerB, aura, creature, true);
assertAbility(playerB, creature, FlyingAbility.getInstance(), false);
}
}