[V14] Armor System ArmorScore (#1744)

* Readded so that armor items have their system defined armor instead of using an ActiveEffect

* Consolidate armor source retrieval

* Fix regression with updating armor when sources are disabled

* Simplify armor pip update

* Use helper in damage reduction dialog

* .

* Corrected SRD Armor Items

---------

Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
WBHarry 2026-03-22 01:16:32 +01:00 committed by GitHub
parent 50dcbf4396
commit 33fb7bcc69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 365 additions and 1535 deletions

View file

@ -1,4 +1,4 @@
import { damageKeyToNumber, getDamageLabel } from '../../helpers/utils.mjs';
import { damageKeyToNumber, getArmorSources, getDamageLabel } from '../../helpers/utils.mjs';
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
@ -21,15 +21,11 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
this.rulesDefault
);
const allArmorEffects = Array.from(actor.allApplicableEffects()).filter(x => x.system.armorData);
const orderedArmorEffects = game.system.api.data.activeEffects.changeTypes.armor.orderEffectsForAutoChange(
allArmorEffects,
true
);
const armor = orderedArmorEffects.reduce((acc, effect) => {
const { current, max } = effect.system.armorData;
const orderedArmorSources = getArmorSources(actor).filter(s => !s.disabled);
const armor = orderedArmorSources.reduce((acc, { document }) => {
const { current, max } = document.type === 'armor' ? document.system.armor : document.system.armorData;
acc.push({
effect: effect,
effect: document,
marks: [...Array(max).keys()].reduce((acc, _, index) => {
const spent = index < current;
acc[foundry.utils.randomID()] = { selected: false, disabled: spent, spent };
@ -159,8 +155,11 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
const parent = source.effect.origin
? await foundry.utils.fromUuid(source.effect.origin)
: source.effect.parent;
const useEffectName = parent.type === 'armor' || parent instanceof Actor;
const label = useEffectName ? source.effect.name : parent.name;
armorSources.push({
label: parent.name,
label: label,
uuid: source.effect.uuid,
marks: source.marks
});
@ -219,13 +218,10 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
const maxArmor = this.actor.system.rules.damageReduction.maxArmorMarked.value;
this.marks = {
armor: Object.keys(this.marks.armor).reduce((acc, key, index) => {
const mark = this.marks.armor[key];
armor: this.marks.armor.map((mark, index) => {
const keepSelectValue = !this.rulesOn || index + 1 <= maxArmor;
acc[key] = { ...mark, selected: keepSelectValue ? mark.selected : false };
return acc;
}, {}),
return { ...mark, selected: keepSelectValue ? mark.selected : false };
}),
stress: this.marks.stress
};