import { DarkStarsUtility } from "./dark-stars-utility.js"; export class DarkStarsRollDialog extends Dialog { /* -------------------------------------------- */ static async create(actor, rollData) { let options = { classes: ["DarkStarsDialog"], width: 420, height: 'fit-content', 'z-index': 99999 }; let html = await renderTemplate('systems/fvtt-dark-stars/templates/apps/roll-dialog-generic.hbs', rollData); 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: '', label: "Roll !", callback: () => { this.roll() } }, cancel: { icon: '', label: "Cancel", callback: () => { this.close() } } }, close: close } super(conf, options); this.actor = actor; this.rollData = rollData; } /* -------------------------------------------- */ roll() { DarkStarsUtility.rollDarkStars(this.rollData) } /* -------------------------------------------- */ async refreshDialog() { const content = await renderTemplate("systems/fvtt-dark-stars/templates/roll-dialog-generic.hbs", this.rollData) this.data.content = content this.render(true) } /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); var dialog = this; function onLoad() { } $(function () { onLoad(); }); html.find('#bonusMalus').change((event) => { this.rollData.bonusMalus = Number(event.currentTarget.value) }) html.find('#above-effective-range').change((event) => { this.rollData.isAboveEffectiveRange = event.currentTarget.checked }) html.find('#weapon-aiming').change((event) => { this.rollData.weaponAiming = String(event.currentTarget.value) }) html.find('#synergy-bonus').change((event) => { this.rollData.synergyBonus = Number(event.currentTarget.value) }) html.find('#extra-time').change((event) => { this.rollData.extraTime = event.currentTarget.checked }) html.find('#attribute-modifier').change((event) => { this.rollData.attributeModifier = Number(event.currentTarget.value) }) } }