- Added some AI code for casting Bonfire of the Damned via Miracle.

This commit is contained in:
Sloth
2012-11-28 06:33:31 +00:00
parent 3dd3d49827
commit e4f4830e99

View File

@@ -48,11 +48,9 @@ public class DamageAllAi extends SpellAiLogic {
} }
Player opp = ai.getOpponent(); Player opp = ai.getOpponent();
final List<Card> humanList = this.getKillableCreatures(sa, opp, dmg); final List<Card> humanList = this.getKillableCreatures(sa, opp, dmg);
List<Card> computerList = this.getKillableCreatures(sa, ai, dmg); List<Card> computerList = this.getKillableCreatures(sa, ai, dmg);
final Target tgt = sa.getTarget(); final Target tgt = sa.getTarget();
if (tgt != null && sa.canTarget(opp)) { if (tgt != null && sa.canTarget(opp)) {
tgt.resetTargets(); tgt.resetTargets();
@@ -165,31 +163,36 @@ public class DamageAllAi extends SpellAiLogic {
validP = sa.getParam("ValidPlayers"); validP = sa.getParam("ValidPlayers");
} }
// Evaluate creatures getting killed
Player enemy = ai.getOpponent(); Player enemy = ai.getOpponent();
final List<Card> humanList = this.getKillableCreatures(sa, enemy, dmg);
List<Card> computerList = this.getKillableCreatures(sa, ai, dmg);
final Target tgt = sa.getTarget(); 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 we can kill human, do it if (tgt != null && sa.canTarget(enemy)) {
if ((validP.contains("Each") || validP.contains("EachOpponent") || validP.contains("Targeted")) tgt.resetTargets();
&& (enemy.getLife() <= enemy.predictDamage(dmg, source, false))) { sa.getTarget().addTarget(enemy);
return true; computerList.clear();
} }
// Evaluate creatures getting killed // If it's not mandatory check a few things
final List<Card> humanList = this.getKillableCreatures(sa, enemy, dmg); if (mandatory) {
final List<Card> computerList = this.getKillableCreatures(sa, ai, dmg); return true;
if (!computerList.isEmpty() && CardFactoryUtil.evaluateCreatureList(computerList) + 50 >= CardFactoryUtil }
.evaluateCreatureList(humanList)) { // Don't get yourself killed
return false; if (validP.contains("Each") && (ai.getLife() <= ai.predictDamage(dmg, source, false))) {
} 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; return true;