Resource setup finished

This commit is contained in:
WBHarry 2025-07-12 02:52:16 +02:00
parent 0c742eb91b
commit d9d7b23838
13 changed files with 104 additions and 44 deletions

View file

@ -11,12 +11,15 @@
const fields = foundry.data.fields;
export default class BaseDataItem extends foundry.abstract.TypeDataModel {
static LOCALIZATION_PREFIXES = ['DAGGERHEART.ITEMS'];
/** @returns {ItemDataModelMetadata}*/
static get metadata() {
return {
label: 'Base Item',
type: 'base',
hasDescription: false,
hasResource: false,
isQuantifiable: false,
isInventoryItem: false
};
@ -29,20 +32,22 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() {
const schema = {
uses: new fields.SchemaField({
value: new fields.NumberField({ nullable: true, initial: null }),
const schema = {};
if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true });
if (this.metadata.hasResource) {
schema.resource = new fields.SchemaField({
value: new fields.NumberField({ integer: true, min: 0, nullable: true, initial: null }),
max: new fields.NumberField({ nullable: true, initial: null }),
icon: new fields.StringField({ initial: 'fa-solid fa-hashtag' }),
icon: new fields.StringField(),
recovery: new fields.StringField({
choices: CONFIG.DH.GENERAL.refreshTypes,
initial: null,
nullable: true
})
})
};
if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true });
});
}
if (this.metadata.isQuantifiable)
schema.quantity = new fields.NumberField({ integer: true, initial: 1, min: 0, required: true });

View file

@ -7,7 +7,8 @@ export default class DHDomainCard extends BaseDataItem {
return foundry.utils.mergeObject(super.metadata, {
label: 'TYPES.Item.domainCard',
type: 'domainCard',
hasDescription: true
hasDescription: true,
hasResource: true
});
}

View file

@ -7,7 +7,8 @@ export default class DHFeature extends BaseDataItem {
return foundry.utils.mergeObject(super.metadata, {
label: 'TYPES.Item.feature',
type: 'feature',
hasDescription: true
hasDescription: true,
hasResource: true
});
}