From 470e3d4a64a5feb6cc9833fa8968f5b3a95d58eb Mon Sep 17 00:00:00 2001 From: Northmoc Date: Fri, 6 May 2022 16:35:35 -0400 Subject: [PATCH] CountersPutEffect support "PutOnDefined" and "OnlyNewKind" --- .../ability/effects/CountersPutEffect.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java index d487d42fa77..36c20fbf7a9 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CountersPutEffect.java @@ -171,6 +171,7 @@ public class CountersPutEffect extends SpellAbilityEffect { boolean existingCounter = sa.hasParam("CounterType") && sa.getParam("CounterType").equals("ExistingCounter"); boolean eachExistingCounter = sa.hasParam("EachExistingCounter"); boolean putOnEachOther = sa.hasParam("PutOnEachOther"); + boolean putOnDefined = sa.hasParam("PutOnDefined"); if (sa.hasParam("Optional") && !pc.confirmAction (sa, null, Localizer.getInstance().getMessage("lblDoYouWantPutCounter"))) { @@ -189,7 +190,7 @@ public class CountersPutEffect extends SpellAbilityEffect { Iterables.addAll(tgtObjects, activator.getController().chooseCardsForEffect(leastToughness, sa, Localizer.getInstance().getMessage("lblChooseACreatureWithLeastToughness"), 1, 1, false, params)); - } else if (sa.hasParam("Choices") && (counterType != null || putOnEachOther)) { + } else if (sa.hasParam("Choices") && (counterType != null || putOnEachOther || putOnDefined)) { ZoneType choiceZone = ZoneType.Battlefield; if (sa.hasParam("ChoiceZone")) { choiceZone = ZoneType.smartValueOf(sa.getParam("ChoiceZone")); @@ -222,9 +223,11 @@ public class CountersPutEffect extends SpellAbilityEffect { } if ((sa.hasParam("ChoiceTitle") || sa.hasParam("SpecifyCounter")) && counterType != null) { title += " (" + counterType.getName() + ")"; - } else if (putOnEachOther) { - title += Localizer.getInstance().getMessage("lblWithKindCounter") + " " + - Localizer.getInstance().getMessage("lblEachOther"); + } else if (putOnEachOther || putOnDefined) { + title += Localizer.getInstance().getMessage("lblWithKindCounter"); + if (putOnEachOther) { + title += " " + Localizer.getInstance().getMessage("lblEachOther"); + } } Map params = Maps.newHashMap(); @@ -397,6 +400,15 @@ public class CountersPutEffect extends SpellAbilityEffect { otherGCard.addCounter(counterType, counterAmount, placer, table); } continue; + } else if (putOnDefined) { + List defs = AbilityUtils.getDefinedCards(card, sa.getParam("PutOnDefined"), sa); + for (Card c : defs) { + Card gCard = game.getCardState(c, null); + if (!sa.hasParam("OnlyNewKind") || gCard.getCounters(counterType) < 1) { + gCard.addCounter(counterType, counterAmount, placer, table); + } + } + continue; } } @@ -579,7 +591,7 @@ public class CountersPutEffect extends SpellAbilityEffect { if (!sa.hasParam("EachExistingCounter") && !sa.hasParam("EachFromSource") && !sa.hasParam("UniqueType") && !sa.hasParam("CounterTypePerDefined") && !sa.hasParam("CounterTypes") && !sa.hasParam("ChooseDifferent") - && !sa.hasParam("PutOnEachOther")) { + && !sa.hasParam("PutOnEachOther") && !sa.hasParam("PutOnDefined")) { try { counterType = chooseTypeFromList(sa, sa.getParam("CounterType"), null, placer.getController());