mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18: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);
|
HashMap<String, String> abilityParams = AF.getMapParams(ability, source);
|
||||||
if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt"))
|
if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt"))
|
||||||
continue; //targeted pumping not supported
|
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"))
|
if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump") && !abilityParams.get("AB").equals("PumpAll"))
|
||||||
continue;
|
continue;
|
||||||
if (abilityParams.containsKey("DB") && !abilityParams.get("DB").equals("Pump") && !abilityParams.get("DB").equals("PumpAll"))
|
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 (abilityParams.containsKey("ValidCards"))
|
||||||
if (attacker.isValidCard(abilityParams.get("ValidCards").split(","), source.getController(), source)
|
if (attacker.isValidCard(abilityParams.get("ValidCards").split(","), source.getController(), source)
|
||||||
|| attacker.isValidCard(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
|
|| attacker.isValidCard(abilityParams.get("ValidCards").replace("attacking+", "").split(",")
|
||||||
, source.getController(), source))
|
, source.getController(), source))
|
||||||
list.add(attacker);
|
list.add(attacker);
|
||||||
if (list.isEmpty()) continue;
|
if (list.isEmpty()) continue;
|
||||||
if (!list.contains(attacker)) continue;
|
if (!list.contains(attacker)) continue;
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ public class ComputerUtil_Attack2 {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean isEffectiveAttacker(Card attacker, Combat combat) {
|
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.damageIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
||||||
if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user