worldbuilding/module/item.js

33 lines
920 B
JavaScript

import {EntitySheetHelper} from "./helper.js";
/**
* Extend the base Item document to support attributes and groups with a custom template creation dialog.
* @extends {Item}
*/
export class SimpleItem extends Item {
/** @inheritdoc */
prepareDerivedData() {
super.prepareDerivedData();
this.data.data.groups = this.data.data.groups || {};
this.data.data.attributes = this.data.data.attributes || {};
EntitySheetHelper.clampResourceValues(this.data.data.attributes);
}
/* -------------------------------------------- */
/** @override */
static async createDialog(data={}, options={}) {
return EntitySheetHelper.createDialog.call(this, data, options);
}
/* -------------------------------------------- */
/**
* Is this Item used as a template for other Items?
* @type {boolean}
*/
get isTemplate() {
return !!this.getFlag("worldbuilding", "isTemplate");
}
}