This repository has been archived on 2024-05-29. You can view files and clone it, but cannot push or open issues or pull requests.
fvtt-warhero/modules/warhero-roll-dialog.js

73 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2023-01-04 22:09:09 +01:00
import { WarheroUtility } from "./warhero-utility.js";
2023-01-04 21:24:56 +01:00
2023-01-04 22:09:09 +01:00
export class WarheroRollDialog extends Dialog {
2023-01-04 21:24:56 +01:00
/* -------------------------------------------- */
static async create(actor, rollData) {
2023-02-06 07:37:39 +01:00
let options = { classes: ["WarheroDialog"], width: 420, height: 'fit-content', 'z-index': 99999 };
2023-01-04 22:09:09 +01:00
let html = await renderTemplate('systems/fvtt-warhero/templates/roll-dialog-generic.html', rollData);
2023-01-04 21:24:56 +01:00
2023-01-04 22:09:09 +01:00
return new WarheroRollDialog(actor, rollData, html, options);
2023-01-04 21:24:56 +01: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() {
2023-01-04 22:09:09 +01:00
WarheroUtility.rollWarhero(this.rollData)
2023-01-04 21:24:56 +01:00
}
/* -------------------------------------------- */
async refreshDialog() {
2023-01-04 22:09:09 +01:00
const content = await renderTemplate("systems/fvtt-warhero/templates/roll-dialog-generic.html", this.rollData)
2023-01-04 21:24:56 +01:00
this.data.content = content
this.render(true)
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
2023-01-29 18:32:30 +01:00
html.find('#powerLevel').change((event) => {
this.rollData.powerLevel = event.currentTarget.value
2023-01-04 21:24:56 +01:00
})
2023-01-29 16:56:09 +01:00
html.find('#bonusMalus').change((event) => {
this.rollData.bonusMalus = Number(event.currentTarget.value)
2023-01-04 21:24:56 +01:00
})
2023-02-06 07:37:39 +01:00
html.find('#usemWeaponMalus').change((event) => {
this.rollData.usemWeaponMalus = event.currentTarget.checked
})
2023-01-04 21:24:56 +01:00
}
}