fvtt-pegasus-rpg/modules/pegasus-roll-dialog.js

86 lines
3.0 KiB
JavaScript
Raw Normal View History

2021-12-02 07:38:59 +01:00
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 };
2022-01-13 16:13:00 +01:00
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") {
2021-12-02 20:18:21 +01:00
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);
2021-12-02 07:38:59 +01:00
options.height = 360;
2022-01-14 18:20:15 +01:00
} else if (rollData.mode == "weapon" || rollData.mode == "armor" || rollData.mode == "power") {
2021-12-02 07:38:59 +01:00
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-weapon.html', rollData);
2022-01-14 15:18:36 +01:00
options.height = 320;
2021-12-02 07:38:59 +01:00
} 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: '<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 () {
2021-12-02 20:18:21 +01:00
PegasusUtility.rollPegasus( this.rollData )
2021-12-02 07:38:59 +01:00
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
2022-01-11 23:35:23 +01:00
html.find('#specList').change((event) => {
this.rollData.selectedSpec = event.currentTarget.value;
});
2022-01-13 16:13:00 +01:00
html.find('#statDicesLevel').change((event) => {
this.rollData.statDicesLevel = Number(event.currentTarget.value);
});
html.find('#specDicesLevel').change((event) => {
this.rollData.specDicesLevel = Number(event.currentTarget.value);
});
2021-12-02 20:18:21 +01:00
html.find('#bonusDicesLevel').change((event) => {
this.rollData.bonusDicesLevel = Number(event.currentTarget.value);
2021-12-02 07:38:59 +01:00
});
2021-12-02 20:18:21 +01:00
html.find('#hindranceDicesLevel').change((event) => {
this.rollData.hindranceDicesLevel = Number(event.currentTarget.value);
2021-12-02 07:38:59 +01:00
});
2021-12-02 20:18:21 +01:00
html.find('#otherDicesLevel').change((event) => {
this.rollData.otherDicesLevel = Number(event.currentTarget.value);
2021-12-02 07:38:59 +01:00
});
}
}