From b718365a39bb506b8966265db7d184f25d669489 Mon Sep 17 00:00:00 2001 From: Agetian Date: Wed, 12 Dec 2018 19:42:28 +0300 Subject: [PATCH] - getDamagingSAToChain should only work for actual AI players, not when simulating human decisions. --- .../src/main/java/forge/ai/ability/DamageDealAi.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index ded374079b1..13569ef19b5 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -1014,14 +1014,16 @@ public class DamageDealAi extends DamageAiBase { // The returned spell ability can be chained to "sa" to deal more damage (enough mana is available to cast both // and can be properly reserved). public static Pair getDamagingSAToChain(Player ai, SpellAbility sa, String damage) { - Game game = ai.getGame(); - int chance = ((PlayerControllerAi)ai.getController()).getAi().getIntProperty(AiProps.CHANCE_TO_CHAIN_TWO_DAMAGE_SPELLS); - - if (((PlayerControllerAi)ai.getController()).getAi().usesSimulation()) { + if (!ai.getController().isAI()) { + return null; // should only work for the actual AI player + } else if (((PlayerControllerAi)ai.getController()).getAi().usesSimulation()) { // simulated AI shouldn't use paired decisions, it tries to find complex decisions on its own return null; } + Game game = ai.getGame(); + int chance = ((PlayerControllerAi)ai.getController()).getAi().getIntProperty(AiProps.CHANCE_TO_CHAIN_TWO_DAMAGE_SPELLS); + if (chance > 0 && (ComputerUtilCombat.lifeInDanger(ai, game.getCombat()) || ComputerUtil.aiLifeInDanger(ai, true, 0))) { chance = 100; // in danger, do it even if normally the chance is low (unless chaining is completely disabled) }