mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Fix issue where loyalty didn't update as counters added/removed
This commit is contained in:
@@ -1214,7 +1214,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (counterType == CounterType.DREAM && this.hasKeyword("CARDNAME can't have more than seven dream counters on it.")) {
|
if (counterType == CounterType.DREAM && this.hasKeyword("CARDNAME can't have more than seven dream counters on it.")) {
|
||||||
addAmount = Math.min(7 - this.getCounters(CounterType.DREAM), addAmount);
|
addAmount = Math.min(7 - this.getCounters(CounterType.DREAM), addAmount);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
addAmount = 0;
|
addAmount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1225,13 +1226,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
int powerBonusBefore = this.getPowerBonusFromCounters();
|
int powerBonusBefore = this.getPowerBonusFromCounters();
|
||||||
int toughnessBonusBefore = this.getToughnessBonusFromCounters();
|
int toughnessBonusBefore = this.getToughnessBonusFromCounters();
|
||||||
|
int loyaltyBefore = this.getCurrentLoyalty();
|
||||||
|
|
||||||
Integer oldValue = this.counters.get(counterType);
|
Integer oldValue = this.counters.get(counterType);
|
||||||
int newValue = addAmount + (oldValue == null ? 0 : oldValue.intValue());
|
int newValue = addAmount + (oldValue == null ? 0 : oldValue.intValue());
|
||||||
this.counters.put(counterType, Integer.valueOf(newValue));
|
this.counters.put(counterType, Integer.valueOf(newValue));
|
||||||
|
|
||||||
//fire card stats changed event if p/t bonuses changed from added counters
|
//fire card stats changed event if p/t bonuses or loyalty changed from added counters
|
||||||
if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters()) {
|
if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters() || loyaltyBefore != getCurrentLoyalty()) {
|
||||||
getGame().fireEvent(new GameEventCardStatsChanged(this));
|
getGame().fireEvent(new GameEventCardStatsChanged(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1300,6 +1302,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
int powerBonusBefore = this.getPowerBonusFromCounters();
|
int powerBonusBefore = this.getPowerBonusFromCounters();
|
||||||
int toughnessBonusBefore = this.getToughnessBonusFromCounters();
|
int toughnessBonusBefore = this.getToughnessBonusFromCounters();
|
||||||
|
int loyaltyBefore = this.getCurrentLoyalty();
|
||||||
|
|
||||||
if (newValue > 0) {
|
if (newValue > 0) {
|
||||||
this.counters.put(counterName, Integer.valueOf(newValue));
|
this.counters.put(counterName, Integer.valueOf(newValue));
|
||||||
@@ -1308,8 +1311,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
this.counters.remove(counterName);
|
this.counters.remove(counterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fire card stats changed event if p/t bonuses changed from subtracted counters
|
//fire card stats changed event if p/t bonuses or loyalty changed from subtracted counters
|
||||||
if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters()) {
|
if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters() || loyaltyBefore != getCurrentLoyalty()) {
|
||||||
getGame().fireEvent(new GameEventCardStatsChanged(this));
|
getGame().fireEvent(new GameEventCardStatsChanged(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user