Fix GameState counters for Permanents

This commit is contained in:
Sol
2017-04-09 02:36:22 +00:00
parent fdca55ae7e
commit 54de9f1009
2 changed files with 8 additions and 5 deletions

View File

@@ -328,11 +328,10 @@ public abstract class GameState {
} }
private void applyCountersToGameEntity(GameEntity entity, String counterString) { private void applyCountersToGameEntity(GameEntity entity, String counterString) {
entity.setCounters(new HashMap<CounterType, Integer>()); //entity.setCounters(new HashMap<CounterType, Integer>());
String[] allCounterStrings = counterString.split(","); String[] allCounterStrings = counterString.split(",");
for (final String counterPair : allCounterStrings) { for (final String counterPair : allCounterStrings) {
String[] pair = counterPair.split("=", 2); String[] pair = counterPair.split("=", 2);
entity.addCounter(CounterType.valueOf(pair[0]), Integer.parseInt(pair[1]), false, false); entity.addCounter(CounterType.valueOf(pair[0]), Integer.parseInt(pair[1]), false, false);
} }
} }

View File

@@ -1022,10 +1022,10 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
setTotalCountersToAdd(addAmount); setTotalCountersToAdd(addAmount);
final Integer oldValue = getCounters(counterType);
final Integer newValue = addAmount + (oldValue == null ? 0 : oldValue);
if (fireEvents) { if (fireEvents) {
final Integer oldValue = getCounters(counterType); // Not sure why firing events wraps EVERYTHING ins
final Integer newValue = addAmount + (oldValue == null ? 0 : oldValue);
if (!newValue.equals(oldValue)) { if (!newValue.equals(oldValue)) {
final int powerBonusBefore = getPowerBonusFromCounters(); final int powerBonusBefore = getPowerBonusFromCounters();
final int toughnessBonusBefore = getToughnessBonusFromCounters(); final int toughnessBonusBefore = getToughnessBonusFromCounters();
@@ -1054,6 +1054,10 @@ public class Card extends GameEntity implements Comparable<Card> {
if (addAmount > 0) { if (addAmount > 0) {
getGame().getTriggerHandler().runTrigger(TriggerType.CounterAddedOnce, runParams, false); getGame().getTriggerHandler().runTrigger(TriggerType.CounterAddedOnce, runParams, false);
} }
} else {
setCounters(counterType, newValue);
getController().addCounterToPermThisTurn(counterType, addAmount);
view.updateCounters(this);
} }
} }