- Fixed the AI targeting restrictions check in AiController to account for the AILogics that can pre-target cards.

- Added an AI logic for The Scarab God (can be generalized later).
This commit is contained in:
Agetian
2018-02-11 07:46:38 +03:00
parent 9e74ef9e37
commit 670966be57
4 changed files with 22 additions and 2 deletions

View File

@@ -662,7 +662,8 @@ public class AiController {
if (sa instanceof SpellPermanent) {
return canPlayFromEffectAI((SpellPermanent)sa, false, true);
}
if (sa.usesTargeting()) {
if (sa.usesTargeting()
&& sa.getTargets().getNumTargeted() < sa.getTargetRestrictions().getMinTargets(sa.getHostCard(), sa)) {
if (!sa.getTargetRestrictions().hasCandidates(sa, true)) {
return AiPlayDecision.TargetingFailed;
}

View File

@@ -1109,6 +1109,23 @@ public class SpecialCardAi {
}
}
// The Scarab God
public static class TheScarabGod {
public static boolean consider(final Player ai, final SpellAbility sa) {
Card bestOppCreat = ComputerUtilCard.getBestAI(CardLists.filter(ai.getOpponents().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES));
Card worstOwnCreat = ComputerUtilCard.getWorstAI(CardLists.filter(ai.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES));
sa.resetTargets();
if (bestOppCreat != null) {
sa.getTargets().add(bestOppCreat);
} else if (worstOwnCreat != null) {
sa.getTargets().add(worstOwnCreat);
}
return sa.getTargets().getNumTargeted() > 0;
}
}
// Timetwister
public static class Timetwister {
public static boolean consider(final Player ai, final SpellAbility sa) {

View File

@@ -94,6 +94,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
return this.doSameNameLogic(aiPlayer, sa);
} else if (aiLogic.equals("ReanimateAll")) {
return SpecialCardAi.LivingDeath.consider(aiPlayer, sa);
} else if (aiLogic.equals("TheScarabGod")) {
return SpecialCardAi.TheScarabGod.consider(aiPlayer, sa);
} else if (aiLogic.equals("Intuition")) {
// This logic only fills the multiple cards array, the decision to play is made
// separately in hiddenOriginCanPlayAI later.