Added a updateArmorValue function that updates armoreffects according to an auto order

This commit is contained in:
WBHarry 2026-02-09 21:51:58 +01:00
parent fb9f89fa9d
commit 9dc5830e18
2 changed files with 75 additions and 5 deletions

View file

@ -115,6 +115,34 @@ export default class ArmorEffect extends foundry.data.ActiveEffectTypeDataModel
await this.parent.update({ 'system.changes': newChanges });
}
static orderEffectsForAutoChange(armorEffects, increasing) {
const getEffectWeight = effect => {
switch (effect.parent.type) {
case 'loot':
case 'consumable':
return 2;
case 'class':
case 'subclass':
case 'ancestry':
case 'community':
case 'feature':
case 'domainCard':
return 3;
case 'weapon':
case 'armor':
return 4;
case 'character':
return 5;
default:
return 1;
}
};
return armorEffects.sort((a, b) =>
increasing ? getEffectWeight(b) - getEffectWeight(a) : getEffectWeight(a) - getEffectWeight(b)
);
}
/* Overrides */
prepareBaseData() {