Merge branch 'improved-effects-type-checking' into 'master'

improve effects type checking

See merge request dungeonslayers/ds4!5
This commit is contained in:
Johannes Loher 2020-12-29 18:23:25 +01:00
commit 7bf4f78a68
6 changed files with 13 additions and 8 deletions

2
package-lock.json generated
View file

@ -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": {

View file

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

View file

@ -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<DS4ActorDataType, DS4Actor> {
export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4ItemDataType> {
/** @override */
static get defaultOptions(): FormApplicationOptions {
return mergeObject(super.defaultOptions, {
@ -70,7 +71,7 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor> {
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);

View file

@ -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<DS4ActorDataType> {
export class DS4Actor extends Actor<DS4ActorDataType, DS4ItemDataType, DS4Item> {
/** @override */
prepareDerivedData(): void {
const data = this.data;

View file

@ -26,8 +26,8 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
/** @override */
getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
console.log(this);
const data = { ...super.getData(), config: CONFIG.DS4 };
console.log(data);
return data;
}
@ -59,7 +59,7 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
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);
});

View file

@ -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<DS4ItemDataType> {
export class DS4Item extends Item<DS4ItemDataType, DS4ActorDataType, DS4Actor> {
/**
* Augment the basic Item data model with additional dynamic data.
*/