2023-12-11 21:41:51 +01:00
|
|
|
import { TeDeumUtility } from "../common/tedeum-utility.js";
|
2023-12-11 20:11:10 +01:00
|
|
|
|
2023-12-11 21:41:51 +01:00
|
|
|
export class TeDeumRollDialog extends Dialog {
|
2023-12-11 20:11:10 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async create(actor, rollData) {
|
|
|
|
|
2023-12-11 21:41:51 +01:00
|
|
|
let options = { classes: ["tedeum-roll-dialog"], width: 540, height: 'fit-content', 'z-index': 99999 }
|
2024-05-31 09:23:01 +02:00
|
|
|
let html = await renderTemplate('systems/fvtt-te-deum/templates/dialogs/roll-dialog-generic.hbs', rollData);
|
2023-12-11 21:41:51 +01:00
|
|
|
return new TeDeumRollDialog(actor, rollData, html, options);
|
2023-12-11 20:11:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
constructor(actor, rollData, html, options, close = undefined) {
|
|
|
|
let conf = {
|
2023-12-11 22:24:19 +01:00
|
|
|
title: "Lancer !",
|
2023-12-11 20:11:10 +01:00
|
|
|
content: html,
|
|
|
|
buttons: {
|
|
|
|
roll: {
|
|
|
|
icon: '<i class="fas fa-check"></i>',
|
2023-12-11 22:24:19 +01:00
|
|
|
label: "Lancer",
|
2023-12-11 20:11:10 +01:00
|
|
|
callback: () => { this.roll() }
|
|
|
|
},
|
|
|
|
cancel: {
|
|
|
|
icon: '<i class="fas fa-times"></i>',
|
2023-12-11 22:24:19 +01:00
|
|
|
label: "Annuler",
|
2023-12-11 20:11:10 +01:00
|
|
|
callback: () => { this.close() }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
close: close
|
|
|
|
}
|
|
|
|
|
|
|
|
super(conf, options);
|
|
|
|
|
|
|
|
this.actor = actor;
|
|
|
|
this.rollData = rollData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
roll() {
|
2024-05-31 09:23:01 +02:00
|
|
|
TeDeumUtility.rollTeDeum(this.rollData)
|
2023-12-11 20:11:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async refreshDialog() {
|
2024-05-31 09:23:01 +02:00
|
|
|
const content = await renderTemplate("systems/fvtt-te-deum/templates/dialogs/roll-dialog-generic.hbs", this.rollData)
|
2023-12-11 20:11:10 +01:00
|
|
|
this.data.content = content
|
|
|
|
this.render(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
2023-12-11 22:44:06 +01:00
|
|
|
let dialog = this;
|
2023-12-11 20:11:10 +01:00
|
|
|
function onLoad() {
|
|
|
|
}
|
|
|
|
$(function () { onLoad(); });
|
|
|
|
|
|
|
|
html.find('#bonusMalusPerso').change((event) => {
|
|
|
|
this.rollData.bonusMalusPerso = Number(event.currentTarget.value)
|
|
|
|
})
|
|
|
|
html.find('#roll-difficulty').change((event) => {
|
2024-05-31 09:23:01 +02:00
|
|
|
this.rollData.difficulty = String(event.currentTarget.value) || "pardefaut"
|
2023-12-11 20:11:10 +01:00
|
|
|
})
|
2024-05-31 09:23:01 +02:00
|
|
|
html.find('#roll-bonus-malus').change((event) => {
|
|
|
|
this.rollData.bonusMalus = event.currentTarget.value || "0"
|
|
|
|
})
|
|
|
|
html.find('#roll-enable-providence').change((event) => {
|
|
|
|
this.rollData.enableProvidence = event.currentTarget.checked
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2023-12-11 20:11:10 +01:00
|
|
|
}
|
|
|
|
}
|