ChooseCardEffect "EachDifferentPower"

This commit is contained in:
Northmoc
2021-09-23 18:31:55 -04:00
parent a5ee24e23d
commit 59549ef7b0

View File

@@ -1,5 +1,7 @@
package forge.game.ability.effects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
@@ -137,6 +139,26 @@ public class ChooseCardEffect extends SpellAbilityEffect {
chosenPool.add(choice);
}
chosen.addAll(chosenPool);
} else if (sa.hasParam("EachDifferentPower")) {
List<Integer> powers = new ArrayList<>();
CardCollection chosenPool = new CardCollection();
for (Card c : choices) {
int pow = c.getNetPower();
if (!powers.contains(pow)) {
powers.add(c.getNetPower());
}
}
Collections.sort(powers);
String re = sa.getParam("Choices");
re = re + (re.contains(".") ? "+powerEQ" : ".powerEQ");
for (int i : powers) {
String restrict = re + i;
CardCollection valids = CardLists.getValidCards(choices, restrict, activator, host, sa);
Card choice = p.getController().chooseSingleEntityForEffect(valids, sa,
Localizer.getInstance().getMessage("lblChooseCreatureWithXPower", i), false, 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);