LethalDamage: update Property when PT or counter changes

This commit is contained in:
Hans Mackowiak
2020-05-08 03:38:44 +00:00
committed by Michael Kamensky
parent 09d2e1fb30
commit 35dd052c93
3 changed files with 20 additions and 13 deletions

View File

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

View File

@@ -479,7 +479,7 @@ public class Card extends GameEntity implements Comparable<Card> {
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<Card> {
// 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<Card> {
} 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<Card> {
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<Card> {
}
public final void updateKeywords() {
currentState.getView().updateKeywords(this, currentState);
getCurrentState().getView().updateKeywords(this, getCurrentState());
getView().updateLethalDamage(this);
}
public final void addChangedCardKeywords(final List<String> keywords, final List<String> removeKeywords,
@@ -4065,7 +4068,7 @@ public class Card extends GameEntity implements Comparable<Card> {
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<Card> {
}
public final void addIntrinsicKeywords(final Iterable<String> 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<Card> {
}
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<Card> {
}
if (hiddenExtrinsicKeyword.remove(s)) {
view.updateNonAbilityText(this);
currentState.getView().updateKeywords(this, currentState);
updateKeywords();
}
}

View File

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