From 56cdf52f0b282e8fce63b56729eb56fc0a95bdfe Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 10 Dec 2018 07:11:14 +0300 Subject: [PATCH] - AI Haste: grant to cards with affordable activated abilities with a tap cost. --- .../main/java/forge/ai/ComputerUtilCard.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index cbac89b2e0c..253c8ace216 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -21,6 +21,7 @@ import forge.game.ability.ApiType; import forge.game.card.*; import forge.game.combat.Combat; import forge.game.combat.CombatUtil; +import forge.game.cost.Cost; import forge.game.cost.CostPayEnergy; import forge.game.keyword.Keyword; import forge.game.keyword.KeywordCollection; @@ -1311,9 +1312,21 @@ public class ComputerUtilCard { //2. grant haste if (keywords.contains("Haste") && c.hasSickness() && !c.isTapped()) { - if (ComputerUtilCard.doesSpecifiedCreatureAttackAI(ai, pumped)) { - chance += 0.5f + (0.5f * ComputerUtilCombat.damageIfUnblocked(pumped, opp, combat, true) / opp.getLife()); + double baseChance = 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; + } } + // 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(); + } + chance += baseChance; } //3. grant evasive