mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- +1/+1 and -1/-1 Counters will now remove each other when added to a card that already has the other type of Counter.
This commit is contained in:
@@ -345,13 +345,40 @@ public class Card extends MyObservable {
|
|||||||
int multiplier = 1;
|
int multiplier = 1;
|
||||||
int doublingSeasons = CardFactoryUtil.getCards("Doubling Season", this.getController()).size();
|
int doublingSeasons = CardFactoryUtil.getCards("Doubling Season", this.getController()).size();
|
||||||
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
|
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
|
||||||
|
|
||||||
if(counters.containsKey(counterName)) {
|
if(counters.containsKey(counterName)) {
|
||||||
Integer aux = counters.get(counterName) + (multiplier * n);
|
Integer aux = counters.get(counterName) + (multiplier * n);
|
||||||
counters.put(counterName, aux);
|
counters.put(counterName, aux);
|
||||||
} else {
|
} else {
|
||||||
counters.put(counterName, Integer.valueOf(multiplier * n));
|
counters.put(counterName, Integer.valueOf(multiplier * n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (counterName.equals(Counters.P1P1) || counterName.equals(Counters.M1M1)){
|
||||||
|
// +1/+1 counters should erase -1/-1 counters
|
||||||
|
int plusOneCounters = 0;
|
||||||
|
int minusOneCounters = 0;
|
||||||
|
|
||||||
|
Counters p1Counter = Counters.P1P1;
|
||||||
|
Counters m1Counter = Counters.M1M1;
|
||||||
|
if (counters.containsKey(p1Counter))
|
||||||
|
plusOneCounters = counters.get(p1Counter);
|
||||||
|
if (counters.containsKey(m1Counter))
|
||||||
|
minusOneCounters = counters.get(m1Counter);
|
||||||
|
|
||||||
|
if (plusOneCounters == minusOneCounters){
|
||||||
|
counters.remove(m1Counter);
|
||||||
|
counters.remove(p1Counter);
|
||||||
|
}
|
||||||
|
if (plusOneCounters > minusOneCounters){
|
||||||
|
counters.remove(m1Counter);
|
||||||
|
counters.put(p1Counter, (Integer)(plusOneCounters - minusOneCounters));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
counters.put(m1Counter, (Integer)(minusOneCounters - plusOneCounters));
|
||||||
|
counters.remove(p1Counter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.updateObservers();
|
this.updateObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user