From a5ee24e23d2fb8b9bd417ceb42eb5e5901a9abea Mon Sep 17 00:00:00 2001 From: Northmoc Date: Thu, 23 Sep 2021 18:31:23 -0400 Subject: [PATCH] ChooseCardEffect "WithDifferentPowers" --- .../ability/effects/ChooseCardEffect.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java index 77b5a722913..2fbc44996ff 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseCardEffect.java @@ -89,7 +89,7 @@ public class ChooseCardEffect extends SpellAbilityEffect { } } } - } else if (sa.hasParam("WithTotalPower")){ + } else if (sa.hasParam("WithTotalPower")) { final int totP = AbilityUtils.calculateAmount(host, sa.getParam("WithTotalPower"), sa); CardCollection negativeCreats = CardLists.filterLEPower(p.getCreaturesInPlay(), -1); int negativeNum = Aggregates.sum(negativeCreats, CardPredicates.Accessors.fnGetNetPower); @@ -97,9 +97,9 @@ public class ChooseCardEffect extends SpellAbilityEffect { CardCollection chosenPool = new CardCollection(); int chosenP = 0; while (!creature.isEmpty()) { - Card c = p.getController().chooseSingleEntityForEffect(creature, sa, + Card c = p.getController().chooseSingleEntityForEffect(creature, sa, Localizer.getInstance().getMessage("lblSelectCreatureWithTotalPowerLessOrEqualTo", (totP - chosenP - negativeNum)) - + "\r\n(" + Localizer.getInstance().getMessage("lblSelected") + ":" + chosenPool + ")\r\n(" + Localizer.getInstance().getMessage("lblTotalPowerNum", chosenP) + ")", chosenP <= totP, null); + + "\r\n(" + Localizer.getInstance().getMessage("lblSelected") + ":" + chosenPool + ")\r\n(" + Localizer.getInstance().getMessage("lblTotalPowerNum", chosenP) + ")", chosenP <= totP, null); if (c == null) { if (p.getController().confirmAction(sa, PlayerActionConfirmMode.OptionalChoose, Localizer.getInstance().getMessage("lblCancelChooseConfirm"))) { break; @@ -114,6 +114,29 @@ public class ChooseCardEffect extends SpellAbilityEffect { } } chosen.addAll(chosenPool); + } else if (sa.hasParam("WithDifferentPowers")) { + String restrict = sa.getParam("Choices"); + CardCollection chosenPool = new CardCollection(); + String title = Localizer.getInstance().getMessage("lblChooseCreature"); + Card choice = null; + while (!choices.isEmpty() && chosenPool.size() < validAmount) { + boolean optional = chosenPool.size() >= minAmount; + CardCollection creature = (CardCollection) choices; + if (!chosenPool.isEmpty()) { + title = Localizer.getInstance().getMessage("lblChooseCreatureWithDiffPower"); + } + choice = p.getController().chooseSingleEntityForEffect(creature, sa, title, optional, null); + if (choice == null) { + break; + } + chosenPool.add(choice); + restrict = restrict + (restrict.contains(".") ? "+powerNE" : ".powerNE") + choice.getNetPower(); + choices = CardLists.getValidCards(choices, restrict, activator, host, sa); + } + if (choice != null) { + chosenPool.add(choice); + } + chosen.addAll(chosenPool); } else if ((tgt == null) || p.canBeTargetedBy(sa)) { if (sa.hasParam("AtRandom") && !choices.isEmpty()) { Aggregates.random(choices, validAmount, chosen);