diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index d6575c24..1ddcb9c9 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -1,2 +1,26 @@ +export type DS4ActorDataType = EntityData; + // TODO: Actually add a type for data -export type DS4ActorDataType = unknown; +export class DS4ActorData { + public attributes: DS4ActorDataAttributes; + public traits: DS4ActorDataTraits; +} + +class DS4ActorDataAttributes { + public body: ExpandableAttribute; + public mobility: ExpandableAttribute; + public mind: ExpandableAttribute; +} + +class ExpandableAttribute { + public initial: T; +} + +class DS4ActorDataTraits { + public strength: ExpandableAttribute; + public constitution: ExpandableAttribute; + public agility: ExpandableAttribute; + public dexterity: ExpandableAttribute; + public intellect: ExpandableAttribute; + public aura: ExpandableAttribute; +} diff --git a/src/module/actor/actor-sheet.ts b/src/module/actor/actor-sheet.ts index 4a16bfa7..57128b34 100644 --- a/src/module/actor/actor-sheet.ts +++ b/src/module/actor/actor-sheet.ts @@ -21,9 +21,9 @@ export class DS4ActorSheet extends ActorSheet { /** @override */ getData(): ActorSheetData { - // TODO: replace ["..."] access with . const data = super.getData(); - data["dtypes"] = ["String", "Number", "Boolean"]; + const checkboxTypes = [typeof String, typeof Number, typeof Boolean]; + console.log(data.data["attributes"]); for (const attr of Object.values(data.data["attributes"])) { attr["isCheckbox"] = attr["dtype"] === "Boolean"; } @@ -99,7 +99,7 @@ export class DS4ActorSheet extends ActorSheet { const dataset = element.dataset; if (dataset.roll) { - const roll = new Roll(dataset.roll, this.actor.data.data as Record); + const roll = new Roll(dataset.roll, this.actor.data.data); const label = dataset.label ? `Rolling ${dataset.label}` : ""; roll.roll().toMessage({ speaker: ChatMessage.getSpeaker({ actor: this.actor }), diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 38292ed7..e1f806b0 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -1,4 +1,4 @@ -import { DS4ActorDataType } from "./actor-data"; +import { DS4ActorData, DS4ActorDataType } from "./actor-data"; /** * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. @@ -13,21 +13,20 @@ export class DS4Actor extends Actor { _prepareCombatValues(data: ActorData): void { const hitPointsModifier = getProperty(data, "data.combatValues.hitPoints.modifier") || 0; + // data.data seems to get initialized with the enitity's data + const actorData = (data.data as unknown) as DS4ActorData; setProperty( data, "data.combatValues.hitPoints.max", - data.data["attributes"]["body"].initial + // TODO: replace ["..."] - data.data["traits"]["constitution"].initial + // TODO: replace ["..."] - 10 + - hitPointsModifier, + actorData.attributes.body.initial + actorData.traits.constitution.initial + 10 + hitPointsModifier, ); const defenseModifier = getProperty(data, "data.combatValues.defense.modifier") || 0; setProperty( data, "data.combatValues.defense.value", - data.data["attributes"]["body"].initial + // TODO: replace ["..."] - data.data["traits"]["constitution"].initial + // TODO: replace ["..."] + actorData.attributes.body.initial + + actorData.traits.constitution.initial + this._getArmorValue() + defenseModifier, ); diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index d9258449..eff93c0d 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -6,7 +6,7 @@ import { DS4ItemDataType } from "./item-data"; * Extend the basic ItemSheet with some very simple modifications * @extends {ItemSheet} */ -export class DS4ItemSheet extends ItemSheet { +export class DS4ItemSheet extends ItemSheet { /** @override */ static get defaultOptions(): FormApplicationOptions { return mergeObject(super.defaultOptions, {