mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- The AI will now check DealDamage triggered abilities when attacking (to not run into Circle of Flame and Caltrops).
This commit is contained in:
@@ -1239,6 +1239,25 @@ public class CombatUtil {
|
||||
HashMap<String, String> abilityParams = AF.getMapParams(ability, source);
|
||||
if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt"))
|
||||
continue; //targeted pumping not supported
|
||||
|
||||
// DealDamage triggers
|
||||
if ((abilityParams.containsKey("AB") && abilityParams.get("AB").equals("DealDamage"))
|
||||
|| (abilityParams.containsKey("DB") && abilityParams.get("DB").equals("DealDamage"))) {
|
||||
if (!abilityParams.containsKey("Defined") || !abilityParams.get("Defined").equals("TriggeredAttacker")) {
|
||||
continue;
|
||||
}
|
||||
int damage = 0;
|
||||
try {
|
||||
damage = Integer.parseInt(abilityParams.get("NumDmg"));
|
||||
} catch (NumberFormatException nfe) {
|
||||
//can't parse the number (X for example)
|
||||
continue;
|
||||
}
|
||||
toughness -= attacker.predictDamage(damage, 0, source, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pump triggers
|
||||
if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump") && !abilityParams.get("AB").equals("PumpAll"))
|
||||
continue;
|
||||
if (abilityParams.containsKey("DB") && !abilityParams.get("DB").equals("Pump") && !abilityParams.get("DB").equals("PumpAll"))
|
||||
@@ -1251,7 +1270,7 @@ public class CombatUtil {
|
||||
if (abilityParams.containsKey("ValidCards"))
|
||||
if (attacker.isValidCard(abilityParams.get("ValidCards").split(","), source.getController(), source)
|
||||
|| attacker.isValidCard(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
|
||||
, source.getController(), source))
|
||||
, source.getController(), source))
|
||||
list.add(attacker);
|
||||
if (list.isEmpty()) continue;
|
||||
if (!list.contains(attacker)) continue;
|
||||
|
||||
@@ -97,9 +97,14 @@ public class ComputerUtil_Attack2 {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isEffectiveAttacker(Card attacker, Combat combat) {
|
||||
|
||||
//if the attacker will die when attacking don't attack
|
||||
if (attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat) <= 0)
|
||||
return false;
|
||||
|
||||
if (CombatUtil.damageIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
||||
if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
||||
|
||||
|
||||
ArrayList<Trigger> registeredTriggers = AllZone.getTriggerHandler().getRegisteredTriggers();
|
||||
for (Trigger trigger : registeredTriggers)
|
||||
if (CombatUtil.combatTriggerWillTrigger(attacker, null, trigger, combat)
|
||||
|
||||
Reference in New Issue
Block a user