2022-12-15 21:44:23 +01:00
|
|
|
import { Hero6Utility } from "./hero6-utility.js";
|
|
|
|
|
|
|
|
export class Hero6RollDialog extends Dialog {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async create(actor, rollData) {
|
|
|
|
|
2023-02-01 12:16:04 +01:00
|
|
|
let options = { classes: ["Hero6Dialog"], width: 460, height: 'fit-content', 'z-index': 99999 };
|
|
|
|
let html = await renderTemplate('systems/fvtt-hero-system-6/templates/apps/roll-dialog-generic.hbs', rollData);
|
2022-12-15 21:44:23 +01:00
|
|
|
|
|
|
|
return new Hero6RollDialog(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() {
|
|
|
|
Hero6Utility.rollHero6(this.rollData)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async refreshDialog() {
|
2023-02-01 12:16:04 +01:00
|
|
|
const content = await renderTemplate("systems/fvtt-hero-system-6/templates/apps/roll-dialog-generic.hbs", this.rollData)
|
2022-12-15 21:44:23 +01:00
|
|
|
this.data.content = content
|
|
|
|
this.render(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
var dialog = this;
|
|
|
|
function onLoad() {
|
|
|
|
}
|
|
|
|
$(function () { onLoad(); });
|
|
|
|
|
|
|
|
html.find('#advantage').change((event) => {
|
|
|
|
this.rollData.advantage = event.currentTarget.value
|
|
|
|
})
|
|
|
|
html.find('#disadvantage').change((event) => {
|
|
|
|
this.rollData.disadvantage = event.currentTarget.value
|
|
|
|
})
|
|
|
|
html.find('#rollAdvantage').change((event) => {
|
|
|
|
this.rollData.rollAdvantage = event.currentTarget.value
|
|
|
|
})
|
|
|
|
html.find('#useshield').change((event) => {
|
|
|
|
this.rollData.useshield = event.currentTarget.checked
|
|
|
|
})
|
|
|
|
html.find('#hasCover').change((event) => {
|
|
|
|
this.rollData.hasCover = event.currentTarget.value
|
|
|
|
})
|
|
|
|
html.find('#situational').change((event) => {
|
|
|
|
this.rollData.situational = event.currentTarget.value
|
|
|
|
})
|
2023-02-01 12:16:04 +01:00
|
|
|
html.find('#bonusMalus').change((event) => {
|
|
|
|
this.rollData.bonusMalus = Number(event.currentTarget.value)
|
2022-12-15 21:44:23 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|