From 61c6f6edd99934eea65f752f8e3bde98cc516b64 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 25 Jan 2021 10:32:13 +0100 Subject: [PATCH] move calculation of total attributes and traits to prepareBaseData --- src/module/actor/actor.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 56a7d01..889ec29 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -19,6 +19,18 @@ export class DS4Actor extends Actor this.applyActiveEffectsToDerivedData(); } + /** @override */ + prepareBaseData(): void { + const data = this.data; + const attributes = data.data.attributes; + Object.values(attributes).forEach( + (attribute: ModifiableData) => (attribute.total = attribute.base + attribute.mod), + ); + + const traits = data.data.traits; + Object.values(traits).forEach((trait: ModifiableData) => (trait.total = trait.base + trait.mod)); + } + applyActiveEffectsToNonDerivedData(): void { this.applyActiveEffectsFiltered((change) => !this.derivedDataProperties.includes(change.key)); } @@ -61,22 +73,13 @@ export class DS4Actor extends Actor /** @override */ prepareDerivedData(): void { - const data = this.data; - const attributes = data.data.attributes; - Object.values(attributes).forEach( - (attribute: ModifiableData) => (attribute.total = attribute.base + attribute.mod), - ); - - const traits = data.data.traits; - Object.values(traits).forEach((trait: ModifiableData) => (trait.total = trait.base + trait.mod)); - this._prepareCombatValues(); } /** The list of properties that are derived from others, given in dot notation */ get derivedDataProperties(): Array { return Object.keys(DS4.combatValues) - .map((combatValue) => `data.combatValues.${combatValue}.base`) + .map((combatValue) => `data.combatValues.${combatValue}.total`) .concat("data.combatValues.hitPoints.max"); }