From 0fe8c1f121dd6b67b8c5404ec099d630d67cd39c Mon Sep 17 00:00:00 2001 From: Seravy Date: Sat, 10 Feb 2018 13:30:22 +0100 Subject: [PATCH] AI will activate ~DestroyAll~ abilities during combat if it would lose the game, or it would take too much damage (Nevinnyrral's Disk, Pernicious Deed) --- .../main/java/forge/ai/ability/DestroyAllAi.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java index 354fe4432a2..81e26eb32d4 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DestroyAllAi.java @@ -101,6 +101,19 @@ public class DestroyAllAi extends SpellAbilityAi { } } + // If effect is destroying creatures and AI is about to lose, activate effect anyway no matter what! + if ((!CardLists.getType(opplist, "Creature").isEmpty()) && (ai.getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) + && (ai.getGame().getCombat() != null && ComputerUtilCombat.lifeInSeriousDanger(ai, ai.getGame().getCombat()))) { + return true; + } + + // If effect is destroying creatures and AI is about to get low on life, activate effect anyway if difference in lost permanents not very much + if ((!CardLists.getType(opplist, "Creature").isEmpty()) && (ai.getGame().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)) + && (ai.getGame().getCombat() != null && ComputerUtilCombat.lifeInDanger(ai, ai.getGame().getCombat())) + && ((ComputerUtilCard.evaluatePermanentList(ailist) - 6) >= ComputerUtilCard.evaluatePermanentList(opplist))) { + return true; + } + // if only creatures are affected evaluate both lists and pass only if // human creatures are more valuable if (CardLists.getNotType(opplist, "Creature").isEmpty() && CardLists.getNotType(ailist, "Creature").isEmpty()) {