mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Merge branch 'update_prevention_predition' into 'master'
Update AI damage prevention prediction code See merge request core-developers/forge!4683
This commit is contained in:
@@ -2293,7 +2293,8 @@ public class ComputerUtilCombat {
|
||||
for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||
Map<String, String> params = re.getMapParams();
|
||||
if (!re.getMode().equals(ReplacementType.DamageDone) || !params.containsKey("PreventionEffect")) {
|
||||
if (!re.getMode().equals(ReplacementType.DamageDone) ||
|
||||
(!params.containsKey("PreventionEffect") && !params.containsKey("Prevent"))) {
|
||||
continue;
|
||||
}
|
||||
// Immortal Coil prevents the damage but has a similar negative effect
|
||||
@@ -2320,6 +2321,14 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
|
||||
}
|
||||
if (params.containsKey("Prevent")) {
|
||||
return 0;
|
||||
} else if (re.getOverridingAbility() != null) {
|
||||
SpellAbility repSA = re.getOverridingAbility();
|
||||
if (repSA.getApi() == ApiType.ReplaceDamage) {
|
||||
return Math.max(0, restDamage - AbilityUtils.calculateAmount(ca, repSA.getParam("Amount"), repSA));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -2491,7 +2500,14 @@ public class ComputerUtilCombat {
|
||||
List<ReplacementEffect> list = game.getReplacementHandler().getReplacementList(
|
||||
ReplacementType.DamageDone, repParams, ReplacementLayer.Other);
|
||||
|
||||
return !list.isEmpty();
|
||||
for (final ReplacementEffect re : list) {
|
||||
Map<String, String> params = re.getMapParams();
|
||||
if (params.containsKey("Prevent") ||
|
||||
(re.getOverridingAbility() != null && re.getOverridingAbility().getApi() != ApiType.ReplaceDamage)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean attackerHasThreateningAfflict(Card attacker, Player aiDefender) {
|
||||
|
||||
@@ -5170,10 +5170,11 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
return damage;
|
||||
}
|
||||
|
||||
for (final Card ca : getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||
for (final Card ca : getGame().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) {
|
||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||
Map<String, String> params = re.getMapParams();
|
||||
if (!re.getMode().equals(ReplacementType.DamageDone) || !params.containsKey("PreventionEffect")) {
|
||||
if (!re.getMode().equals(ReplacementType.DamageDone) ||
|
||||
(!params.containsKey("PreventionEffect") && !params.containsKey("Prevent"))) {
|
||||
continue;
|
||||
}
|
||||
if (params.containsKey("ValidSource")
|
||||
@@ -5195,6 +5196,14 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.containsKey("Prevent")) {
|
||||
return 0;
|
||||
} else if (re.getOverridingAbility() != null) {
|
||||
SpellAbility repSA = re.getOverridingAbility();
|
||||
if (repSA.getApi() == ApiType.ReplaceDamage) {
|
||||
return Math.max(0, damage - AbilityUtils.calculateAmount(ca, repSA.getParam("Amount"), repSA));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user