placeholder for special param that picks new ability if no legal targets

This commit is contained in:
Northmoc
2021-07-29 21:46:02 -04:00
parent f3a2f72106
commit 89a91c6df8

View File

@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.card.CardUtil;
import forge.game.event.GameEventCardModeChosen;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
@@ -81,6 +82,20 @@ public class ChooseGenericEffect extends SpellAbilityEffect {
chosenSAs = p.getController().chooseSpellAbilitiesForEffect(abilities, sa, prompt, amount, ImmutableMap.of());
}
// TODO: Move this up into the AtRandom area
for (SpellAbility chosenSA : chosenSAs) {
if (sa.getParam("ChangeToAtRandom").equals("Urza") && chosenSA.usesTargeting()) {
List<Card> validTargets = CardUtil.getValidCardsToTarget(chosenSA.getTargetRestrictions(), sa);
if (validTargets.isEmpty()) {
List <SpellAbility> newChosenSAs = Lists.newArrayList();
Aggregates.random(abilities, amount, newChosenSAs);
chosenSAs = newChosenSAs;
} else {
p.getController().chooseTargetsFor(chosenSA);
}
}
}
if (!chosenSAs.isEmpty()) {
for (SpellAbility chosenSA : chosenSAs) {
String chosenValue = chosenSA.getDescription();