From e4f4830e990ef20d522bfbf422b0911efc4d4e9f Mon Sep 17 00:00:00 2001 From: Sloth Date: Wed, 28 Nov 2012 06:33:31 +0000 Subject: [PATCH] - Added some AI code for casting Bonfire of the Damned via Miracle. --- .../card/abilityfactory/ai/DamageAllAi.java | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/main/java/forge/card/abilityfactory/ai/DamageAllAi.java b/src/main/java/forge/card/abilityfactory/ai/DamageAllAi.java index 2ea7bef1055..0a5e4e46602 100644 --- a/src/main/java/forge/card/abilityfactory/ai/DamageAllAi.java +++ b/src/main/java/forge/card/abilityfactory/ai/DamageAllAi.java @@ -48,11 +48,9 @@ public class DamageAllAi extends SpellAiLogic { } Player opp = ai.getOpponent(); - final List humanList = this.getKillableCreatures(sa, opp, dmg); List computerList = this.getKillableCreatures(sa, ai, dmg); - final Target tgt = sa.getTarget(); if (tgt != null && sa.canTarget(opp)) { tgt.resetTargets(); @@ -165,31 +163,36 @@ public class DamageAllAi extends SpellAiLogic { validP = sa.getParam("ValidPlayers"); } + // Evaluate creatures getting killed Player enemy = ai.getOpponent(); + final List humanList = this.getKillableCreatures(sa, enemy, dmg); + List computerList = this.getKillableCreatures(sa, ai, dmg); final Target tgt = sa.getTarget(); - if (tgt == null) { - // If it's not mandatory check a few things - if (mandatory) { - return true; - } - // Don't get yourself killed - if (validP.contains("Each") && (ai.getLife() <= ai.predictDamage(dmg, source, false))) { - return false; - } + + if (tgt != null && sa.canTarget(enemy)) { + tgt.resetTargets(); + sa.getTarget().addTarget(enemy); + computerList.clear(); + } - // if we can kill human, do it - if ((validP.contains("Each") || validP.contains("EachOpponent") || validP.contains("Targeted")) - && (enemy.getLife() <= enemy.predictDamage(dmg, source, false))) { - return true; - } + // If it's not mandatory check a few things + if (mandatory) { + return true; + } + // Don't get yourself killed + if (validP.contains("Each") && (ai.getLife() <= ai.predictDamage(dmg, source, false))) { + return false; + } - // Evaluate creatures getting killed - final List humanList = this.getKillableCreatures(sa, enemy, dmg); - final List computerList = this.getKillableCreatures(sa, ai, dmg); - if (!computerList.isEmpty() && CardFactoryUtil.evaluateCreatureList(computerList) + 50 >= CardFactoryUtil - .evaluateCreatureList(humanList)) { - return false; - } + // if we can kill human, do it + if ((validP.contains("Each") || validP.contains("EachOpponent") || validP.contains("Targeted")) + && (enemy.getLife() <= enemy.predictDamage(dmg, source, false))) { + return true; + } + + if (!computerList.isEmpty() && CardFactoryUtil.evaluateCreatureList(computerList) + 50 >= CardFactoryUtil + .evaluateCreatureList(humanList)) { + return false; } return true;