- 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) { if (sa instanceof SpellPermanent) {
return canPlayFromEffectAI((SpellPermanent)sa, false, true); 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)) { if (!sa.getTargetRestrictions().hasCandidates(sa, true)) {
return AiPlayDecision.TargetingFailed; 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 // Timetwister
public static class Timetwister { public static class Timetwister {
public static boolean consider(final Player ai, final SpellAbility sa) { 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); return this.doSameNameLogic(aiPlayer, sa);
} else if (aiLogic.equals("ReanimateAll")) { } else if (aiLogic.equals("ReanimateAll")) {
return SpecialCardAi.LivingDeath.consider(aiPlayer, sa); return SpecialCardAi.LivingDeath.consider(aiPlayer, sa);
} else if (aiLogic.equals("TheScarabGod")) {
return SpecialCardAi.TheScarabGod.consider(aiPlayer, sa);
} else if (aiLogic.equals("Intuition")) { } else if (aiLogic.equals("Intuition")) {
// This logic only fills the multiple cards array, the decision to play is made // This logic only fills the multiple cards array, the decision to play is made
// separately in hiddenOriginCanPlayAI later. // separately in hiddenOriginCanPlayAI later.

View File

@@ -5,7 +5,7 @@ PT:5/5
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigDrain | TriggerDescription$ At the beginning of your upkeep, each opponent loses X life and you scry X, where X is the number of Zombies you control. T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigDrain | TriggerDescription$ At the beginning of your upkeep, each opponent loses X life and you scry X, where X is the number of Zombies you control.
SVar:TrigDrain:DB$ LoseLife | Defined$ Player.Opponent | LifeAmount$ X | References$ X | SubAbility$ DBScry SVar:TrigDrain:DB$ LoseLife | Defined$ Player.Opponent | LifeAmount$ X | References$ X | SubAbility$ DBScry
SVar:DBScry:DB$Scry | ScryNum$ X | References$ X SVar:DBScry:DB$Scry | ScryNum$ X | References$ X
A:AB$ ChangeZone | Cost$ 2 U B | RememberLKI$ True | Origin$ Graveyard | Destination$ Exile | ValidTgts$ Creature | ChangeNum$ 1 | SubAbility$ DBCopy | SpellDescription$ Exile target creature card from a graveyard. Create a token that's a copy of it, except it's a 4/4 black Zombie. A:AB$ ChangeZone | Cost$ 2 U B | RememberLKI$ True | Origin$ Graveyard | Destination$ Exile | ValidTgts$ Creature | ChangeNum$ 1 | SubAbility$ DBCopy | AILogic$ TheScarabGod | SpellDescription$ Exile target creature card from a graveyard. Create a token that's a copy of it, except it's a 4/4 black Zombie.
SVar:DBCopy:DB$ CopyPermanent | Defined$ Remembered | SetPower$ 4 | SetToughness$ 4 | SetColor$ Black | SetCreatureTypes$ Zombie | SubAbility$ DBCleanup SVar:DBCopy:DB$ CopyPermanent | Defined$ Remembered | SetPower$ 4 | SetToughness$ 4 | SetColor$ Black | SetCreatureTypes$ Zombie | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Battlefield | Destination$ Graveyard | TriggerController$ TriggeredCardController | Execute$ TrigDelay | TriggerDescription$ When CARDNAME dies, return it to its owner's hand at the beginning of the next end step. T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Battlefield | Destination$ Graveyard | TriggerController$ TriggeredCardController | Execute$ TrigDelay | TriggerDescription$ When CARDNAME dies, return it to its owner's hand at the beginning of the next end step.