import { Imperium5Utility } from "./imperium5-utility.js"; export class Imperium5RollDialog extends Dialog { /* -------------------------------------------- */ static async create(actor, rollData ) { let options = { classes: ["Imperium5Dialog"], width: 320, height: 380, 'z-index': 99999 } let html = await renderTemplate('systems/fvtt-imperium5/templates/roll-dialog-generic.html', rollData) return new Imperium5RollDialog(actor, rollData, html, options ) } /* -------------------------------------------- */ constructor(actor, rollData, html, options, close = undefined) { let conf = { title:"Jet", 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 () { Imperium5Utility.rollImperium5( this.rollData ) } /* -------------------------------------------- */ updatePCPool() { let value = Imperium5Utility.computeDiceReserve(this.rollData) $('#ame-total').html(value ) } /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html) var dialog = this function onLoad() { dialog.updatePCPool() } $(function () { onLoad(); }) html.find('#select-realite-dice').change(async (event) => { this.rollData.realiteDice = Number(event.currentTarget.value) }) html.find('#select-capacite').change(async (event) => { this.rollData.usedCapacite = String(event.currentTarget.value) this.updatePCPool() }) html.find('#select-use-archetype').change(async (event) => { this.rollData.useArchetype = event.currentTarget.checked this.updatePCPool() }) html.find('#select-use-aide').change(async (event) => { this.rollData.useAide = event.currentTarget.checked this.updatePCPool() }) html.find('#select-use-karma').change(async (event) => { this.rollData.useKarma = event.currentTarget.checked this.updatePCPool() }) } }