ds4/src/module/actor/actor.ts

25 lines
986 B
TypeScript
Raw Normal View History

2020-12-29 00:33:43 +01:00
import { DS4Item } from "../item/item";
import { DS4ItemDataType } from "../item/item-data";
import { DS4ActorDataType, ModifiableData } from "./actor-data";
2020-12-23 18:23:26 +01:00
2020-12-29 00:33:43 +01:00
export class DS4Actor extends Actor<DS4ActorDataType, DS4ItemDataType, DS4Item> {
2020-12-23 16:52:20 +01:00
/** @override */
2020-12-23 18:23:26 +01:00
prepareDerivedData(): void {
2020-12-23 16:52:20 +01:00
const data = this.data;
const attributes = data.data.attributes;
Object.values(attributes).forEach(
(attribute: ModifiableData<number>) => (attribute.total = attribute.base + attribute.mod),
2020-12-23 16:52:20 +01:00
);
const traits = data.data.traits;
Object.values(traits).forEach((trait: ModifiableData<number>) => (trait.total = trait.base + trait.mod));
2020-12-23 16:52:20 +01:00
const combatValues = data.data.combatValues;
Object.values(combatValues).forEach(
(combatValue: ModifiableData<number>) => (combatValue.total = combatValue.base + combatValue.mod),
);
2021-01-07 12:47:38 +01:00
combatValues.hitPoints.max = combatValues.hitPoints.total;
2020-12-23 16:52:20 +01:00
}
}