import { CrucibleUtility } from "./crucible-utility.js";
export class CrucibleRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData) {
let options = { classes: ["CrucibleDialog"], width: 420, height: 280, 'z-index': 99999 };
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 = {
title: (rollData.mode == "skill") ? "Skill" : "Attribute",
content: html,
buttons: {
roll: {
icon: '',
label: "Roll !",
callback: () => { this.roll() }
},
cancel: {
icon: '',
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(); });
html.find('#none-clicked').change((event) => {
this.rollData.advantage = "none"
this.refreshDialog()
})
html.find('#advantage-clicked').change((event) => {
this.rollData.advantage = "advantage"
this.refreshDialog()
})
html.find('#disadvantage-clicked').change((event) => {
this.rollData.advantage = "disadvantage"
this.refreshDialog()
})
html.find('#roll-with-advantage-clicked').change((event) => {
this.rollData.rollAdvantage = !this.rollData.rollAdvantage
this.refreshDialog()
})
html.find('#featDieName').change((event) => {
this.rollData.featDieName = event.currentTarget.value
})
html.find('#featDieSL').change((event) => {
this.rollData.featDieSL = event.currentTarget.value
})
}
}