46 lines
1.4 KiB
JavaScript

export class DialogEnchanter extends Dialog {
static async create(item, actor, callback) {
const enchanter = {
actor: actor,
item: item,
nouveaupr: item.system.pr,
prpermanent: item.system.prpermanent,
purifier: false
}
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/item/potion/dialog-enchanter.hbs`, enchanter)
return new DialogEnchanter(enchanter, html, callback)
}
constructor(enchanter, html, callback) {
let options = { classes: ["dialog-enchanter"], width: 400, height: 'fit-content', 'z-index': 99999 }
let conf = {
title: "Enchanter une potion",
content: html,
default: "enchanter",
buttons: {
"enchanter": { label: "Enchanter", callback: it => this.onEnchanter() }
}
};
super(conf, options)
this.callback = callback
this.enchanter = enchanter
}
activateListeners(html) {
super.activateListeners(html)
this.html = html
this.html.find("input.nouveaupr").change(event => this.enchanter.nouveaupr = Number(event.currentTarget.value))
this.html.find("input.purifier").change(event => this.enchanter.purifier = event.currentTarget.checked)
this.html.find("input.prpermanent").change(event => this.enchanter.prpermanent = event.currentTarget.checked)
}
async onEnchanter() {
await this.html.find(".nouveaupr").change()
this.callback(this.enchanter);
}
}