mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Implemented Rule 704.5r - If a permanent has both a +1/+1 counter and a -1/-1 counter on it, N +1/+1 and N -1/-1 counters are removed from it, where N is the smaller of the number of +1/+1 and -1/-1 counters on it.
This commit is contained in:
parent
7c608b8b91
commit
13497ec651
2 changed files with 20 additions and 0 deletions
|
@ -74,6 +74,12 @@ public class Counters extends HashMap<String, Counter> implements Serializable {
|
|||
if (this.containsKey(name))
|
||||
this.get(name).remove();
|
||||
}
|
||||
|
||||
public void removeCounter(CounterType counterType, int amount) {
|
||||
if (this.containsKey(counterType.getName())) {
|
||||
get(counterType.getName()).remove(amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCounter(String name, int amount) {
|
||||
if (this.containsKey(name))
|
||||
|
@ -85,6 +91,10 @@ public class Counters extends HashMap<String, Counter> implements Serializable {
|
|||
return this.get(name).getCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean containsKey(CounterType counterType) {
|
||||
return getCount(counterType) > 0;
|
||||
}
|
||||
|
||||
public int getCount(CounterType type) {
|
||||
if (this.containsKey(type.getName()))
|
||||
|
|
|
@ -725,6 +725,16 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
}
|
||||
}
|
||||
}
|
||||
//20110501 - 704.5r
|
||||
for (Permanent perm: getBattlefield().getAllActivePermanents()) {
|
||||
if (perm.getCounters().containsKey(CounterType.P1P1) && perm.getCounters().containsKey(CounterType.M1M1)) {
|
||||
int p1p1 = perm.getCounters().getCount(CounterType.P1P1);
|
||||
int m1m1 = perm.getCounters().getCount(CounterType.M1M1);
|
||||
int min = Math.min(p1p1, m1m1);
|
||||
perm.getCounters().removeCounter(CounterType.P1P1, min);
|
||||
perm.getCounters().removeCounter(CounterType.M1M1, min);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: implement the rest
|
||||
|
||||
|
|
Loading…
Reference in a new issue