2021-11-01 00:28:42 +01:00
|
|
|
import { BoLUtility } from "../system/bol-utility.js";
|
|
|
|
|
2021-07-08 10:12:12 +02:00
|
|
|
/**
|
|
|
|
* Extend the basic ItemSheet with some very simple modifications
|
|
|
|
* @extends {ItemSheet}
|
|
|
|
*/
|
|
|
|
export class BoLItemSheet extends ItemSheet {
|
|
|
|
|
|
|
|
/** @override */
|
|
|
|
static get defaultOptions() {
|
|
|
|
return mergeObject(super.defaultOptions, {
|
|
|
|
classes: ["bol", "sheet", "item"],
|
2021-11-07 20:23:02 +01:00
|
|
|
template: "systems/bol/templates/item/item-sheet.hbs",
|
2021-12-24 04:51:14 +01:00
|
|
|
width: 650,
|
|
|
|
height: 750,
|
2021-07-08 10:12:12 +02:00
|
|
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
2021-12-24 04:51:14 +01:00
|
|
|
getData(options) {
|
|
|
|
const data = super.getData(options);
|
|
|
|
const itemData = data.data;
|
|
|
|
data.config = game.bol.config;
|
|
|
|
data.item = itemData;
|
|
|
|
data.data = itemData.data;
|
|
|
|
data.category = itemData.category;
|
|
|
|
data.itemProperties = this.item.itemProperties;
|
|
|
|
data.isGM = game.user.isGM;
|
2022-01-23 09:25:09 +01:00
|
|
|
|
2022-01-27 07:47:42 +01:00
|
|
|
// Dynamic default data fix/adapt
|
|
|
|
if (itemData.type == "item") {
|
|
|
|
if (!itemData.data.category) {
|
|
|
|
itemData.data.category = "equipment"
|
2022-01-23 09:25:09 +01:00
|
|
|
}
|
2022-01-27 07:47:42 +01:00
|
|
|
if (itemData.data.category == 'spell') {
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
|
|
itemData.data.properties.mandatoryconditions[i] = itemData.data.properties.mandatoryconditions[i] ?? ""
|
|
|
|
}
|
|
|
|
for (let i = 0; i < 8; i++) {
|
|
|
|
itemData.data.properties.optionnalconditions[i] = itemData.data.properties.optionnalconditions[i] ?? ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!itemData.data.subtype) {
|
|
|
|
itemData.data.category = "origin"
|
2022-01-23 09:25:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("ITEMDATA", data);
|
2021-12-24 04:51:14 +01:00
|
|
|
return data;
|
2021-07-08 10:12:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/** @override */
|
|
|
|
setPosition(options = {}) {
|
|
|
|
const position = super.setPosition(options);
|
|
|
|
const sheetBody = this.element.find(".sheet-body");
|
|
|
|
const bodyHeight = position.height - 192;
|
|
|
|
sheetBody.css("height", bodyHeight);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/** @override */
|
|
|
|
activateListeners(html) {
|
2022-01-27 07:47:42 +01:00
|
|
|
|
2021-07-08 10:12:12 +02:00
|
|
|
super.activateListeners(html);
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
// Roll handlers, click handlers, etc. would go here.
|
2021-12-24 04:51:14 +01:00
|
|
|
|
|
|
|
html.find('.armorQuality').change(ev => {
|
|
|
|
const li = $(ev.currentTarget);
|
|
|
|
console.log(game.bol.config.soakFormulas[li.val()]);
|
|
|
|
$('.soakFormula').val(game.bol.config.soakFormulas[li.val()]);
|
|
|
|
});
|
|
|
|
|
2021-07-08 10:12:12 +02:00
|
|
|
}
|
2021-11-08 14:40:29 +01:00
|
|
|
|
2021-07-08 10:12:12 +02:00
|
|
|
}
|