[Feature] Damage Reduction Rules (#574)

* More rules

* Updated some cards with damageReduction

* Fixed Endurance and HighStamina Features

* More style improvements
This commit is contained in:
WBHarry 2025-08-04 16:18:03 +02:00 committed by GitHub
parent 6bdeccfbf9
commit 02a8a9c313
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
59 changed files with 640 additions and 245 deletions

View file

@ -464,14 +464,17 @@ export default class DhpActor extends Actor {
}
#canReduceDamage(hpDamage, type) {
const { stressDamageReduction, disabledArmor } = this.system.rules.damageReduction;
if (disabledArmor) return false;
const availableStress = this.system.resources.stress.max - this.system.resources.stress.value;
const canUseArmor =
this.system.armor &&
this.system.armor.system.marks.value < this.system.armorScore &&
type.every(t => this.system.armorApplicableDamageTypes[t] === true);
const canUseStress = Object.keys(this.system.rules.damageReduction.stressDamageReduction).reduce((acc, x) => {
const rule = this.system.rules.damageReduction.stressDamageReduction[x];
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);