From 93a0a83854e294ba75324e94ab67cf6e6739e29e Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Sat, 9 Oct 2021 10:37:36 +0200 Subject: [PATCH] Card: fix Grist again --- .../src/main/java/forge/game/GameAction.java | 3 ++ .../src/main/java/forge/game/card/Card.java | 31 ++++++++++++------- .../forge/game/card/CardChangedWords.java | 4 +-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 4ba4286662c..e54fb643b4e 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -285,6 +285,9 @@ public class GameAction { copied.copyChangedTextFrom(c); copied.setTimestamp(c.getTimestamp()); + // clean up changes that come from its own static abilities + copied.cleanupCopiedChangesFrom(c); + // copy exiled properties when adding to stack // will be cleanup later in MagicStack copied.setExiledWith(c.getExiledWith()); diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index cdbf39337e9..6c9b8d9bc8a 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -555,8 +555,8 @@ public class Card extends GameEntity implements Comparable, IHasSVars { // The following methods are used to selectively update certain view components (text, // P/T, card types) in order to avoid card flickering due to aggressive full update public void updateAbilityTextForView() { - updateKeywords(); - view.getCurrentState().updateAbilityText(this, getCurrentState()); + updateKeywords(); // does call update Ability text + //view.getCurrentState().updateAbilityText(this, getCurrentState()); } public final void updatePowerToughnessForView() { @@ -4347,10 +4347,10 @@ public class Card extends GameEntity implements Comparable, IHasSVars { } public final void removeChangedTextColorWord(final Long timestamp, final long staticId) { - changedTextColors.remove(timestamp); - updateKeywordsOnRemoveChangedText( - removeChangedCardKeywords(timestamp, staticId)); - updateChangedText(); + if (changedTextColors.remove(timestamp)) { + updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp, staticId)); + updateChangedText(); + } } /** @@ -4370,11 +4370,11 @@ public class Card extends GameEntity implements Comparable, IHasSVars { } public final void removeChangedTextTypeWord(final Long timestamp, final long staticId) { - changedTextTypes.remove(timestamp); - removeChangedCardTypes(timestamp, staticId); - updateKeywordsOnRemoveChangedText( - removeChangedCardKeywords(timestamp, staticId)); - updateChangedText(); + if (changedTextTypes.remove(timestamp)) { + removeChangedCardTypes(timestamp, staticId); + updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp, staticId)); + updateChangedText(); + } } private void updateKeywordsChangedText(final Long timestamp, final long staticId) { @@ -6654,6 +6654,15 @@ public class Card extends GameEntity implements Comparable, IHasSVars { } } + public void cleanupCopiedChangesFrom(Card c) { + for (StaticAbility stAb : c.getStaticAbilities()) { + this.removeChangedCardTypes(c.getTimestamp(), stAb.getId(), false); + this.removeColor(c.getTimestamp(), stAb.getId()); + this.removeChangedCardKeywords(c.getTimestamp(), stAb.getId(), false); + this.removeChangedCardTraits(c.getTimestamp(), stAb.getId()); + } + } + public void forceTurnFaceUp() { getGame().getTriggerHandler().suppressMode(TriggerType.TurnFaceUp); turnFaceUp(false, false, null); diff --git a/forge-game/src/main/java/forge/game/card/CardChangedWords.java b/forge-game/src/main/java/forge/game/card/CardChangedWords.java index ae8719dee69..320eeef0282 100644 --- a/forge-game/src/main/java/forge/game/card/CardChangedWords.java +++ b/forge-game/src/main/java/forge/game/card/CardChangedWords.java @@ -24,9 +24,9 @@ public final class CardChangedWords { return stamp; } - public void remove(final Long timestamp) { - map.remove(timestamp); + public boolean remove(final Long timestamp) { isDirty = true; + return map.remove(timestamp) != null; } public void removeAll() {