Card & Player: more fixes with setCounters

This commit is contained in:
Hanmac
2017-01-11 07:02:43 +00:00
parent 5055435222
commit 7c0a8412c9
2 changed files with 3 additions and 3 deletions

View File

@@ -1015,7 +1015,7 @@ public class Card extends GameEntity implements Comparable<Card> {
setTotalCountersToAdd(addAmount); setTotalCountersToAdd(addAmount);
if (fireEvents) { if (fireEvents) {
final Integer oldValue = counters.get(counterType); final Integer oldValue = getCounters(counterType);
final Integer newValue = addAmount + (oldValue == null ? 0 : oldValue); final Integer newValue = addAmount + (oldValue == null ? 0 : oldValue);
if (!newValue.equals(oldValue)) { if (!newValue.equals(oldValue)) {
@@ -1083,7 +1083,7 @@ public class Card extends GameEntity implements Comparable<Card> {
@Override @Override
public final void subtractCounter(final CounterType counterName, final int n) { public final void subtractCounter(final CounterType counterName, final int n) {
Integer oldValue = counters.get(counterName); Integer oldValue = getCounters(counterName);
int newValue = oldValue == null ? 0 : Math.max(oldValue - n, 0); int newValue = oldValue == null ? 0 : Math.max(oldValue - n, 0);
final int delta = (oldValue == null ? 0 : oldValue) - newValue; final int delta = (oldValue == null ? 0 : oldValue) - newValue;

View File

@@ -940,7 +940,7 @@ public class Player extends GameEntity implements Comparable<Player> {
public void setCounters(final CounterType counterType, final Integer num, boolean fireEvents) { public void setCounters(final CounterType counterType, final Integer num, boolean fireEvents) {
Integer old = getCounters(counterType); Integer old = getCounters(counterType);
counters.put(counterType, num); setCounters(counterType, num);
view.updateCounters(this); view.updateCounters(this);
if (fireEvents) { if (fireEvents) {
getGame().fireEvent(new GameEventPlayerCounters(this, counterType, old, num)); getGame().fireEvent(new GameEventPlayerCounters(this, counterType, old, num));