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

@ -30,6 +30,7 @@ import mage.game.permanent.Battlefield;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.SpellStack;
import mage.game.stack.StackObject;
import mage.game.turn.Phase;
import mage.game.turn.Step;
import mage.game.turn.Turn;
@ -310,6 +311,19 @@ public interface Game extends MageItem, Serializable, Copyable<Game> {
void resetShortLivingLKI();
/**
* For finding the spell or ability on the stack for "becomes the target" triggers.
* Also ensures that spells/abilities that target the same object twice only trigger each "becomes the target" ability once.
* If this is the first attempt at triggering for a given ability targeting a given object,
* this method temporarily records that in the game state for later checks by this same method,
* to not return the same object again (until short living LKI is cleared)
*
* @param checkingReference must be unique for each usage (this.getId().toString() of the TriggeredAbility, or this.getKey() of the watcher)
* @param event the GameEvent.EventType.TARGETED from checkTrigger() or watch()
* @return the StackObject which targeted the source, or null if already used or not found
*/
StackObject findTargetingStackObject(String checkingReference, GameEvent event);
void setLosingPlayer(Player player);
Player getLosingPlayer();