From 468eb4647169ce208c9412bb7332901035a283b9 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 20 Oct 2016 19:45:04 +0200 Subject: [PATCH] * Midnight Oil - Fixed that also one remaning counter was removed it from it's own effect. --- .../counter/RemoveCounterSourceEffect.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java index a371859fc5..6322b59d12 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/RemoveCounterSourceEffect.java @@ -57,20 +57,26 @@ public class RemoveCounterSourceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null && permanent.getCounters(game).getCount(counter.getName()) >= counter.getCount()) { - permanent.removeCounters(counter.getName(), counter.getCount(), game); - if (!game.isSimulation()) { - game.informPlayers("Removed " + counter.getCount() + " " + counter.getName() + " counter from " + permanent.getLogName()); + if (permanent != null) { + int toRemove = Math.min(counter.getCount(), permanent.getCounters(game).getCount(counter.getName())); + if (toRemove > 0) { + permanent.removeCounters(counter.getName(), toRemove, game); + if (!game.isSimulation()) { + game.informPlayers("Removed " + toRemove + " " + counter.getName() + " counter from " + permanent.getLogName()); + } } return true; } Card card = game.getCard(source.getSourceId()); - if (card != null && card.getCounters(game).getCount(counter.getName()) >= counter.getCount()) { - card.removeCounters(counter.getName(), counter.getCount(), game); - if (!game.isSimulation()) { - game.informPlayers("Removed " + counter.getCount() + " " + counter.getName() - + " counter from " + card.getLogName() - + " (" + card.getCounters(game).getCount(counter.getName()) + " left)"); + if (card != null) { + int toRemove = Math.min(counter.getCount(), card.getCounters(game).getCount(counter.getName())); + if (toRemove > 0) { + card.removeCounters(counter.getName(), toRemove, game); + if (!game.isSimulation()) { + game.informPlayers("Removed " + toRemove + " " + counter.getName() + + " counter from " + card.getLogName() + + " (" + card.getCounters(game).getCount(counter.getName()) + " left)"); + } } return true; }