import { EnvironmentSheetHelper } from "./environnement.js"; import { RdDItemSheet } from "./item-sheet.js"; import { RdDUtility } from "./rdd-utility.js"; export class RdDFauneItemSheet extends RdDItemSheet { static get ITEM_TYPE() { return "faune" }; static get defaultOptions() { return EnvironmentSheetHelper.defaultOptions(super.defaultOptions); } setPosition(options = {}) { return EnvironmentSheetHelper.setPosition(this, super.setPosition(options)); } async getData() { const formData = await super.getData(); return await EnvironmentSheetHelper.getData(this, formData); } activateListeners(html) { super.activateListeners(html); if (!this.options.editable) return; EnvironmentSheetHelper.activateListeners(this); html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor()); html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event)); html.find("a.manger-nourriture").click(event => this.mangerNourriture(event)); } async _onDropActor(event, dragData) { console.log('faune:dropActor', event, dragData) const linkedActor = fromUuidSync(dragData.uuid); if (linkedActor?.pack) { this.item.update({ 'system.actor.pack': linkedActor.pack, 'system.actor.id': linkedActor._id, 'system.actor.name': linkedActor.name }); } else { ui.notifications.warn(`${linkedActor.name} ne provient pas d'un compendium.
Choisissez une créature du compendium pour représenter un élément de faune générique`) } } async onDeleteLinkedActor() { this.item.update({ 'system.actor.pack': '', 'system.actor.id': '', 'system.actor.name': '' }); } async preparerNourriture(event) { if (this.actor) { await this.actor.preparerNourriture(this.item); } } async mangerNourriture(event) { if (this.actor) { await this.actor.mangerNourriture(this.item); } } }