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.copyChangedTextFrom(c);
copied.setTimestamp(c.getTimestamp()); copied.setTimestamp(c.getTimestamp());
// clean up changes that come from its own static abilities
copied.cleanupCopiedChangesFrom(c);
// copy exiled properties when adding to stack // copy exiled properties when adding to stack
// will be cleanup later in MagicStack // will be cleanup later in MagicStack
copied.setExiledWith(c.getExiledWith()); 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, // 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 // P/T, card types) in order to avoid card flickering due to aggressive full update
public void updateAbilityTextForView() { public void updateAbilityTextForView() {
updateKeywords(); updateKeywords(); // does call update Ability text
view.getCurrentState().updateAbilityText(this, getCurrentState()); //view.getCurrentState().updateAbilityText(this, getCurrentState());
} }
public final void updatePowerToughnessForView() { public final void updatePowerToughnessForView() {
@@ -4347,10 +4347,10 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
public final void removeChangedTextColorWord(final Long timestamp, final long staticId) { public final void removeChangedTextColorWord(final Long timestamp, final long staticId) {
changedTextColors.remove(timestamp); if (changedTextColors.remove(timestamp)) {
updateKeywordsOnRemoveChangedText( updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp, staticId));
removeChangedCardKeywords(timestamp, staticId)); updateChangedText();
updateChangedText(); }
} }
/** /**
@@ -4370,11 +4370,11 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
public final void removeChangedTextTypeWord(final Long timestamp, final long staticId) { public final void removeChangedTextTypeWord(final Long timestamp, final long staticId) {
changedTextTypes.remove(timestamp); if (changedTextTypes.remove(timestamp)) {
removeChangedCardTypes(timestamp, staticId); removeChangedCardTypes(timestamp, staticId);
updateKeywordsOnRemoveChangedText( updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp, staticId));
removeChangedCardKeywords(timestamp, staticId)); updateChangedText();
updateChangedText(); }
} }
private void updateKeywordsChangedText(final Long timestamp, final long staticId) { private void updateKeywordsChangedText(final Long timestamp, final long staticId) {
@@ -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() { public void forceTurnFaceUp() {
getGame().getTriggerHandler().suppressMode(TriggerType.TurnFaceUp); getGame().getTriggerHandler().suppressMode(TriggerType.TurnFaceUp);
turnFaceUp(false, false, null); turnFaceUp(false, false, null);

View File

@@ -24,9 +24,9 @@ public final class CardChangedWords {
return stamp; return stamp;
} }
public void remove(final Long timestamp) { public boolean remove(final Long timestamp) {
map.remove(timestamp);
isDirty = true; isDirty = true;
return map.remove(timestamp) != null;
} }
public void removeAll() { public void removeAll() {