Fix the counter removal code so it doesn't throw events when it's removing nonexistent counters.

This commit is contained in:
Dilnu 2016-11-21 07:39:47 -05:00
parent 5e12a141cb
commit 9ff3e2c670
3 changed files with 15 additions and 7 deletions

View file

@ -656,7 +656,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override
public void removeCounters(String name, int amount, Game game) {
for (int i = 0; i < amount; i++) {
getCounters(game).removeCounter(name, 1);
if (!getCounters(game).removeCounter(name, 1)) {
break;
}
GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTER_REMOVED, objectId, getControllerOrOwner());
event.setData(name);
game.fireEvent(event);