/** * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ import { Imperium5Utility } from "./imperium5-utility.js"; import { Imperium5RollDialog } from "./imperium5-roll-dialog.js"; /* -------------------------------------------- */ export class Imperium5ActorSheet extends ActorSheet { /** @override */ static get defaultOptions() { return mergeObject(super.defaultOptions, { classes: ["fvtt-imperium5", "sheet", "actor"], template: "systems/fvtt-imperium5/templates/actor-sheet.html", width: 720, height: 760, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "combat" }], dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], editScore: true }); } /* -------------------------------------------- */ async getData() { let actorData = duplicate(this.object.system) let formData = { title: this.title, id: this.actor.id, type: this.actor.type, img: this.actor.img, name: this.actor.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", system: actorData, archetype: this.actor.getArchetype(), specialites: this.actor.getSpecialites(), familiarites: this.actor.getFamiliarites(), nature: this.actor.getNatureProfonde(), traits: this.actor.getTraits(), symbioses: this.actor.getSymbioses(), equipements: this.actor.getEquipements(), capacites: this.actor.getCapacites(), singularites: this.actor.getSingularites(), contacts: this.actor.getContacts(), effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, options: this.options, owner: this.document.isOwner, editScore: this.options.editScore, isGM: game.user.isGM } this.formData = formData; console.log("PC : ", formData, this.object); return formData; } /* -------------------------------------------- */ /** @override */ activateListeners(html) { super.activateListeners(html); // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; html.bind("keydown", function(e) { // Ignore Enter in actores sheet if (e.keyCode === 13) return false; }); // Update Inventory Item html.find('.item-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); let itemId = li.data("item-id"); const item = this.actor.items.get( itemId ); item.sheet.render(true); }); // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); Imperium5Utility.confirmDelete(this, li); }); html.find('.equip-activate').click(ev => { const li = $(ev.currentTarget).parents(".item") let itemId = li.data("item-id") this.actor.equipActivate( itemId) }); html.find('.equip-deactivate').click(ev => { const li = $(ev.currentTarget).parents(".item") let itemId = li.data("item-id") this.actor.equipDeactivate( itemId) }); html.find('.subactor-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); let actorId = li.data("actor-id"); let actor = game.actors.get( actorId ); actor.sheet.render(true); }); html.find('.subactor-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); let actorId = li.data("actor-id"); this.actor.delSubActor(actorId); }); html.find('.quantity-minus').click(event => { const li = $(event.currentTarget).parents(".item"); this.actor.incDecQuantity( li.data("item-id"), -1 ); } ); html.find('.quantity-plus').click(event => { const li = $(event.currentTarget).parents(".item"); this.actor.incDecQuantity( li.data("item-id"), +1 ); } ); html.find('.roll-ame-button').click((event) => { const ameKey = $(event.currentTarget).data("ame-key") this.actor.rollAme(ameKey) }); 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); }); html.find('.item-equip').click(ev => { const li = $(ev.currentTarget).parents(".item"); this.actor.equipItem( li.data("item-id") ); this.render(true); }); html.find('.update-field').change(ev => { const fieldName = $(ev.currentTarget).data("field-name"); let value = Number(ev.currentTarget.value); this.actor.update( { [`${fieldName}`]: value } ); }); } /* -------------------------------------------- */ /** @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; } /* -------------------------------------------- */ async _onDropItemUNUSED(event, dragData) { let item = await Imperium5Utility.searchItem( dragData) if (item == undefined) { item = this.actor.items.get( dragData.data._id ) } //this.actor.preprocessItem( event, item, true ) super._onDropItem(event, dragData) } /* -------------------------------------------- */ /** @override */ _updateObject(event, formData) { // Update the Actor return this.object.update(formData); } }