This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
foundryvtt-beam-saber/module/blades-item-sheet.js
2021-06-16 14:49:54 +03:00

66 lines
1.8 KiB
JavaScript

/**
* Extend the basic ItemSheet
* @extends {ItemSheet}
*/
import {onManageActiveEffect, prepareActiveEffectCategories} from "./effects.js";
export class BladesItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["blades-in-the-dark", "sheet", "item"],
width: 560,
height: 'auto',
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
});
}
/* -------------------------------------------- */
/** @override */
get template() {
const path = "systems/blades-in-the-dark/templates/items";
let simple_item_types = ["background", "heritage", "vice", "crew_reputation"];
let template_name = `${this.item.data.type}`;
if (simple_item_types.indexOf(this.item.data.type) >= 0) {
template_name = "simple";
}
return `${path}/${template_name}.html`;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
html.find(".effect-control").click(ev => {
if ( this.item.isOwned ) return ui.notifications.warn(game.i18n.localize("BITD.EffectWarning"))
onManageActiveEffect(ev, this.item)
});
}
/* -------------------------------------------- */
/** @override */
getData() {
const data = super.getData();
data.isGM = game.user.isGM;
data.editable = this.options.editable;
const itemData = data.data;
data.actor = itemData;
data.data = itemData.data;
// Prepare Active Effects
data.effects = prepareActiveEffectCategories(this.item.effects);
return data;
}
}