From 38a34372671c685addc6e4c39cb5d01753212faa Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 16 Feb 2021 16:34:23 +0100 Subject: [PATCH] Small cleanup --- src/module/actor/actor.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index f6ef1878..889e8b3d 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -15,7 +15,7 @@ export class DS4Actor extends Actor { if (!this.data.name) this.data.name = "New " + this.entity; this.prepareBaseData(); this.prepareEmbeddedEntities(); - this.applyActiveEffectsToNonDerivedData(); + this.applyActiveEffectsToBaseData(); this.prepareDerivedData(); this.applyActiveEffectsToDerivedData(); this.prepareFinalDerivedData(); @@ -24,6 +24,7 @@ export class DS4Actor extends Actor { /** @override */ prepareBaseData(): void { const data = this.data; + const attributes = data.data.attributes; Object.values(attributes).forEach( (attribute: ModifiableData) => (attribute.total = attribute.base + attribute.mod), @@ -33,7 +34,7 @@ export class DS4Actor extends Actor { Object.values(traits).forEach((trait: ModifiableData) => (trait.total = trait.base + trait.mod)); } - applyActiveEffectsToNonDerivedData(): void { + applyActiveEffectsToBaseData(): void { this.applyActiveEffectsFiltered( (change) => !this.derivedDataProperties.includes(change.key) && !this.finalDerivedProperties.includes(change.key), @@ -90,8 +91,7 @@ export class DS4Actor extends Actor { } protected _getOriginatingItemOfActiveEffect(effect: ActiveEffect): DS4Item | undefined { - const item = this.items.find((item) => item.uuid === effect.data.origin); - return item ?? undefined; + return this.items.find((item) => item.uuid === effect.data.origin) ?? undefined; } /** @@ -119,8 +119,8 @@ export class DS4Actor extends Actor { } /** - * The list of properties that are completely derived (i.e. {@link ActiveEffect}s cannot be applied to them), given in dot - * notation. + * The list of properties that are completely derived (i.e. {@link ActiveEffect}s cannot be applied to them), + * given in dot notation. */ get finalDerivedProperties(): string[] { return ["data.combatValues.hitPoints.max"]; @@ -165,9 +165,9 @@ export class DS4Actor extends Actor { protected _prepareCombatValues(): void { const data = this.data.data; const armorValueOfEquippedItems = this._calculateArmorValueOfEquippedItems(); + data.combatValues.hitPoints.base = (data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + 10; - data.combatValues.defense.base = (data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + armorValueOfEquippedItems; data.combatValues.initiative.base = (data.attributes.mobility.total ?? 0) + (data.traits.agility.total ?? 0);