* Leech Bonder - fixed that it removes all counter instances instead one;

This commit is contained in:
Oleg Agafonov 2020-04-19 00:48:30 +04:00
parent 58ebf01c3b
commit b251d97cdb

View file

@ -1,9 +1,5 @@
package mage.cards.l; package mage.cards.l;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -17,8 +13,8 @@ import mage.cards.CardSetInfo;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.Counter; import mage.counters.Counter;
import mage.counters.CounterType; import mage.counters.CounterType;
@ -28,10 +24,12 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*
*/ */
public final class LeechBonder extends CardImpl { public final class LeechBonder extends CardImpl {
@ -91,11 +89,13 @@ class LeechBonderEffect extends OneShotEffect {
|| controller == null) { || controller == null) {
return false; return false;
} }
Choice choice = new ChoiceImpl();
Set<String> possibleChoices = new HashSet<>(); Set<String> possibleChoices = new HashSet<>(fromPermanent.getCounters(game).keySet());
for (String counterName : fromPermanent.getCounters(game).keySet()) { if (possibleChoices.size() == 0) {
possibleChoices.add(counterName); return false;
} }
Choice choice = new ChoiceImpl();
choice.setChoices(possibleChoices); choice.setChoices(possibleChoices);
if (controller.choose(outcome, choice, game)) { if (controller.choose(outcome, choice, game)) {
String chosen = choice.getChoice(); String chosen = choice.getChoice();
@ -103,7 +103,7 @@ class LeechBonderEffect extends OneShotEffect {
CounterType counterType = CounterType.findByName(chosen); CounterType counterType = CounterType.findByName(chosen);
if (counterType != null) { if (counterType != null) {
Counter counter = counterType.createInstance(); Counter counter = counterType.createInstance();
fromPermanent.removeCounters(counter, game); fromPermanent.removeCounters(counterType.getName(), 1, game);
toPermanent.addCounters(counter, source, game); toPermanent.addCounters(counter, source, game);
return true; return true;
} }