improve effects type checking

This commit is contained in:
Johannes Loher 2020-12-29 00:33:43 +01:00
parent aa0c4741d2
commit 082cd03b71
6 changed files with 13 additions and 8 deletions

2
package-lock.json generated
View file

@ -2678,7 +2678,7 @@
} }
}, },
"foundry-pc-types": { "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", "from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes",
"dev": true, "dev": true,
"requires": { "requires": {

View file

@ -9,7 +9,7 @@ interface DS4ActorDataAttributes {
mind: ExtensibleData<number>; mind: ExtensibleData<number>;
} }
interface ExtensibleData<T extends any> { interface ExtensibleData<T> {
initial: T; initial: T;
} }

View file

@ -1,3 +1,4 @@
import { DS4ItemDataType } from "../item/item-data";
import { DS4Actor } from "./actor"; import { DS4Actor } from "./actor";
import { DS4ActorDataType } from "./actor-data"; import { DS4ActorDataType } from "./actor-data";
@ -5,7 +6,7 @@ import { DS4ActorDataType } from "./actor-data";
* Extend the basic ActorSheet with some very simple modifications * Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet} * @extends {ActorSheet}
*/ */
export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor> { export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4ItemDataType> {
/** @override */ /** @override */
static get defaultOptions(): FormApplicationOptions { static get defaultOptions(): FormApplicationOptions {
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
@ -70,7 +71,7 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor> {
data: data, data: data,
}; };
// Remove the type from the dataset since it's in the itemData.type prop. // 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! // Finally, create the item!
return this.actor.createOwnedItem(itemData); return this.actor.createOwnedItem(itemData);

View file

@ -1,10 +1,12 @@
import { DS4Item } from "../item/item";
import { DS4ItemDataType } from "../item/item-data";
import { DS4ActorDataType } from "./actor-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. * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor} * @extends {Actor}
*/ */
export class DS4Actor extends Actor<DS4ActorDataType> { export class DS4Actor extends Actor<DS4ActorDataType, DS4ItemDataType, DS4Item> {
/** @override */ /** @override */
prepareDerivedData(): void { prepareDerivedData(): void {
const data = this.data; const data = this.data;

View file

@ -26,8 +26,8 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
/** @override */ /** @override */
getData(): ItemSheetData<DS4ItemDataType, DS4Item> { getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
console.log(this);
const data = { ...super.getData(), config: CONFIG.DS4 }; const data = { ...super.getData(), config: CONFIG.DS4 };
console.log(data);
return data; return data;
} }
@ -59,7 +59,7 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
html.find(".effect-edit").on("click", (ev) => { html.find(".effect-edit").on("click", (ev) => {
const li = $(ev.currentTarget).parents(".effect"); const li = $(ev.currentTarget).parents(".effect");
console.log(li.data("effectId")); 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); effect.sheet.render(true);
}); });

View file

@ -1,10 +1,12 @@
import { DS4Actor } from "../actor/actor";
import { DS4ActorDataType } from "../actor/actor-data";
import { DS4ItemDataType } from "./item-data"; import { DS4ItemDataType } from "./item-data";
/** /**
* Extend the basic Item with some very simple modifications. * Extend the basic Item with some very simple modifications.
* @extends {Item} * @extends {Item}
*/ */
export class DS4Item extends Item<DS4ItemDataType> { export class DS4Item extends Item<DS4ItemDataType, DS4ActorDataType, DS4Actor> {
/** /**
* Augment the basic Item data model with additional dynamic data. * Augment the basic Item data model with additional dynamic data.
*/ */