mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Added a updateArmorValue function that updates armoreffects according to an auto order
This commit is contained in:
parent
fb9f89fa9d
commit
9dc5830e18
2 changed files with 75 additions and 5 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue