From 5212509b5c216b41786680a1065bd112992715a2 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 2 Oct 2021 16:06:07 +0200 Subject: [PATCH] feat: round stats after effects have been applied With this change, all stats except for movement are rounded up to the next integer after all effects have been applied. --- src/module/actor/actor.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 1b3a790..2192cf8 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -139,6 +139,22 @@ export class DS4Actor extends Actor { * Apply final transformations to the Actor data after all effects have been applied. */ prepareFinalDerivedData(): void { + Object.values(this.data.data.attributes).forEach( + (attribute: ModifiableDataBaseTotal) => (attribute.total = Math.ceil(attribute.total)), + ); + Object.values(this.data.data.traits).forEach( + (trait: ModifiableDataBaseTotal) => (trait.total = Math.ceil(trait.total)), + ); + Object.entries(this.data.data.combatValues) + .filter(([key]) => key !== "movement") + .map(([, value]) => value) + .forEach( + (combatValue: ModifiableDataBaseTotal) => (combatValue.total = Math.ceil(combatValue.total)), + ); + (Object.keys(this.data.data.checks) as (keyof typeof this.data.data.checks)[]).forEach((key) => { + this.data.data.checks[key] = Math.ceil(this.data.data.checks[key]); + }); + this.data.data.combatValues.hitPoints.max = this.data.data.combatValues.hitPoints.total; this.data.data.checks.defend = this.data.data.combatValues.defense.total; if (this.data.type === "character") {