From f91c3d2419ad09289768bed3a9b198695032d39b Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 8 Mar 2026 13:11:14 -0600 Subject: [PATCH] Create the Item data model --- langs/en-ca.json | 3 +++ module/data/Item/generic.mjs | 25 +++++++++++++++++++++++++ module/documents/Item.mjs | 7 ------- module/hooks/init.mjs | 7 ++----- system.json | 9 ++++++++- 5 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 module/data/Item/generic.mjs delete mode 100644 module/documents/Item.mjs diff --git a/langs/en-ca.json b/langs/en-ca.json index 6dee3ec..2790b0a 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -2,6 +2,9 @@ "TYPES": { "Actor": { "player": "Player" + }, + "Item": { + "generic": "Generic Item" } }, "taf": { diff --git a/module/data/Item/generic.mjs b/module/data/Item/generic.mjs new file mode 100644 index 0000000..b030f6f --- /dev/null +++ b/module/data/Item/generic.mjs @@ -0,0 +1,25 @@ +export class GenericItemData extends foundry.abstract.TypeDataModel { + static defineSchema() { + const fields = foundry.data.fields; + return { + weight: new fields.NumberField({ + min: 0, + initial: 0, + nullable: false, + }), + quantity: new fields.NumberField({ + integer: true, + min: 0, + initial: 1, + }), + equipped: new fields.BooleanField({ + initial: true, + }), + description: new fields.HTMLField({ + blank: true, + trim: true, + initial: ``, + }), + }; + }; +}; diff --git a/module/documents/Item.mjs b/module/documents/Item.mjs deleted file mode 100644 index 683187e..0000000 --- a/module/documents/Item.mjs +++ /dev/null @@ -1,7 +0,0 @@ -const { Item } = foundry.documents; - -export class TAFItem extends Item { - async _preCreate() { - return false; - }; -}; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 6ff92f0..283405a 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -5,11 +5,11 @@ import { SingleModePlayerSheet } from "../apps/SingleModePlayerSheet.mjs"; // Data Models import { PlayerData } from "../data/Player.mjs"; +import { GenericItemData } from "../data/Item/generic.mjs"; // Documents import { TAFActor } from "../documents/Actor.mjs"; import { TAFCombatant } from "../documents/Combatant.mjs"; -import { TAFItem } from "../documents/Item.mjs"; import { TAFTokenDocument } from "../documents/Token.mjs"; // Settings @@ -30,10 +30,7 @@ Hooks.on(`init`, () => { CONFIG.Combatant.documentClass = TAFCombatant; CONFIG.Actor.dataModels.player = PlayerData; - - // We disable items in the system for now - CONFIG.Item.documentClass = TAFItem; - delete CONFIG.ui.sidebar.TABS.items; + CONFIG.Item.dataModels.generic = GenericItemData; foundry.documents.collections.Actors.registerSheet( __ID__, diff --git a/system.json b/system.json index 94e2ccd..a756e80 100644 --- a/system.json +++ b/system.json @@ -39,7 +39,14 @@ "filePathFields": {} } }, - "Item": {} + "Item": { + "generic": { + "htmlFields": [ + "description" + ], + "filePathFields": {} + } + } }, "socket": true, "flags": {