mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Card & Player: more fixes with setCounters
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|||||||
Reference in New Issue
Block a user