Fixed so that a character having ReduceSeverity or ThresholdImmunity rules are considered for popping the DamageReductionDialog (#2064)

This commit is contained in:
WBHarry 2026-07-06 20:06:08 +02:00 committed by GitHub
parent 5889476b64
commit 67b0d036a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -622,22 +622,30 @@ export default class DhpActor extends Actor {
return rollData;
}
#canReduceDamage(hpDamage, type) {
const { stressDamageReduction, disabledArmor } = this.system.rules.damageReduction;
#canReduceDamage(hpDamage, types) {
const { stressDamageReduction, disabledArmor, reduceSeverity, thresholdImmunities } =
this.system.rules.damageReduction;
if (disabledArmor) return false;
const availableStress = this.system.resources.stress.max - this.system.resources.stress.value;
const canUseArmor =
this.system.armorScore.value < this.system.armorScore.max &&
type.every(t => this.system.armorApplicableDamageTypes[t] === true);
types.every(t => this.system.armorApplicableDamageTypes[t] === true);
const canUseStress = Object.keys(stressDamageReduction).reduce((acc, x) => {
const rule = stressDamageReduction[x];
if (damageKeyToNumber(x) <= hpDamage) return acc || (rule.enabled && availableStress >= rule.cost);
return acc;
}, false);
return canUseArmor || canUseStress;
const hasReduceSeverity = types.some(t => reduceSeverity[t]);
const hasThresholdImmunity = Object.entries(thresholdImmunities)
.filter(([key, value]) => Boolean(value) && damageKeyToNumber(key) === hpDamage)
.length;
return canUseArmor || canUseStress || hasReduceSeverity || hasThresholdImmunity;
}
async takeDamage(damages, isDirect = false) {