From 35dd052c93a751cd37ed2f71d27f85445b85fbac Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Fri, 8 May 2020 03:38:44 +0000 Subject: [PATCH] LethalDamage: update Property when PT or counter changes --- .../ability/effects/DamageDealEffect.java | 2 +- .../src/main/java/forge/game/card/Card.java | 23 +++++++++++-------- .../main/java/forge/game/card/CardView.java | 8 +++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java index 21c293c2098..9aeeee88eee 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DamageDealEffect.java @@ -257,7 +257,7 @@ public class DamageDealEffect extends DamageBaseEffect { if (sa.hasParam("ExcessDamage") && (!sa.hasParam("ExcessDamageCondition") || sourceLKI.isValid(sa.getParam("ExcessDamageCondition").split(","), activationPlayer, hostCard, sa))) { // excess damage explicit says toughness, not lethal damage in the rules - int lethal = c.getNetToughness() - c.getDamage(); + int lethal = c.getLethalDamage(); if (sourceLKI.hasKeyword(Keyword.DEATHTOUCH)) { lethal = Math.min(lethal, 1); } 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 8801350f6e9..aedfcf7cfcc 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -479,7 +479,7 @@ public class Card extends GameEntity implements Comparable { currentState.getView().updateColors(this); } if (!changedCardKeywords.isEmpty()) { - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } if (state == CardStateName.FaceDown) { @@ -545,7 +545,7 @@ public class Card extends GameEntity implements Comparable { // 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() { - view.getCurrentState().updateKeywords(this, getCurrentState()); + updateKeywords(); view.getCurrentState().updateAbilityText(this, getCurrentState()); } @@ -3482,6 +3482,7 @@ public class Card extends GameEntity implements Comparable { } else { newPT.put(timestamp, Pair.of(power, toughness)); } + getView().updateLethalDamage(this); currentState.getView().updatePower(this); currentState.getView().updateToughness(this); } @@ -3493,6 +3494,7 @@ public class Card extends GameEntity implements Comparable { removed |= newPTCharacterDefining.remove(timestamp) != null; if (removed) { + getView().updateLethalDamage(this); currentState.getView().updatePower(this); currentState.getView().updateToughness(this); } @@ -3783,7 +3785,8 @@ public class Card extends GameEntity implements Comparable { } public final void updateKeywords() { - currentState.getView().updateKeywords(this, currentState); + getCurrentState().getView().updateKeywords(this, getCurrentState()); + getView().updateLethalDamage(this); } public final void addChangedCardKeywords(final List keywords, final List removeKeywords, @@ -4065,7 +4068,7 @@ public class Card extends GameEntity implements Comparable { public final KeywordInterface addIntrinsicKeyword(final String s) { KeywordInterface inst = currentState.addIntrinsicKeyword(s, true); if (inst != null) { - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } return inst; } @@ -4075,19 +4078,19 @@ public class Card extends GameEntity implements Comparable { } public final void addIntrinsicKeywords(final Iterable s, boolean initTraits) { if (currentState.addIntrinsicKeywords(s, initTraits)) { - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } } public final void removeIntrinsicKeyword(final String s) { if (currentState.removeIntrinsicKeyword(s)) { - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } } public final void removeIntrinsicKeyword(final KeywordInterface s) { if (currentState.removeIntrinsicKeyword(s)) { - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } } @@ -4111,14 +4114,14 @@ public class Card extends GameEntity implements Comparable { } if (hiddenExtrinsicKeyword.add(s) != null) { view.updateNonAbilityText(this); - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } } public final void addHiddenExtrinsicKeyword(KeywordInterface k) { if (hiddenExtrinsicKeyword.insert(k)) { view.updateNonAbilityText(this); - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } } @@ -4128,7 +4131,7 @@ public class Card extends GameEntity implements Comparable { } if (hiddenExtrinsicKeyword.remove(s)) { view.updateNonAbilityText(this); - currentState.getView().updateKeywords(this, currentState); + updateKeywords(); } } diff --git a/forge-game/src/main/java/forge/game/card/CardView.java b/forge-game/src/main/java/forge/game/card/CardView.java index 0bb3d1b0530..9a1939bd67d 100644 --- a/forge-game/src/main/java/forge/game/card/CardView.java +++ b/forge-game/src/main/java/forge/game/card/CardView.java @@ -243,6 +243,7 @@ public class CardView extends GameEntityView { } void updateCounters(Card c) { set(TrackableProperty.Counters, c.getCounters()); + updateLethalDamage(c); CardStateView state = getCurrentState(); state.updatePower(c); state.updateToughness(c); @@ -254,7 +255,7 @@ public class CardView extends GameEntityView { } void updateDamage(Card c) { set(TrackableProperty.Damage, c.getDamage()); - set(TrackableProperty.LethalDamage, c.getLethalDamage()); + updateLethalDamage(c); } public int getAssignedDamage() { @@ -262,12 +263,15 @@ public class CardView extends GameEntityView { } void updateAssignedDamage(Card c) { set(TrackableProperty.AssignedDamage, c.getTotalAssignedDamage()); - set(TrackableProperty.LethalDamage, c.getLethalDamage()); + updateLethalDamage(c); } public int getLethalDamage() { return get(TrackableProperty.LethalDamage); } + void updateLethalDamage(Card c) { + set(TrackableProperty.LethalDamage, c.getLethalDamage()); + } public int getShieldCount() { return get(TrackableProperty.ShieldCount);