2020-05-11 12:21:18 +00:00
|
|
|
|
|
|
|
import { BladesSheet } from "./blades-sheet.js";
|
2021-09-20 22:39:57 +00:00
|
|
|
import { BladesActiveEffect } from "./blades-active-effect.js";
|
2020-05-11 12:21:18 +00:00
|
|
|
|
2020-04-17 21:23:57 +00:00
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
2020-05-11 12:21:18 +00:00
|
|
|
* @extends {BladesSheet}
|
2020-04-17 21:23:57 +00:00
|
|
|
*/
|
2020-05-11 12:21:18 +00:00
|
|
|
export class BladesActorSheet extends BladesSheet {
|
2020-04-17 21:23:57 +00:00
|
|
|
|
|
|
|
/** @override */
|
|
|
|
static get defaultOptions() {
|
2021-05-25 10:27:40 +00:00
|
|
|
return foundry.utils.mergeObject(super.defaultOptions, {
|
2023-11-28 22:06:09 +00:00
|
|
|
classes: ["beam-saber", "sheet", "actor", "pc"],
|
|
|
|
template: "systems/beam-saber/templates/actor-sheet.html",
|
2020-04-23 16:11:04 +00:00
|
|
|
width: 700,
|
2020-05-04 10:37:00 +00:00
|
|
|
height: 970,
|
|
|
|
tabs: [{navSelector: ".tabs", contentSelector: ".tab-content", initial: "abilities"}]
|
2020-04-17 21:23:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/** @override */
|
2022-09-03 15:44:26 +00:00
|
|
|
async getData(options) {
|
|
|
|
const superData = super.getData( options );
|
|
|
|
const sheetData = superData.data;
|
|
|
|
sheetData.owner = superData.owner;
|
|
|
|
sheetData.editable = superData.editable;
|
|
|
|
sheetData.isGM = game.user.isGM;
|
2020-04-23 16:11:04 +00:00
|
|
|
|
2021-06-10 22:57:01 +00:00
|
|
|
// Prepare active effects
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.effects = BladesActiveEffect.prepareActiveEffectCategories(this.actor.effects);
|
2021-06-10 22:57:01 +00:00
|
|
|
|
2020-04-23 16:11:04 +00:00
|
|
|
// Calculate Load
|
|
|
|
let loadout = 0;
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.items.forEach(i => {loadout += (i.type === "item") ? parseInt(i.system.load) : 0});
|
|
|
|
|
2020-07-27 13:02:27 +00:00
|
|
|
//Sanity Check
|
|
|
|
if (loadout < 0) {
|
|
|
|
loadout = 0;
|
|
|
|
}
|
|
|
|
if (loadout > 10) {
|
|
|
|
loadout = 10;
|
|
|
|
}
|
2020-07-24 10:39:22 +00:00
|
|
|
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.system.loadout = loadout;
|
|
|
|
|
|
|
|
// Encumbrance Levels
|
|
|
|
let load_level=["BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Normal","BITD.Normal","BITD.Heavy","BITD.Encumbered",
|
|
|
|
"BITD.Encumbered","BITD.Encumbered","BITD.OverMax"];
|
|
|
|
let mule_level=["BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Normal","BITD.Normal",
|
|
|
|
"BITD.Heavy","BITD.Encumbered","BITD.OverMax"];
|
|
|
|
let mule_present=0;
|
|
|
|
|
|
|
|
|
2020-07-24 10:39:22 +00:00
|
|
|
//look for Mule ability
|
2020-08-04 12:39:31 +00:00
|
|
|
// @todo - fix translation.
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.items.forEach(i => {
|
|
|
|
if (i.type === "ability" && i.name === "(C) Mule") {
|
2020-07-27 13:02:27 +00:00
|
|
|
mule_present = 1;
|
|
|
|
}
|
|
|
|
});
|
2020-07-24 10:39:22 +00:00
|
|
|
|
|
|
|
//set encumbrance level
|
2020-07-27 13:02:27 +00:00
|
|
|
if (mule_present) {
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.system.load_level=mule_level[loadout];
|
2020-07-27 13:02:27 +00:00
|
|
|
} else {
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.system.load_level=load_level[loadout];
|
2020-07-27 13:02:27 +00:00
|
|
|
}
|
2020-07-24 10:39:22 +00:00
|
|
|
|
2022-09-03 15:44:26 +00:00
|
|
|
sheetData.system.load_levels = {"BITD.Light":"BITD.Light", "BITD.Normal":"BITD.Normal", "BITD.Heavy":"BITD.Heavy"};
|
|
|
|
|
|
|
|
sheetData.system.description = await TextEditor.enrichHTML(sheetData.system.description, {secrets: sheetData.owner, async: true});
|
|
|
|
|
2023-07-18 22:35:38 +00:00
|
|
|
// catch unmigrated actor data
|
|
|
|
for( const a in sheetData.system.attributes ) {
|
|
|
|
for( const s in sheetData.system.attributes[a].skills ) {
|
|
|
|
if( sheetData.system.attributes[a].skills[s].max === undefined ){
|
|
|
|
sheetData.system.attributes[a].skills[s].max = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 15:44:26 +00:00
|
|
|
return sheetData;
|
2020-04-17 21:23:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/** @override */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
|
|
|
|
// Update Inventory Item
|
2020-04-21 16:06:33 +00:00
|
|
|
html.find('.item-body').click(ev => {
|
|
|
|
const element = $(ev.currentTarget).parents(".item");
|
2021-05-25 10:27:40 +00:00
|
|
|
const item = this.actor.items.get(element.data("itemId"));
|
2020-04-17 21:23:57 +00:00
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Delete Inventory Item
|
2021-05-25 10:27:40 +00:00
|
|
|
html.find('.item-delete').click( async ev => {
|
2020-04-21 16:06:33 +00:00
|
|
|
const element = $(ev.currentTarget).parents(".item");
|
2021-05-25 10:27:40 +00:00
|
|
|
await this.actor.deleteEmbeddedDocuments("Item", [element.data("itemId")]);
|
2020-04-22 07:57:36 +00:00
|
|
|
element.slideUp(200, () => this.render(false));
|
2020-04-17 21:23:57 +00:00
|
|
|
});
|
2021-06-10 22:57:01 +00:00
|
|
|
|
|
|
|
// manage active effects
|
2021-09-20 22:39:57 +00:00
|
|
|
html.find(".effect-control").click(ev => BladesActiveEffect.onManageActiveEffect(ev, this.actor));
|
2020-04-17 21:23:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
}
|