import { ModifiableData } from "../common/common-data"; import { DS4Item } from "../item/item"; import { DS4ItemDataType, ItemType } from "../item/item-data"; import { DS4ActorDataType } from "./actor-data"; 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)); const combatValues = data.data.combatValues; Object.values(combatValues).forEach( (combatValue: ModifiableData) => (combatValue.total = combatValue.base + combatValue.mod), ); combatValues.hitPoints.max = combatValues.hitPoints.total; } /** * The list of item types that can be owned by this actor. */ get ownableItemTypes(): Array { switch (this.data.type) { case "character": return [ "weapon", "armor", "shield", "spell", "trinket", "equipment", "talent", "racialAbility", "language", "alphabet", ]; case "creature": return ["weapon", "armor", "spell", "specialCreatureAbility"]; default: []; } } /** * Checks whether or not the given item type can be owned by the actor. * @param itemType the item type to check */ canOwnItemType(itemType: ItemType): boolean { return this.ownableItemTypes.includes(itemType); } }