Create the Item data model
This commit is contained in:
parent
cc8f054115
commit
f91c3d2419
5 changed files with 38 additions and 13 deletions
|
|
@ -2,6 +2,9 @@
|
||||||
"TYPES": {
|
"TYPES": {
|
||||||
"Actor": {
|
"Actor": {
|
||||||
"player": "Player"
|
"player": "Player"
|
||||||
|
},
|
||||||
|
"Item": {
|
||||||
|
"generic": "Generic Item"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"taf": {
|
"taf": {
|
||||||
|
|
|
||||||
25
module/data/Item/generic.mjs
Normal file
25
module/data/Item/generic.mjs
Normal 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: ``,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
const { Item } = foundry.documents;
|
|
||||||
|
|
||||||
export class TAFItem extends Item {
|
|
||||||
async _preCreate() {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
@ -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__,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,14 @@
|
||||||
"filePathFields": {}
|
"filePathFields": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Item": {}
|
"Item": {
|
||||||
|
"generic": {
|
||||||
|
"htmlFields": [
|
||||||
|
"description"
|
||||||
|
],
|
||||||
|
"filePathFields": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"flags": {
|
"flags": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue