2022-07-19 23:16:03 +02:00
|
|
|
import { CrucibleUtility } from "./crucible-utility.js";
|
|
|
|
|
|
|
|
export class CrucibleRollDialog extends Dialog {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async create(actor, rollData) {
|
|
|
|
|
2022-07-31 19:32:54 +02:00
|
|
|
let options = { classes: ["CrucibleDialog"], width: 540, height: 340, 'z-index': 99999 };
|
2022-07-19 23:16:03 +02:00
|
|
|
let html = await renderTemplate('systems/fvtt-crucible-rpg/templates/roll-dialog-generic.html', rollData);
|
|
|
|
|
|
|
|
return new CrucibleRollDialog(actor, rollData, html, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
constructor(actor, rollData, html, options, close = undefined) {
|
|
|
|
let conf = {
|
2022-07-26 21:40:42 +02:00
|
|
|
title: (rollData.mode == "skill") ? "Skill" : "Attribute",
|
2022-07-19 23:16:03 +02:00
|
|
|
content: html,
|
|
|
|
buttons: {
|
|
|
|
roll: {
|
|
|
|
icon: '<i class="fas fa-check"></i>',
|
|
|
|
label: "Roll !",
|
|
|
|
callback: () => { this.roll() }
|
|
|
|
},
|
|
|
|
cancel: {
|
|
|
|
icon: '<i class="fas fa-times"></i>',
|
|
|
|
label: "Cancel",
|
|
|
|
callback: () => { this.close() }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
close: close
|
|
|
|
}
|
|
|
|
|
|
|
|
super(conf, options);
|
|
|
|
|
|
|
|
this.actor = actor;
|
|
|
|
this.rollData = rollData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
roll() {
|
|
|
|
CrucibleUtility.rollCrucible(this.rollData)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async refreshDialog() {
|
|
|
|
const content = await renderTemplate("systems/fvtt-crucible-rpg/templates/roll-dialog-generic.html", this.rollData)
|
|
|
|
this.data.content = content
|
|
|
|
this.render(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
var dialog = this;
|
|
|
|
function onLoad() {
|
|
|
|
}
|
|
|
|
$(function () { onLoad(); });
|
|
|
|
|
2022-07-31 19:32:54 +02:00
|
|
|
html.find('#advantage').change((event) => {
|
|
|
|
this.rollData.advantage = event.currentTarget.value
|
2022-07-19 23:16:03 +02:00
|
|
|
})
|
2022-08-01 21:39:17 +02:00
|
|
|
html.find('#disadvantage').change((event) => {
|
|
|
|
this.rollData.disadvantage = event.currentTarget.value
|
|
|
|
})
|
2022-07-31 19:32:54 +02:00
|
|
|
html.find('#rollAdvantage').change((event) => {
|
|
|
|
this.rollData.rollAdvantage = event.currentTarget.value
|
2022-07-30 23:29:55 +02:00
|
|
|
})
|
2022-08-10 14:41:40 +02:00
|
|
|
html.find('#useshield').change((event) => {
|
|
|
|
this.rollData.useShield = event.currentTarget.checked
|
2022-07-30 22:54:08 +02:00
|
|
|
})
|
|
|
|
|
2022-07-19 23:16:03 +02:00
|
|
|
}
|
|
|
|
}
|