Support another case of reflexive triggers getting duplicated (#5594)

* Support another case of reflexive triggers getting duplicated

* Improve detection logic

---------

Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.60>
This commit is contained in:
tool4ever
2024-07-15 05:25:00 +00:00
committed by GitHub
parent faa128f86d
commit c5203421d9
7 changed files with 19 additions and 12 deletions

View File

@@ -34,6 +34,10 @@ public class ImmediateTriggerEffect extends SpellAbilityEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard(); final Card host = sa.getHostCard();
final Game game = host.getGame(); final Game game = host.getGame();
int amt = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("TriggerAmount", "1"), sa);
if (amt <= 0) {
return;
}
Map<String, String> mapParams = Maps.newHashMap(sa.getMapParams()); Map<String, String> mapParams = Maps.newHashMap(sa.getMapParams());
if (mapParams.containsKey("SpellDescription") && !mapParams.containsKey("TriggerDescription")) { if (mapParams.containsKey("SpellDescription") && !mapParams.containsKey("TriggerDescription")) {
@@ -71,7 +75,6 @@ public class ImmediateTriggerEffect extends SpellAbilityEffect {
immediateTrig.setOverridingAbility(overridingSA); immediateTrig.setOverridingAbility(overridingSA);
} }
int amt = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("TriggerAmount", "1"), sa);
for (int i = 0; i < amt; i++) { for (int i = 0; i < amt; i++) {
// Instead of registering this, add to the delayed triggers as an immediate trigger type? Which means it'll fire as soon as possible // Instead of registering this, add to the delayed triggers as an immediate trigger type? Which means it'll fire as soon as possible
game.getTriggerHandler().registerDelayedTrigger(immediateTrig); game.getTriggerHandler().registerDelayedTrigger(immediateTrig);

View File

@@ -73,6 +73,7 @@ public abstract class TokenEffectBase extends SpellAbilityEffect {
final Card host = sa.getHostCard(); final Card host = sa.getHostCard();
final Game game = host.getGame(); final Game game = host.getGame();
long timestamp = game.getNextTimestamp(); long timestamp = game.getNextTimestamp();
Set<Card> originalTokens = Sets.newHashSet(tokenTable.columnKeySet());
// support PlayerCollection for affected // support PlayerCollection for affected
Set<Player> toRemove = Sets.newHashSet(); Set<Player> toRemove = Sets.newHashSet();
@@ -191,6 +192,10 @@ public abstract class TokenEffectBase extends SpellAbilityEffect {
if (sa.hasParam("RememberTokens")) { if (sa.hasParam("RememberTokens")) {
host.addRemembered(moved); host.addRemembered(moved);
} }
// used for some reflexive trigger
if (sa.hasParam("RememberOriginalTokens") && originalTokens.contains(prototype)) {
host.addRemembered(moved);
}
if (sa.hasParam("ImprintTokens")) { if (sa.hasParam("ImprintTokens")) {
host.addImprintedCard(moved); host.addImprintedCard(moved);
} }

View File

@@ -20,8 +20,8 @@ Colors:red,white
Types:Legendary Planeswalker Ajani Types:Legendary Planeswalker Ajani
Loyalty:3 Loyalty:3
A:AB$ PutCounterAll | Cost$ AddCounter<2/LOYALTY> | ValidCards$ Cat.YouCtrl | CounterType$ P1P1 | CounterNum$ 1 | Planeswalker$ True | SpellDescription$ Put a +1/+1 counter on each Cat you control. A:AB$ PutCounterAll | Cost$ AddCounter<2/LOYALTY> | ValidCards$ Cat.YouCtrl | CounterType$ P1P1 | CounterNum$ 1 | Planeswalker$ True | SpellDescription$ Put a +1/+1 counter on each Cat you control.
A:AB$ Token | Cost$ AddCounter<0/LOYALTY> | TokenAmount$ 1 | TokenScript$ w_2_1_cat_warrior | TokenOwner$ You | RememberTokens$ True | SubAbility$ DBImmediateTrig1 | Planeswalker$ True | SpellDescription$ Create a 2/1 white Cat Warrior creature token. When you do, if you control a red permanent other than CARDNAME, he deals damage equal to the number of creatures you control to any target. A:AB$ Token | Cost$ AddCounter<0/LOYALTY> | TokenAmount$ 1 | TokenScript$ w_2_1_cat_warrior | TokenOwner$ You | RememberOriginalTokens$ True | SubAbility$ DBImmediateTrig1 | Planeswalker$ True | SpellDescription$ Create a 2/1 white Cat Warrior creature token. When you do, if you control a red permanent other than CARDNAME, he deals damage equal to the number of creatures you control to any target.
SVar:DBImmediateTrig1:DB$ ImmediateTrigger | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionPresent2$ Permanent.Red+YouCtrl+Other | Execute$ TrigDamage | TriggerDescription$ When you do, if you control a red permanent other than CARDNAME, he deals damage equal to the number of creatures you control to any target. SVar:DBImmediateTrig1:DB$ ImmediateTrigger | TriggerAmount$ Remembered$Amount | ConditionPresent$ Permanent.Red+YouCtrl+Other | Execute$ TrigDamage | TriggerDescription$ When you do, if you control a red permanent other than CARDNAME, he deals damage equal to the number of creatures you control to any target.
SVar:TrigDamage:DB$ DealDamage | NumDmg$ X | ValidTgts$ Any | ConditionPresent$ Permanent.Red+YouCtrl+Other | SubAbility$ DBCleanup | TgtPrompt$ Select any valid target | SpellDescription$ CARDNAME deals damage equal to the number of creatures you control to any target. SVar:TrigDamage:DB$ DealDamage | NumDmg$ X | ValidTgts$ Any | ConditionPresent$ Permanent.Red+YouCtrl+Other | SubAbility$ DBCleanup | TgtPrompt$ Select any valid target | SpellDescription$ CARDNAME deals damage equal to the number of creatures you control to any target.
SVar:X:Count$Valid Creature.YouCtrl SVar:X:Count$Valid Creature.YouCtrl
A:AB$ RepeatEach | Cost$ SubCounter<4/LOYALTY> | Planeswalker$ True | Ultimate$ True | RepeatPlayers$ Opponent | RepeatSubAbility$ ChooseArtf | SubAbility$ SacAllOthers | SpellDescription$ Each opponent chooses an artifact, a creature, an enchantment, and a planeswalker from among the nonland permanents they control, then sacrifices the rest. A:AB$ RepeatEach | Cost$ SubCounter<4/LOYALTY> | Planeswalker$ True | Ultimate$ True | RepeatPlayers$ Opponent | RepeatSubAbility$ ChooseArtf | SubAbility$ SacAllOthers | SpellDescription$ Each opponent chooses an artifact, a creature, an enchantment, and a planeswalker from among the nonland permanents they control, then sacrifices the rest.

View File

@@ -3,8 +3,8 @@ ManaCost:4 B
Types:Creature Zombie Types:Creature Zombie
PT:3/4 PT:3/4
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigToken | TriggerDescription$ When CARDNAME enters the battlefield, create two 2/2 black Zombie creature tokens with decayed. When you do, exile up to two target cards from graveyards. (A creature with decayed can't block. When it attacks, sacrifice it at end of combat.) T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigToken | TriggerDescription$ When CARDNAME enters the battlefield, create two 2/2 black Zombie creature tokens with decayed. When you do, exile up to two target cards from graveyards. (A creature with decayed can't block. When it attacks, sacrifice it at end of combat.)
SVar:TrigToken:DB$ Token | TokenAmount$ 2 | TokenScript$ b_2_2_zombie_decayed | RememberTokens$ True | SubAbility$ DBImmediateTrigger SVar:TrigToken:DB$ Token | TokenAmount$ 2 | TokenScript$ b_2_2_zombie_decayed | RememberOriginalTokens$ True | SubAbility$ DBImmediateTrigger
SVar:DBImmediateTrigger:DB$ ImmediateTrigger | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ GE2 | Execute$ TrigExile | SubAbility$ DBCleanup | TriggerDescription$ When you do, exile up to two target cards from graveyards. SVar:DBImmediateTrigger:DB$ ImmediateTrigger | TriggerAmount$ Remembered$Amount/DivideEvenlyDown.2 | Execute$ TrigExile | SubAbility$ DBCleanup | TriggerDescription$ When you do, exile up to two target cards from graveyards.
SVar:TrigExile:DB$ ChangeZone | Origin$ Graveyard | Destination$ Exile | TargetMin$ 0 | TargetMax$ 2 | TgtPrompt$ Select up to two target cards from graveyards | ValidTgts$ Card SVar:TrigExile:DB$ ChangeZone | Origin$ Graveyard | Destination$ Exile | TargetMin$ 0 | TargetMax$ 2 | TgtPrompt$ Select up to two target cards from graveyards | ValidTgts$ Card
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
DeckHas:Ability$Token|Graveyard DeckHas:Ability$Token|Graveyard

View File

@@ -3,8 +3,8 @@ ManaCost:2 W
Types:Creature Halfling Peasant Types:Creature Halfling Peasant
PT:2/3 PT:2/3
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigFood | TriggerDescription$ When CARDNAME enters the battlefield, create a Food token. When you do, target creature you control gets +1/+1 until end of turn for each Food you control. (A Food token is an artifact with "{2}, {T}, Sacrifice this artifact: You gain 3 life.") T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigFood | TriggerDescription$ When CARDNAME enters the battlefield, create a Food token. When you do, target creature you control gets +1/+1 until end of turn for each Food you control. (A Food token is an artifact with "{2}, {T}, Sacrifice this artifact: You gain 3 life.")
SVar:TrigFood:DB$ Token | TokenAmount$ 1 | TokenScript$ c_a_food_sac | TokenOwner$ You | RememberTokens$ True | SubAbility$ DBImmediateTrig SVar:TrigFood:DB$ Token | TokenAmount$ 1 | TokenScript$ c_a_food_sac | TokenOwner$ You | RememberOriginalTokens$ True | SubAbility$ DBImmediateTrig
SVar:DBImmediateTrig:DB$ ImmediateTrigger | ConditionDefined$ Remembered | ConditionPresent$ Card | Execute$ TrigPump | SubAbility$ DBCleanup | TriggerDescription$ When you do, target creature you control gets +1/+1 until end of turn for each Food you control. (A Food token is an artifact with "{2}, {T}, Sacrifice this artifact: You gain 3 life.") SVar:DBImmediateTrig:DB$ ImmediateTrigger | TriggerAmount$ Remembered$Amount | Execute$ TrigPump | SubAbility$ DBCleanup | TriggerDescription$ When you do, target creature you control gets +1/+1 until end of turn for each Food you control. (A Food token is an artifact with "{2}, {T}, Sacrifice this artifact: You gain 3 life.")
SVar:TrigPump:DB$ Pump | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | NumAtt$ +X | NumDef$ +X SVar:TrigPump:DB$ Pump | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | NumAtt$ +X | NumDef$ +X
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Count$Valid Food.YouCtrl SVar:X:Count$Valid Food.YouCtrl

View File

@@ -2,9 +2,8 @@ Name:Explosion of Riches
ManaCost:5 R ManaCost:5 R
Types:Sorcery Types:Sorcery
A:SP$ Draw | Defined$ You | NumCards$ 1 | SubAbility$ DBDraw | StackDescription$ SpellDescription | RememberDrawn$ AllReplaced | SpellDescription$ Draw a card, then each other player may draw a card. Whenever a card is drawn this way, CARDNAME deals 5 damage to target opponent chosen at random from among your opponents. A:SP$ Draw | Defined$ You | NumCards$ 1 | SubAbility$ DBDraw | StackDescription$ SpellDescription | RememberDrawn$ AllReplaced | SpellDescription$ Draw a card, then each other player may draw a card. Whenever a card is drawn this way, CARDNAME deals 5 damage to target opponent chosen at random from among your opponents.
SVar:DBDraw:DB$ Draw | Defined$ Player.Other | OptionalDecider$ True | NumCards$ 1 | RememberDrawn$ AllReplaced | SubAbility$ DBRepeatEach | StackDescription$ None SVar:DBDraw:DB$ Draw | Defined$ Player.Other | OptionalDecider$ True | NumCards$ 1 | RememberDrawn$ AllReplaced | SubAbility$ DBImmediateTrigger | StackDescription$ None
SVar:DBRepeatEach:DB$ RepeatEach | RepeatCards$ Card.IsRemembered | Zone$ Hand | RepeatSubAbility$ DBImmediateTrigger | SubAbility$ DBCleanup SVar:DBImmediateTrigger:DB$ ImmediateTrigger | Execute$ TrigDamage | TriggerAmount$ Remembered$Amount | SubAbility$ DBCleanup | TriggerDescription$ Whenever a card is drawn this way, CARDNAME deals 5 damage to target opponent chosen at random from among your opponents.
SVar:DBImmediateTrigger:DB$ ImmediateTrigger | Execute$ TrigDamage | Secondary$ True | TriggerDescription$ Whenever a card is drawn this way, CARDNAME deals 5 damage to target opponent chosen at random from among your opponents.
SVar:TrigDamage:DB$ DealDamage | ValidTgts$ Player.Opponent | NumDmg$ 5 | TargetsAtRandom$ True SVar:TrigDamage:DB$ DealDamage | ValidTgts$ Player.Opponent | NumDmg$ 5 | TargetsAtRandom$ True
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
Oracle:Draw a card, then each other player may draw a card. Whenever a card is drawn this way, Explosion of Riches deals 5 damage to target opponent chosen at random from among your opponents. Oracle:Draw a card, then each other player may draw a card. Whenever a card is drawn this way, Explosion of Riches deals 5 damage to target opponent chosen at random from among your opponents.

View File

@@ -4,8 +4,8 @@ Types:Creature Human Rogue
PT:2/2 PT:2/2
K:Menace K:Menace
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigTreasure | OptionalDecider$ You | TriggerDescription$ At the beginning of your upkeep, you may create a Treasure token. When you do, target opponent creates a tapped Treasure token. T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigTreasure | OptionalDecider$ You | TriggerDescription$ At the beginning of your upkeep, you may create a Treasure token. When you do, target opponent creates a tapped Treasure token.
SVar:TrigTreasure:DB$ Token | TokenScript$ c_a_treasure_sac | RememberTokens$ True | SubAbility$ DBImmediateTrigger SVar:TrigTreasure:DB$ Token | TokenScript$ c_a_treasure_sac | RememberOriginalTokens$ True | SubAbility$ DBImmediateTrigger
SVar:DBImmediateTrigger:DB$ ImmediateTrigger | ConditionDefined$ Remembered | ConditionPresent$ Card | Execute$ TrigToken | RememberObjects$ RememberedCard | SubAbility$ DBCleanup | SpellDescription$ When you do, target opponent creates a tapped Treasure token. SVar:DBImmediateTrigger:DB$ ImmediateTrigger | Execute$ TrigToken | TriggerAmount$ Remembered$Amount | SubAbility$ DBCleanup | SpellDescription$ When you do, target opponent creates a tapped Treasure token.
SVar:TrigToken:DB$ Token | TokenAmount$ 1 | ValidTgts$ Opponent | TokenOwner$ Targeted | TokenScript$ c_a_treasure_sac | TokenTapped$ True SVar:TrigToken:DB$ Token | TokenAmount$ 1 | ValidTgts$ Opponent | TokenOwner$ Targeted | TokenScript$ c_a_treasure_sac | TokenTapped$ True
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigDamage | TriggerDescription$ Whenever CARDNAME attacks, it deals damage to defending player equal to the number of artifacts they control. T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigDamage | TriggerDescription$ Whenever CARDNAME attacks, it deals damage to defending player equal to the number of artifacts they control.