mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix counter placement sound playing repeatedly.
This commit is contained in:
@@ -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()) {
|
||||||
|
|||||||
@@ -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>();
|
||||||
|
|||||||
Reference in New Issue
Block a user