Fix counter placement sound playing repeatedly.

This commit is contained in:
elcnesh
2014-09-29 09:08:45 +00:00
parent 97a46fae15
commit 9ce50662fe
2 changed files with 23 additions and 13 deletions

View File

@@ -758,7 +758,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
pumped.addChangedCardKeywords(kws, new ArrayList<String>(), false, timestamp); pumped.addChangedCardKeywords(kws, new ArrayList<String>(), false, timestamp);
Set<CounterType> types = c.getCounters().keySet(); Set<CounterType> types = c.getCounters().keySet();
for(CounterType ct : types) { for(CounterType ct : types) {
pumped.addCounter(ct, c.getCounters(ct), true); pumped.addCounterFireNoEvents(ct, c.getCounters(ct), true);
} }
//Copies tap-state and extra keywords (auras, equipment, etc.) //Copies tap-state and extra keywords (auras, equipment, etc.)
if (c.isTapped()) { if (c.isTapped()) {

View File

@@ -1194,6 +1194,13 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
} }
public final void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier) { public final void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier) {
this.addCounter(counterType, n, applyMultiplier, true);
}
public final void addCounterFireNoEvents(final CounterType counterType, final int n, final boolean applyMultiplier) {
this.addCounter(counterType, n, applyMultiplier, false);
}
private void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier, final boolean fireEvents) {
int addAmount = n; int addAmount = n;
final HashMap<String, Object> repParams = new HashMap<String, Object>(); final HashMap<String, Object> repParams = new HashMap<String, Object>();
repParams.put("Event", "AddCounter"); repParams.put("Event", "AddCounter");
@@ -1218,14 +1225,16 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
} }
this.setTotalCountersToAdd(addAmount); this.setTotalCountersToAdd(addAmount);
int powerBonusBefore = this.getPowerBonusFromCounters(); if (fireEvents) {
int toughnessBonusBefore = this.getToughnessBonusFromCounters(); final int powerBonusBefore = this.getPowerBonusFromCounters();
int loyaltyBefore = this.getCurrentLoyalty(); final int toughnessBonusBefore = this.getToughnessBonusFromCounters();
final int loyaltyBefore = this.getCurrentLoyalty();
Integer oldValue = this.counters.get(counterType); final Integer oldValue = this.counters.get(counterType);
int newValue = addAmount + (oldValue == null ? 0 : oldValue.intValue()); final 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 or loyalty changed from added counters //fire card stats changed event if p/t bonuses or loyalty changed from added counters
if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters() || loyaltyBefore != getCurrentLoyalty()) { if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters() || loyaltyBefore != getCurrentLoyalty()) {
getGame().fireEvent(new GameEventCardStatsChanged(this)); getGame().fireEvent(new GameEventCardStatsChanged(this));
@@ -1233,6 +1242,7 @@ public class Card extends GameEntity implements Comparable<Card>, IIdentifiable
// play the Add Counter sound // play the Add Counter sound
getGame().fireEvent(new GameEventCardCounters(this, counterType, oldValue == null ? 0 : oldValue.intValue(), newValue)); getGame().fireEvent(new GameEventCardCounters(this, counterType, oldValue == null ? 0 : oldValue.intValue(), newValue));
}
// Run triggers // Run triggers
final Map<String, Object> runParams = new TreeMap<String, Object>(); final Map<String, Object> runParams = new TreeMap<String, Object>();