2022-11-27 08:58:19 +01:00
|
|
|
import { DarkStarsUtility } from "./dark-stars-utility.js";
|
|
|
|
|
|
|
|
export class DarkStarsRollDialog extends Dialog {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async create(actor, rollData) {
|
|
|
|
|
2022-12-30 22:27:38 +01:00
|
|
|
let options = { classes: ["DarkStarsDialog"], width: 320, height: 'fit-content', 'z-index': 99999 };
|
|
|
|
let html = await renderTemplate('systems/fvtt-dark-stars/templates/apps/roll-dialog-generic.hbs', rollData);
|
2022-11-27 08:58:19 +01:00
|
|
|
|
|
|
|
return new DarkStarsRollDialog(actor, rollData, html, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
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() {
|
|
|
|
DarkStarsUtility.rollDarkStars(this.rollData)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async refreshDialog() {
|
2022-12-04 12:16:25 +01:00
|
|
|
const content = await renderTemplate("systems/fvtt-dark-stars/templates/roll-dialog-generic.hbs", this.rollData)
|
2022-11-27 08:58:19 +01:00
|
|
|
this.data.content = content
|
|
|
|
this.render(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
var dialog = this;
|
|
|
|
function onLoad() {
|
|
|
|
}
|
|
|
|
$(function () { onLoad(); });
|
|
|
|
|
2022-12-30 22:27:38 +01:00
|
|
|
html.find('#bonusMalus').change((event) => {
|
|
|
|
this.rollData.bonusMalus = Number(event.currentTarget.value)
|
2022-11-27 08:58:19 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|