- getDamagingSAToChain should only work for actual AI players, not when simulating human decisions.

This commit is contained in:
Agetian
2018-12-12 19:42:28 +03:00
parent 7a7b461e0d
commit b718365a39

View File

@@ -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 // 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). // and can be properly reserved).
public static Pair<SpellAbility, Integer> getDamagingSAToChain(Player ai, SpellAbility sa, String damage) { public static Pair<SpellAbility, Integer> getDamagingSAToChain(Player ai, SpellAbility sa, String damage) {
Game game = ai.getGame(); if (!ai.getController().isAI()) {
int chance = ((PlayerControllerAi)ai.getController()).getAi().getIntProperty(AiProps.CHANCE_TO_CHAIN_TWO_DAMAGE_SPELLS); return null; // should only work for the actual AI player
} else if (((PlayerControllerAi)ai.getController()).getAi().usesSimulation()) {
if (((PlayerControllerAi)ai.getController()).getAi().usesSimulation()) {
// simulated AI shouldn't use paired decisions, it tries to find complex decisions on its own // simulated AI shouldn't use paired decisions, it tries to find complex decisions on its own
return null; 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))) { 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) chance = 100; // in danger, do it even if normally the chance is low (unless chaining is completely disabled)
} }