Merge branch 'master' into 'master'

Improved AI Haste chance calculation.

See merge request core-developers/forge!1203
This commit is contained in:
Michael Kamensky
2018-12-10 04:48:42 +00:00

View File

@@ -1312,21 +1312,22 @@ public class ComputerUtilCard {
//2. grant haste
if (keywords.contains("Haste") && c.hasSickness() && !c.isTapped()) {
double baseChance = 0.0f;
double nonCombatChance = 0.0f;
double combatChance = 0.0f;
// non-combat Haste: has an activated ability with tap cost
for (SpellAbility ab : c.getSpellAbilities()) {
Cost abCost = ab.getPayCosts();
if (abCost != null && abCost.hasTapCost()
&& (!abCost.hasManaCost() || ComputerUtilMana.canPayManaCost(ab, ai, 0))) {
baseChance += 0.5f;
nonCombatChance += 0.5f;
break;
}
}
// combat Haste: only grant it if the creature will attack
if (ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, pumped)) {
if (baseChance < 0.5f) { baseChance = 0.5f; }
chance += 0.5f * ComputerUtilCombat.damageIfUnblocked(pumped, opp, combat, true) / opp.getLife();
combatChance += 0.5f + (0.5f * ComputerUtilCombat.damageIfUnblocked(pumped, opp, combat, true) / opp.getLife());
}
chance += baseChance;
chance += nonCombatChance + combatChance;
}
//3. grant evasive