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.
This commit is contained in:
Johannes Loher 2021-10-02 16:06:07 +02:00
parent 73a6ad4bbc
commit 5212509b5c

View file

@ -139,6 +139,22 @@ export class DS4Actor extends Actor {
* Apply final transformations to the Actor data after all effects have been applied. * Apply final transformations to the Actor data after all effects have been applied.
*/ */
prepareFinalDerivedData(): void { prepareFinalDerivedData(): void {
Object.values(this.data.data.attributes).forEach(
(attribute: ModifiableDataBaseTotal<number>) => (attribute.total = Math.ceil(attribute.total)),
);
Object.values(this.data.data.traits).forEach(
(trait: ModifiableDataBaseTotal<number>) => (trait.total = Math.ceil(trait.total)),
);
Object.entries(this.data.data.combatValues)
.filter(([key]) => key !== "movement")
.map(([, value]) => value)
.forEach(
(combatValue: ModifiableDataBaseTotal<number>) => (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.combatValues.hitPoints.max = this.data.data.combatValues.hitPoints.total;
this.data.data.checks.defend = this.data.data.combatValues.defense.total; this.data.data.checks.defend = this.data.data.combatValues.defense.total;
if (this.data.type === "character") { if (this.data.type === "character") {