Create the Item data model

This commit is contained in:
Oliver 2026-03-08 13:11:14 -06:00
parent cc8f054115
commit f91c3d2419
5 changed files with 38 additions and 13 deletions

View file

@ -2,6 +2,9 @@
"TYPES": { "TYPES": {
"Actor": { "Actor": {
"player": "Player" "player": "Player"
},
"Item": {
"generic": "Generic Item"
} }
}, },
"taf": { "taf": {

View file

@ -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: ``,
}),
};
};
};

View file

@ -1,7 +0,0 @@
const { Item } = foundry.documents;
export class TAFItem extends Item {
async _preCreate() {
return false;
};
};

View file

@ -5,11 +5,11 @@ import { SingleModePlayerSheet } from "../apps/SingleModePlayerSheet.mjs";
// Data Models // Data Models
import { PlayerData } from "../data/Player.mjs"; import { PlayerData } from "../data/Player.mjs";
import { GenericItemData } from "../data/Item/generic.mjs";
// Documents // Documents
import { TAFActor } from "../documents/Actor.mjs"; import { TAFActor } from "../documents/Actor.mjs";
import { TAFCombatant } from "../documents/Combatant.mjs"; import { TAFCombatant } from "../documents/Combatant.mjs";
import { TAFItem } from "../documents/Item.mjs";
import { TAFTokenDocument } from "../documents/Token.mjs"; import { TAFTokenDocument } from "../documents/Token.mjs";
// Settings // Settings
@ -30,10 +30,7 @@ Hooks.on(`init`, () => {
CONFIG.Combatant.documentClass = TAFCombatant; CONFIG.Combatant.documentClass = TAFCombatant;
CONFIG.Actor.dataModels.player = PlayerData; CONFIG.Actor.dataModels.player = PlayerData;
CONFIG.Item.dataModels.generic = GenericItemData;
// We disable items in the system for now
CONFIG.Item.documentClass = TAFItem;
delete CONFIG.ui.sidebar.TABS.items;
foundry.documents.collections.Actors.registerSheet( foundry.documents.collections.Actors.registerSheet(
__ID__, __ID__,

View file

@ -39,7 +39,14 @@
"filePathFields": {} "filePathFields": {}
} }
}, },
"Item": {} "Item": {
"generic": {
"htmlFields": [
"description"
],
"filePathFields": {}
}
}
}, },
"socket": true, "socket": true,
"flags": { "flags": {