From d85e623bff6a5bbabfd0023fec646c8e0f3c9e22 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 15 Jun 2022 07:24:24 +0200 Subject: [PATCH] GameAction: fix timestamp and trigger for etb (#670) * GameAction: fix trigger by etb counter --- .../src/main/java/forge/game/GameAction.java | 35 ++++++------------- .../java/forge/game/ability/AbilityUtils.java | 6 ---- .../res/cardsfolder/upcoming/master_chef.txt | 2 +- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 8e650d1ae22..e4eb7cbbb03 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -246,10 +246,6 @@ public class GameAction { lastKnownInfo = CardUtil.getLKICopy(c); } - if (!suppress) { - copied.setTimestamp(game.getNextTimestamp()); - } - if (!lastKnownInfo.hasKeyword("Counters remain on CARDNAME as it moves to any zone other than a player's hand or library.")) { copied.clearCounters(); } @@ -274,6 +270,8 @@ public class GameAction { copied = CardFactory.copyCard(c, false); } + copied.setTimestamp(c.getTimestamp()); + if (zoneTo.is(ZoneType.Stack)) { // when moving to stack, copy changed card information copied.setChangedCardColors(c.getChangedCardColorsTable()); @@ -286,7 +284,6 @@ public class GameAction { copied.setDrawnThisTurn(c.getDrawnThisTurn()); copied.copyChangedTextFrom(c); - copied.setTimestamp(c.getTimestamp()); // clean up changes that come from its own static abilities copied.cleanupCopiedChangesFrom(c); @@ -304,9 +301,6 @@ public class GameAction { // on Transformed objects) copied.setState(CardStateName.Original, false); copied.setBackSide(false); - - // reset timestamp in changezone effects so they have same timestamp if ETB simultaneously - copied.setTimestamp(game.getNextTimestamp()); } copied.setUnearthed(c.isUnearthed()); @@ -388,6 +382,11 @@ public class GameAction { } } + if (!zoneTo.is(ZoneType.Stack) && !suppress) { + // reset timestamp in changezone effects so they have same timestamp if ETB simultaneously + copied.setTimestamp(game.getNextTimestamp()); + } + copied.getOwner().removeInboundToken(copied); // Aura entering as Copy from stack @@ -491,15 +490,6 @@ public class GameAction { GameEntityCounterTable table = new GameEntityCounterTable(); - // need to suspend cards own replacement effects - if (!suppress) { - if (toBattlefield && !copied.getEtbCounters().isEmpty()) { - for (final ReplacementEffect re : copied.getReplacementEffects()) { - re.setSuppressed(true); - } - } - } - if (mergedCards != null) { // Move components of merged permanent here // Also handle 723.3e and 903.9a @@ -546,14 +536,9 @@ public class GameAction { } // do ETB counters after zone add - if (!suppress) { - if (toBattlefield) { - copied.putEtbCounters(table); - // enable replacement effects again - for (final ReplacementEffect re : copied.getReplacementEffects()) { - re.setSuppressed(false); - } - } + if (!suppress && toBattlefield && !copied.getEtbCounters().isEmpty()) { + game.getTriggerHandler().registerActiveTrigger(copied, false); + copied.putEtbCounters(table); copied.clearEtbCounters(); } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 5461441ab2d..18190a19b1c 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -55,7 +55,6 @@ import forge.game.phase.PhaseHandler; import forge.game.player.Player; import forge.game.player.PlayerCollection; import forge.game.player.PlayerPredicates; -import forge.game.replacement.ReplacementType; import forge.game.spellability.AbilitySub; import forge.game.spellability.LandAbility; import forge.game.spellability.OptionalCost; @@ -218,11 +217,6 @@ public class AbilityUtils { else if (defined.startsWith("Replaced") && sa instanceof SpellAbility) { final SpellAbility root = ((SpellAbility)sa).getRootAbility(); AbilityKey type = AbilityKey.fromString(defined.substring(8)); - // for Moved Effects, if it wants to know the affected Card, it might need to return the LKI - // or otherwise the timestamp does match - if (type == AbilityKey.Card && root.isReplacementAbility() && root.getReplacementEffect().getMode() == ReplacementType.Moved) { - type = AbilityKey.CardLKI; - } final Object crd = root.getReplacingObject(type); if (crd instanceof Card) { diff --git a/forge-gui/res/cardsfolder/upcoming/master_chef.txt b/forge-gui/res/cardsfolder/upcoming/master_chef.txt index 272815e24fe..4164d2d67f1 100644 --- a/forge-gui/res/cardsfolder/upcoming/master_chef.txt +++ b/forge-gui/res/cardsfolder/upcoming/master_chef.txt @@ -3,7 +3,7 @@ ManaCost:2 G Types:Legendary Enchantment Background S:Mode$ Continuous | Affected$ Creature.IsCommander+YouOwn | AddReplacementEffects$ This & Other | Description$ Commander creatures you own have "This creature enters the battlefield with an additional +1/+1 counter on it" and "Other creatures you control enter with an additional +1/+1 counter on them." SVar:This:Event$ Moved | ValidCard$ Card.Self | Destination$ Battlefield | ReplaceWith$ ExtraCounter | ReplacementResult$ Updated | Description$ This creature enters the battlefield with an additional +1/+1 counter on it. -SVar:Other:Event$ Moved | ValidCard$ Creature.Other+YouCtrl | Destination$ Battlefield | ReplaceWith$ ExtraCounter | ReplacementResult$ Updated | Description$ Other creatures you control enter with an additional +1/+1 counter on them. +SVar:Other:Event$ Moved | ValidCard$ Creature.Other+YouCtrl | ActiveZones$ Battlefield | Destination$ Battlefield | ReplaceWith$ ExtraCounter | ReplacementResult$ Updated | Description$ Other creatures you control enter with an additional +1/+1 counter on them. SVar:ExtraCounter:DB$ PutCounter | ETB$ True | Defined$ ReplacedCard | CounterType$ P1P1 AI:RemoveDeck:NonCommander DeckHas:Ability$Counters