ChooseCardEffect "WithDifferentPowers"

This commit is contained in:
Northmoc
2021-09-23 18:31:23 -04:00
parent 6c62df0a48
commit a5ee24e23d

View File

@@ -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);