mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fixed counter handling of counters.
This commit is contained in:
parent
34f62ec620
commit
af4a40d5d5
1 changed files with 4 additions and 7 deletions
|
@ -75,18 +75,15 @@ public class Counters extends HashMap<String, Counter> implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCounter(String name) {
|
public void removeCounter(String name) {
|
||||||
if (this.containsKey(name)) {
|
removeCounter(name, 1);
|
||||||
Counter counter = this.get(name);
|
|
||||||
counter.remove();
|
|
||||||
if (counter.getCount() == 0) {
|
|
||||||
this.remove(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCounter(CounterType counterType, int amount) {
|
public void removeCounter(CounterType counterType, int amount) {
|
||||||
if (this.containsKey(counterType.getName())) {
|
if (this.containsKey(counterType.getName())) {
|
||||||
get(counterType.getName()).remove(amount);
|
get(counterType.getName()).remove(amount);
|
||||||
|
if (get(counterType.getName()).count == 0) {
|
||||||
|
this.remove(counterType.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue