Update AI damage prevention prediction code

This commit is contained in:
Lyu Zong-Hong
2021-05-10 08:09:27 +09:00
parent 03bee3e11e
commit 04811da9cc
2 changed files with 29 additions and 4 deletions

View File

@@ -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;
}
}