Skip to content

Commit ec9c94d

Browse files
tool4EvErtool4EvEr
authored andcommitted
Reduce some View updates
1 parent 309e368 commit ec9c94d

File tree

8 files changed

+24
-26
lines changed

8 files changed

+24
-26
lines changed

forge-game/src/main/java/forge/game/GameAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ public boolean visit(final Card c) {
12781278
c.updateNameforView();
12791279
c.updatePowerToughnessForView();
12801280
c.updateTypesForView();
1281-
c.updateAbilityTextForView(); // only update keywords and text for view to avoid flickering
1281+
c.updateKeywords();
12821282
}
12831283

12841284
// TODO filter out old copies from zone change

forge-game/src/main/java/forge/game/StaticEffect.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ final CardCollectionView remove(List<StaticAbilityLayer> layers) {
219219

220220
if (layers.contains(StaticAbilityLayer.TEXT)) {
221221
// Revert changed color words
222-
affectedCard.removeChangedTextColorWord(getTimestamp(), ability.getId());
222+
if (hasParam("ChangeColorWordsTo")) {
223+
affectedCard.removeChangedTextColorWord(getTimestamp(), ability.getId());
224+
}
223225

224226
// remove changed name
225227
if (hasParam("SetName") || hasParam("AddNames")) {
@@ -275,6 +277,9 @@ final CardCollectionView remove(List<StaticAbilityLayer> layers) {
275277
}
276278

277279
affectedCard.removeChangedSVars(getTimestamp(), ability.getId());
280+
281+
// need update for clean reapply
282+
affectedCard.updateKeywordsCache(affectedCard.getCurrentState());
278283
}
279284

280285
if (layers.contains(StaticAbilityLayer.SETPT)) {
@@ -311,8 +316,6 @@ final CardCollectionView remove(List<StaticAbilityLayer> layers) {
311316
affectedCard.removeCanBlockAdditional(getTimestamp());
312317
}
313318
}
314-
315-
affectedCard.updateAbilityTextForView(); // need to update keyword cache for clean reapply
316319
}
317320
return affectedCards;
318321
}

forge-game/src/main/java/forge/game/ability/effects/PumpEffect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void run() {
122122
}
123123
gameCard.updatePowerToughnessForView();
124124
if (updateText) {
125-
gameCard.updateAbilityTextForView();
125+
gameCard.updateKeywords();
126126
}
127127

128128
game.fireEvent(new GameEventCardStatsChanged(gameCard));

forge-game/src/main/java/forge/game/card/Card.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,7 @@ public void updateStateForView() {
600600
// The following methods are used to selectively update certain view components (text,
601601
// P/T, card types) in order to avoid card flickering due to aggressive full update
602602
public void updateAbilityTextForView() {
603-
updateKeywords(); // does call update Ability text
604-
//view.getCurrentState().updateAbilityText(this, getCurrentState());
603+
view.getCurrentState().updateAbilityText(this, getCurrentState());
605604
}
606605

607606
public void updateManaCostForView() {
@@ -1690,8 +1689,8 @@ public void addCounterInternal(final CounterType counterType, final int n, final
16901689
}
16911690
if (newValue <= 0) {
16921691
removeCounterTimestamp(counterType);
1693-
} else if (addCounterTimestamp(counterType)) {
1694-
updateAbilityTextForView();
1692+
} else if (addCounterTimestamp(counterType, false)) {
1693+
updateKeywords();
16951694
}
16961695
if (table != null) {
16971696
table.put(source, this, counterType, addAmount);
@@ -1789,8 +1788,8 @@ public final int subtractCounter(final CounterType counterName, final int n, fin
17891788
view.updateCounters(this);
17901789

17911790
if (newValue <= 0) {
1792-
if (removeCounterTimestamp(counterName)) {
1793-
updateAbilityTextForView();
1791+
if (removeCounterTimestamp(counterName, false)) {
1792+
updateKeywords();
17941793
}
17951794
}
17961795

@@ -1838,7 +1837,6 @@ public final void setCounters(final Map<CounterType, Integer> allCounters) {
18381837
}
18391838
if (changed) {
18401839
updateKeywords();
1841-
updateAbilityTextForView();
18421840
}
18431841
}
18441842

@@ -1856,7 +1854,6 @@ public final void clearCounters() {
18561854
}
18571855
if (changed) {
18581856
updateKeywords();
1859-
updateAbilityTextForView();
18601857
}
18611858
}
18621859

@@ -2169,7 +2166,7 @@ public String getCurrentRoom() {
21692166
public void setCurrentRoom(String room) {
21702167
currentRoom = room;
21712168
view.updateCurrentRoom(this);
2172-
view.getCurrentState().updateAbilityText(this, getCurrentState());
2169+
updateAbilityTextForView();
21732170
}
21742171
public boolean isInLastRoom() {
21752172
for (final Trigger t : getTriggers()) {
@@ -4896,7 +4893,6 @@ public final void addChangedCardTraitsByText(Collection<SpellAbility> spells,
48964893
changedCardTraitsByText.put(timestamp, staticId, new CardTraitChanges(
48974894
spells, null, trigger, replacements, statics, true, false
48984895
));
4899-
// update view
49004896
updateAbilityTextForView();
49014897
}
49024898

@@ -5046,13 +5042,11 @@ public final void addChangedCardTraits(Collection<SpellAbility> spells, Collecti
50465042
changedCardTraits.put(timestamp, staticId, new CardTraitChanges(
50475043
spells, removedAbilities, trigger, replacements, statics, removeAll, removeNonMana
50485044
));
5049-
// update view
50505045
updateAbilityTextForView();
50515046
}
50525047

50535048
public final void addChangedCardTraits(CardTraitChanges ctc, long timestamp, long staticId) {
50545049
changedCardTraits.put(timestamp, staticId, ctc);
5055-
// update view
50565050
updateAbilityTextForView();
50575051
}
50585052

@@ -5144,6 +5138,7 @@ public final boolean hasKeyword(String keyword, CardState state) {
51445138

51455139
public final void updateKeywords() {
51465140
getCurrentState().getView().updateKeywords(this, getCurrentState());
5141+
// for Zilortha
51475142
getView().updateLethalDamage(this);
51485143
}
51495144

@@ -5434,7 +5429,7 @@ public void updateChangedText() {
54345429
getView().updateChangedTypes(this);
54355430
updateManaCostForView();
54365431

5437-
currentState.getView().updateAbilityText(this, currentState);
5432+
updateAbilityTextForView();
54385433
view.updateNonAbilityText(this);
54395434
}
54405435

@@ -6796,7 +6791,7 @@ public final int getClassLevel() {
67966791
public void setClassLevel(int level) {
67976792
classLevel = level;
67986793
view.updateClassLevel(this);
6799-
view.getCurrentState().updateAbilityText(this, getCurrentState());
6794+
updateAbilityTextForView();
68006795
}
68016796
public boolean isClassCard() {
68026797
return getType().hasStringType("Class");

forge-game/src/main/java/forge/game/card/CardView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,9 @@ void updateAbilityText(Card c, CardState state) {
16031603
}
16041604
void updateKeywords(Card c, CardState state) {
16051605
c.updateKeywordsCache(state);
1606+
// deeper check for Idris
16061607
set(TrackableProperty.HasAnnihilator, c.hasKeyword(Keyword.ANNIHILATOR, state) || state.getTriggers().anyMatch(t -> t.isKeyword(Keyword.ANNIHILATOR)));
1608+
set(TrackableProperty.HasWard, c.hasKeyword(Keyword.WARD, state) || state.getTriggers().anyMatch(t -> t.isKeyword(Keyword.WARD)));
16071609
set(TrackableProperty.HasDeathtouch, c.hasKeyword(Keyword.DEATHTOUCH, state));
16081610
set(TrackableProperty.HasToxic, c.hasKeyword(Keyword.TOXIC, state));
16091611
set(TrackableProperty.HasDevoid, c.hasKeyword(Keyword.DEVOID, state));
@@ -1617,7 +1619,6 @@ void updateKeywords(Card c, CardState state) {
16171619
set(TrackableProperty.HasFear, c.hasKeyword(Keyword.FEAR, state));
16181620
set(TrackableProperty.HasHexproof, c.hasKeyword(Keyword.HEXPROOF, state));
16191621
set(TrackableProperty.HasHorsemanship, c.hasKeyword(Keyword.HORSEMANSHIP, state));
1620-
set(TrackableProperty.HasWard, c.hasKeyword(Keyword.WARD, state) || state.getTriggers().anyMatch(t -> t.isKeyword(Keyword.WARD)));
16211622
set(TrackableProperty.HasWither, c.hasKeyword(Keyword.WITHER, state));
16221623
set(TrackableProperty.HasIndestructible, c.hasKeyword(Keyword.INDESTRUCTIBLE, state));
16231624
set(TrackableProperty.HasIntimidate, c.hasKeyword(Keyword.INTIMIDATE, state));

forge-game/src/main/java/forge/game/player/Player.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,6 @@ public void updateKeywordCardAbilityText() {
36153615
return;
36163616
final PlayerZone com = getZone(ZoneType.Command);
36173617
keywordEffect.setText("");
3618-
keywordEffect.updateAbilityTextForView();
36193618
boolean headerAdded = false;
36203619
StringBuilder kw = new StringBuilder();
36213620
for (KeywordInterface k : keywords) {
@@ -3627,8 +3626,8 @@ public void updateKeywordCardAbilityText() {
36273626
}
36283627
if (!kw.toString().isEmpty()) {
36293628
keywordEffect.setText(trimKeywords(kw.toString()));
3630-
keywordEffect.updateAbilityTextForView();
36313629
}
3630+
keywordEffect.updateAbilityTextForView();
36323631
this.updateZoneForView(com);
36333632
}
36343633
public String trimKeywords(String keywordTexts) {

forge-gui/res/cardsfolder/upcoming/pit_automaton.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Types:Artifact Creature Construct
44
PT:0/4
55
K:Defender
66
A:AB$ Mana | Cost$ T | Produced$ C | Amount$ 2 | RestrictValid$ Activated | SpellDescription$ Add {C}{C}. Spend this mana only to activate abilities.
7-
A:AB$ DelayedTrigger | Cost$ 2 T | AILogic$ SpellCopy | Mode$ AbilityCast | ValidSA$ Activated.Exhaust | ValidActivatingPlayer$ You | ThisTurn$ True | Execute$ EffTrigCopy | SpellDescription$ When you next activate an exhaust ability this turn, copy it. You may choose new targets for the copy.
7+
A:AB$ DelayedTrigger | Cost$ 2 T | AILogic$ SpellCopy | Mode$ AbilityCast | ValidSA$ Activated.Exhaust+nonManaAbility | ValidActivatingPlayer$ You | ThisTurn$ True | Execute$ EffTrigCopy | SpellDescription$ When you next activate an exhaust ability that isn't a mana ability this turn, copy it. You may choose new targets for the copy.
88
SVar:EffTrigCopy:DB$ CopySpellAbility | Defined$ TriggeredSpellAbility | MayChooseTarget$ True
9-
Oracle:Defender\n{T}: Add {C}{C}. Spend this mana only to activate abilities.\n{2}, {T}: When you next activate an exhaust ability this turn, copy it. You may choose new targets for the copy.
9+
Oracle:Defender\n{T}: Add {C}{C}. Spend this mana only to activate abilities.\n{2}, {T}: When you next activate an exhaust ability that isn't a mana ability this turn, copy it. You may choose new targets for the copy.

forge-gui/res/cardsfolder/upcoming/rangers_refueler.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Name:Rangers' Refueler
22
ManaCost:1 U
33
Types:Artifact Vehicle
44
PT:3/3
5-
T:Mode$ AbilityCast | ValidActivatingPlayer$ You | ValidSA$ Activated.Exhaust | TriggerZones$ Battlefield | Execute$ TrigToken | TriggerDescription$ Whenever you activate an exhaust ability, create a 1/1 colorless Thopter artifact creature token with flying.
6-
SVar:TrigToken:DB$ Token | TokenAmount$ 1 | TokenScript$ c_1_1_a_thopter_flying | TokenOwner$ You
5+
T:Mode$ AbilityCast | ValidActivatingPlayer$ You | ValidSA$ Activated.Exhaust | TriggerZones$ Battlefield | Execute$ TrigDraw | TriggerDescription$ Whenever you activate an exhaust ability, draw a card.
6+
SVar:TrigDraw:DB$ Draw
77
A:AB$ Animate | Cost$ 4 | Defined$ Self | Types$ Artifact,Creature | Exhaust$ True | Duration$ Permanent | SubAbility$ DBPutCounter | SpellDescription$ This Vehicle becomes an artifact creature. Put a +1/+1 counter on it. (Activate each exhaust ability only once.)
88
SVar:DBPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1
99
K:Crew:1

0 commit comments

Comments
 (0)