- +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:
jendave
2011-08-06 08:13:27 +00:00
parent 440814fc15
commit f60eb218ea

View File

@@ -345,13 +345,40 @@ public class Card extends MyObservable {
int multiplier = 1;
int doublingSeasons = CardFactoryUtil.getCards("Doubling Season", this.getController()).size();
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
if(counters.containsKey(counterName)) {
Integer aux = counters.get(counterName) + (multiplier * n);
counters.put(counterName, aux);
} else {
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();
}