- Basic fix for PumpAiBase.shouldPumpCard() to enable the AI to use abilities that grant "Lifelink"

This commit is contained in:
excessum
2014-08-23 12:18:26 +00:00
parent fc71b705f8
commit de1d214a16

View File

@@ -572,7 +572,16 @@ public abstract class PumpAiBase extends SpellAbilityAi {
chance += 1.0f * (pumpedDmg - dmg) / opp.getLife(); chance += 1.0f * (pumpedDmg - dmg) / opp.getLife();
} }
//4. if the life of the computer is in danger, try to pump blockers blocking Tramplers //4. lifelink
if (ai.canGainLife() && !c.hasKeyword("Lifelink") && keywords.contains("Lifelink")
&& (combat.isAttacking(c) || combat.isBlocking(c))) {
int dmg = pumped.getNetCombatDamage();
//The actual dmg inflicted should be the sum of ComputerUtilCombat.predictDamageTo() for opposing creature
//and trample damage (if any)
chance += 1.0f * dmg / ai.getLife();
}
//5. if the life of the computer is in danger, try to pump blockers blocking Tramplers
if (combat.isBlocking(c) && defense > 0 ) { if (combat.isBlocking(c) && defense > 0 ) {
List<Card> blockedBy = combat.getAttackersBlockedBy(c); List<Card> blockedBy = combat.getAttackersBlockedBy(c);
boolean attackerHasTrample = false; boolean attackerHasTrample = false;
@@ -584,6 +593,8 @@ public abstract class PumpAiBase extends SpellAbilityAi {
} }
} }
} }
//TODO:how to consider repeatable pump abilities? This probably requires the AI to keep track of future decisions and/or
//plan a sequence of decisions.
return MyRandom.getRandom().nextFloat() < chance; return MyRandom.getRandom().nextFloat() < chance;
} }