This repository has been archived on 2023-01-25. You can view files and clone it, but cannot push or open issues or pull requests.
fvtt-avd12/modules/avd12-roll-dialog.js

69 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2022-10-17 15:20:18 +02:00
import { Avd12Utility } from "./avd12-utility.js";
export class Avd12RollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData) {
let options = { classes: ["Avd12Dialog"], width: 540, height: 'fit-content', 'z-index': 99999 };
2022-11-27 16:06:26 +01:00
let html = await renderTemplate('systems/fvtt-avd12/templates/dialogs/roll-dialog-generic.hbs', rollData);
2022-10-17 15:20:18 +02:00
2022-11-27 16:06:26 +01:00
return new Avd12RollDialog(actor, rollData, html, options);
2022-10-17 15:20:18 +02:00
}
/* -------------------------------------------- */
constructor(actor, rollData, html, options, close = undefined) {
let conf = {
title: (rollData.mode == "skill") ? "Skill" : "Attribute",
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() {
Avd12Utility.rollAvd12(this.rollData)
}
/* -------------------------------------------- */
async refreshDialog() {
2022-11-27 16:06:26 +01:00
const content = await renderTemplate("systems/fvtt-avd12/templates/dialogs/roll-dialog-generic.hbs", this.rollData)
2022-10-17 15:20:18 +02:00
this.data.content = content
this.render(true)
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
2022-11-27 16:06:26 +01:00
html.find('#bonusMalusRoll').change((event) => {
this.rollData.bonusMalusRoll = event.currentTarget.value
2022-10-17 15:20:18 +02:00
})
2022-11-27 16:06:26 +01:00
html.find('#targetCheck').change((event) => {
this.rollData.targetCheck = event.currentTarget.value
2022-10-17 15:20:18 +02:00
})
2022-11-27 16:06:26 +01:00
2022-10-17 15:20:18 +02:00
}
}