This commit is contained in:
tool4ever
2022-12-05 19:43:56 +01:00
committed by GitHub
parent 3f831bc036
commit bdf09485a2
17 changed files with 39 additions and 52 deletions

View File

@@ -2961,7 +2961,7 @@ public class ComputerUtil {
return false;
}
public static boolean targetPlayableSpellCard(final Player ai, CardCollection options, final SpellAbility sa, final boolean withoutPayingManaCost, boolean mandatory) {
public static boolean targetPlayableSpellCard(final Player ai, Iterable<Card> options, final SpellAbility sa, final boolean withoutPayingManaCost, boolean mandatory) {
// determine and target a card with a SA that the AI can afford and will play
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
sa.resetTargets();
@@ -2993,8 +2993,8 @@ public class ComputerUtil {
}
if (targets.isEmpty()) {
if (mandatory && !options.isEmpty()) {
targets = options;
if (mandatory && !Iterables.isEmpty(options)) {
targets.addAll(options);
} else {
return false;
}

View File

@@ -131,7 +131,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
if (sa.usesTargeting()) {
sa.resetTargets();
CardCollection list = new CardCollection(CardUtil.getValidCardsToTarget(sa.getTargetRestrictions(), sa));
List<Card> list = CardUtil.getValidCardsToTarget(sa.getTargetRestrictions(), sa);
//Nothing to target
if (list.isEmpty()) {

View File

@@ -68,7 +68,6 @@ public class DebuffAi extends SpellAbilityAi {
if (!sa.usesTargeting()) {
List<Card> cards = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
final Combat combat = game.getCombat();
return Iterables.any(cards, new Predicate<Card>() {
@Override
@@ -121,7 +120,6 @@ public class DebuffAi extends SpellAbilityAi {
final TargetRestrictions tgt = sa.getTargetRestrictions();
sa.resetTargets();
CardCollection list = getCurseCreatures(ai, sa, kws == null ? Lists.newArrayList() : kws);
list = CardLists.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getHostCard(), sa);
// several uses here:
// 1. make human creatures lose evasion when they are attacking
@@ -205,9 +203,7 @@ public class DebuffAi extends SpellAbilityAi {
}
// Remove anything that's already been targeted
for (final Card c : sa.getTargets().getTargetCards()) {
list.remove(c);
}
list.removeAll(sa.getTargets().getTargetCards());
final CardCollection pref = CardLists.filterControlledBy(list, ai.getOpponents());
final CardCollection forced = CardLists.filterControlledBy(list, ai);

View File

@@ -40,7 +40,7 @@ public class PlayAi extends SpellAbilityAi {
return false; // prevent infinite loop
}
CardCollection cards = getPlayableCards(sa, ai);
List<Card> cards = getPlayableCards(sa, ai);
if (cards.isEmpty()) {
return false;
}
@@ -188,14 +188,14 @@ public class PlayAi extends SpellAbilityAi {
});
return ComputerUtilCard.getBestAI(tgtCards);
}
private static CardCollection getPlayableCards(SpellAbility sa, Player ai) {
CardCollection cards = new CardCollection();
private static List<Card> getPlayableCards(SpellAbility sa, Player ai) {
List<Card> cards = null;
final TargetRestrictions tgt = sa.getTargetRestrictions();
final Card source = sa.getHostCard();
if (tgt != null) {
cards = CardLists.getValidCards(ai.getGame().getCardsIn(tgt.getZone()), tgt.getValidTgts(), ai, source, sa);
cards = CardUtil.getValidCardsToTarget(tgt, sa);
} else if (!sa.hasParam("Valid")) {
cards = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
}

View File

@@ -518,7 +518,7 @@ public class PumpAi extends PumpAiBase {
}
}
list = CardLists.getValidCards(list, tgt.getValidTgts(), ai, source, sa);
list = CardLists.getTargetableCards(list, sa);
if (game.getStack().isEmpty()) {
// If the cost is tapping, don't activate before declare attack/block
if (sa.getPayCosts().hasTapCost()) {