/** * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ import { VadentisUtility } from "./vadentis-utility.js"; /* -------------------------------------------- */ export class VadentisActorSheet extends ActorSheet { /** @override */ static get defaultOptions() { return mergeObject(super.defaultOptions, { classes: ["vadentis", "sheet", "actor"], template: "systems/foundryvtt-vadentis/templates/actor-sheet.html", width: 640, height: 720, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }], dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], editScore: false }); } /* -------------------------------------------- */ getData() { let data = super.getData(); data.stats = this.actor.stats; data.combat = this.actor.combat; data.magie = this.actor.magie; data.editScore = this.options.editScore; data.donnees = this.actor.getDonnees(); data.competences = this.actor.getCompetences(); data.sorts = this.actor.getSorts(); data.devotions = this.actor.getDevotions(); data.isGM = game.user.isGM; return data; } /* -------------------------------------------- */ /** @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 html.find('.item-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("item-id")); item.sheet.render(true); }); // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); VadentisUtility.confirmDelete(this, li); }); html.find('.combat-label a').click((event) => { let combatName = event.currentTarget.attributes.name.value; this.actor.rollCombat(combatName); }); html.find('.competence-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); const competenceId = li.data("item-id"); this.actor.rollCompetence(competenceId); }); html.find('.sort-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); const sortId = li.data("item-id"); this.actor.rollSort(sortId); }); html.find('.devotion-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); const devotionId = li.data("item-id"); this.actor.rollDevotion(devotionId); }); html.find('.weapon-label a').click((event) => { const li = $(event.currentTarget).parents(".item"); const weapon = this.actor.getOwnedItem(li.data("item-id")); this.actor.rollWeapon(weapon); }); html.find('.competence-base').change((event) => { let skillName = event.currentTarget.attributes.skillname.value; this.actor.updateCompetence(skillName, "base", parseInt(event.target.value)); }); html.find('.competence-bonus').change((event) => { let skillName = event.currentTarget.attributes.skillname.value; this.actor.updateCompetence(skillName, "bonus", parseInt(event.target.value)); }); html.find('.competence-malus').change((event) => { let skillName = event.currentTarget.attributes.skillname.value; this.actor.updateCompetence(skillName, "malus", parseInt(event.target.value)); }); html.find('.lock-unlock-sheet').click((event) => { this.options.editScore = !this.options.editScore; this.render(true); }); html.find('.item-link a').click((event) => { const itemId = $(event.currentTarget).data("item-id"); const item = this.actor.getOwnedItem(itemId); item.sheet.render(true); }); } /* -------------------------------------------- */ /** @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 */ _updateObject(event, formData) { // Update the Actor return this.object.update(formData); } }