From 082cd03b7100cc1f9f2774a891ff53a7ee050533 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 29 Dec 2020 00:33:43 +0100 Subject: [PATCH] improve effects type checking --- package-lock.json | 2 +- src/module/actor/actor-data.ts | 2 +- src/module/actor/actor-sheet.ts | 5 +++-- src/module/actor/actor.ts | 4 +++- src/module/item/item-sheet.ts | 4 ++-- src/module/item/item.ts | 4 +++- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9b1dfbe..58ddfec0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2678,7 +2678,7 @@ } }, "foundry-pc-types": { - "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#211c36bdde13400f02421dc0f911b255767dac76", + "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#4ae5653e74e79bb6b4bd23b094dee066a0c7723a", "from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes", "dev": true, "requires": { diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index 93bb7883..a202f15f 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -9,7 +9,7 @@ interface DS4ActorDataAttributes { mind: ExtensibleData; } -interface ExtensibleData { +interface ExtensibleData { initial: T; } diff --git a/src/module/actor/actor-sheet.ts b/src/module/actor/actor-sheet.ts index 43af361c..a45371d7 100644 --- a/src/module/actor/actor-sheet.ts +++ b/src/module/actor/actor-sheet.ts @@ -1,3 +1,4 @@ +import { DS4ItemDataType } from "../item/item-data"; import { DS4Actor } from "./actor"; import { DS4ActorDataType } from "./actor-data"; @@ -5,7 +6,7 @@ import { DS4ActorDataType } from "./actor-data"; * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ -export class DS4ActorSheet extends ActorSheet { +export class DS4ActorSheet extends ActorSheet { /** @override */ static get defaultOptions(): FormApplicationOptions { return mergeObject(super.defaultOptions, { @@ -70,7 +71,7 @@ export class DS4ActorSheet extends ActorSheet { data: data, }; // Remove the type from the dataset since it's in the itemData.type prop. - delete itemData.data["type"]; + delete itemData.data.type; // Finally, create the item! return this.actor.createOwnedItem(itemData); diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 5f67e96e..40717808 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -1,10 +1,12 @@ +import { DS4Item } from "../item/item"; +import { DS4ItemDataType } from "../item/item-data"; import { DS4ActorDataType } from "./actor-data"; /** * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * @extends {Actor} */ -export class DS4Actor extends Actor { +export class DS4Actor extends Actor { /** @override */ prepareDerivedData(): void { const data = this.data; diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index d6798804..1e69b3c9 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -26,8 +26,8 @@ export class DS4ItemSheet extends ItemSheet { /** @override */ getData(): ItemSheetData { + console.log(this); const data = { ...super.getData(), config: CONFIG.DS4 }; - console.log(data); return data; } @@ -59,7 +59,7 @@ export class DS4ItemSheet extends ItemSheet { html.find(".effect-edit").on("click", (ev) => { const li = $(ev.currentTarget).parents(".effect"); console.log(li.data("effectId")); - const effect = this.item["effects"].get(li.data("effectId")); // TODO: replace ["..."] + const effect = this.item.effects.get(li.data("effectId")); effect.sheet.render(true); }); diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 87a15b1e..c32f0cfe 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,10 +1,12 @@ +import { DS4Actor } from "../actor/actor"; +import { DS4ActorDataType } from "../actor/actor-data"; import { DS4ItemDataType } from "./item-data"; /** * Extend the basic Item with some very simple modifications. * @extends {Item} */ -export class DS4Item extends Item { +export class DS4Item extends Item { /** * Augment the basic Item data model with additional dynamic data. */