GameAction: fix timestamp and trigger for etb (#670)

* GameAction: fix trigger by etb counter
This commit is contained in:
Hans Mackowiak
2022-06-15 07:24:24 +02:00
committed by GitHub
parent 864572a06e
commit d85e623bff
3 changed files with 11 additions and 32 deletions

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -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