Card: fix Grist again

This commit is contained in:
Hans Mackowiak
2021-10-09 10:37:36 +02:00
parent 029b72573b
commit 93a0a83854
3 changed files with 25 additions and 13 deletions

View File

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

View File

@@ -555,8 +555,8 @@ public class Card extends GameEntity implements Comparable<Card>, 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,11 +4347,11 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
}
public final void removeChangedTextColorWord(final Long timestamp, final long staticId) {
changedTextColors.remove(timestamp);
updateKeywordsOnRemoveChangedText(
removeChangedCardKeywords(timestamp, staticId));
if (changedTextColors.remove(timestamp)) {
updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp, staticId));
updateChangedText();
}
}
/**
* Replace all instances of one type in this card's text by another.
@@ -4370,12 +4370,12 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
}
public final void removeChangedTextTypeWord(final Long timestamp, final long staticId) {
changedTextTypes.remove(timestamp);
if (changedTextTypes.remove(timestamp)) {
removeChangedCardTypes(timestamp, staticId);
updateKeywordsOnRemoveChangedText(
removeChangedCardKeywords(timestamp, staticId));
updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp, staticId));
updateChangedText();
}
}
private void updateKeywordsChangedText(final Long timestamp, final long staticId) {
if (hasSVar("LockInKeywords")) {
@@ -6654,6 +6654,15 @@ public class Card extends GameEntity implements Comparable<Card>, 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);

View File

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