mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
ChooseCardEffect "EachDifferentPower"
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user