2022-12-03 18:31:05 +01:00
|
|
|
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;
|
|
|
|
|
2022-12-09 02:00:31 +01:00
|
|
|
EnvironmentSheetHelper.activateListeners(this);
|
2022-12-03 18:31:05 +01:00
|
|
|
|
|
|
|
html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor());
|
2022-12-03 22:32:32 +01:00
|
|
|
html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event));
|
|
|
|
html.find("a.manger-nourriture").click(event => this.mangerNourriture(event));
|
2022-12-03 18:31:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async _onDropActor(event, dragData) {
|
|
|
|
console.log('faune:dropActor', event, dragData)
|
2022-12-03 22:32:32 +01:00
|
|
|
const linkedActor = fromUuidSync(dragData.uuid);
|
|
|
|
if (linkedActor?.pack) {
|
2022-12-03 18:31:05 +01:00
|
|
|
this.item.update({
|
2022-12-03 22:32:32 +01:00
|
|
|
'system.actor.pack': linkedActor.pack,
|
|
|
|
'system.actor.id': linkedActor._id,
|
|
|
|
'system.actor.name': linkedActor.name
|
2022-12-03 18:31:05 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2022-12-03 22:32:32 +01:00
|
|
|
ui.notifications.warn(`${linkedActor.name} ne provient pas d'un compendium.
|
2022-12-03 18:31:05 +01:00
|
|
|
<br>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': ''
|
|
|
|
});
|
|
|
|
}
|
2022-12-03 22:32:32 +01:00
|
|
|
|
|
|
|
async preparerNourriture(event) {
|
|
|
|
if (this.actor) {
|
|
|
|
await this.actor.preparerNourriture(this.item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async mangerNourriture(event) {
|
|
|
|
if (this.actor) {
|
|
|
|
await this.actor.mangerNourriture(this.item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 18:31:05 +01:00
|
|
|
}
|