import { PegasusUtility } from "./pegasus-utility.js"; export class PegasusRollDialog extends Dialog { /* -------------------------------------------- */ static async create(actor, rollData ) { let html let options = { classes: ["WotGdialog"], width: 420, height: 320, 'z-index': 99999 }; if ( rollData.mode == "generic" ) { html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-generic.html', rollData); options.height = 320; } else if ( rollData.mode == "stat" || rollData.mode == "MR") { html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-stat.html', rollData); options.height = 320; } else if (rollData.mode == "spec") { html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-spec.html', rollData); options.height = 360; } else if (rollData.mode == "weapon") { html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-weapon.html', rollData); options.height = 460; } else { html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-skill.html', rollData); } return new PegasusRollDialog(actor, rollData, html, options ); } /* -------------------------------------------- */ constructor(actor, rollData, html, options, close = undefined) { let conf = { title: (rollData.mode == "skill") ? "Skill" : "Roll", content: html, buttons: { roll: { icon: '', label: "Roll !", callback: () => { this.roll() } }, cancel: { icon: '', label: "Cancel", callback: () => { this.close() } } }, default: "roll", close: close } super(conf, options); this.actor = actor; this.rollData = rollData; } /* -------------------------------------------- */ roll () { PegasusUtility.rollPegasus( this.rollData ) } /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); var dialog = this; function onLoad() { } $(function () { onLoad(); }); html.find('#specList').change((event) => { this.rollData.selectedSpec = event.currentTarget.value; }); html.find('#statDicesLevel').change((event) => { this.rollData.statDicesLevel = Number(event.currentTarget.value); }); html.find('#specDicesLevel').change((event) => { this.rollData.specDicesLevel = Number(event.currentTarget.value); }); html.find('#bonusDicesLevel').change((event) => { this.rollData.bonusDicesLevel = Number(event.currentTarget.value); }); html.find('#hindranceDicesLevel').change((event) => { this.rollData.hindranceDicesLevel = Number(event.currentTarget.value); }); html.find('#otherDicesLevel').change((event) => { this.rollData.otherDicesLevel = Number(event.currentTarget.value); }); } }