2023-04-28 15:25:57 +02:00
|
|
|
import { EcrymeUtility } from "../common/ecryme-utility.js";
|
2023-04-19 18:44:41 +02:00
|
|
|
|
|
|
|
export class EcrymeRollDialog extends Dialog {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async create(actor, rollData) {
|
|
|
|
|
2023-05-26 07:46:06 +02:00
|
|
|
let options = { classes: ["ecryme-roll-dialog"], width: 540, height: 'fit-content', 'z-index': 99999 }
|
|
|
|
let html = await renderTemplate('systems/fvtt-ecryme/templates/dialogs/roll-dialog-generic.hbs', rollData);
|
2023-04-19 18:44:41 +02:00
|
|
|
return new EcrymeRollDialog(actor, rollData, html, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
constructor(actor, rollData, html, options, close = undefined) {
|
|
|
|
let conf = {
|
2023-05-26 07:46:06 +02:00
|
|
|
title: game.i18n.localize("ECRY.ui.rolltitle"),
|
2023-04-19 18:44:41 +02:00
|
|
|
content: html,
|
|
|
|
buttons: {
|
|
|
|
roll: {
|
|
|
|
icon: '<i class="fas fa-check"></i>',
|
2023-05-26 07:46:06 +02:00
|
|
|
label: game.i18n.localize("ECRY.ui.roll"),
|
2023-04-19 18:44:41 +02:00
|
|
|
callback: () => { this.roll() }
|
|
|
|
},
|
|
|
|
cancel: {
|
|
|
|
icon: '<i class="fas fa-times"></i>',
|
2023-05-26 07:46:06 +02:00
|
|
|
label: game.i18n.localize("ECRY.ui.cancel"),
|
2023-04-19 18:44:41 +02:00
|
|
|
callback: () => { this.close() }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
close: close
|
|
|
|
}
|
|
|
|
|
|
|
|
super(conf, options);
|
|
|
|
|
|
|
|
this.actor = actor;
|
|
|
|
this.rollData = rollData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
roll() {
|
2023-05-26 07:46:06 +02:00
|
|
|
EcrymeUtility.rollEcryme(this.rollData)
|
2023-04-19 18:44:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async refreshDialog() {
|
|
|
|
const content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/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('#bonusMalusPerso').change((event) => {
|
|
|
|
this.rollData.bonusMalusPerso = Number(event.currentTarget.value)
|
|
|
|
})
|
2023-05-26 07:46:06 +02:00
|
|
|
html.find('#roll-difficulty').change((event) => {
|
|
|
|
this.rollData.difficulty = Number(event.currentTarget.value) || 0
|
2023-04-19 18:44:41 +02:00
|
|
|
})
|
2023-05-26 07:46:06 +02:00
|
|
|
html.find('#roll-specialization').change((event) => {
|
|
|
|
this.rollData.selectedSpecs = $('#roll-specialization').val()
|
2023-04-19 18:44:41 +02:00
|
|
|
})
|
2023-05-26 07:46:06 +02:00
|
|
|
html.find('#roll-trait-bonus').change((event) => {
|
|
|
|
this.rollData.traitsBonus = $('#roll-trait-bonus').val()
|
2023-04-19 18:44:41 +02:00
|
|
|
})
|
2023-05-26 07:46:06 +02:00
|
|
|
html.find('#roll-trait-malus').change((event) => {
|
|
|
|
this.rollData.traitsMalus = $('#roll-trait-malus').val()
|
2023-04-19 18:44:41 +02:00
|
|
|
})
|
2023-05-26 07:46:06 +02:00
|
|
|
html.find('#roll-select-transcendence').change((event) => {
|
|
|
|
this.rollData.skillTranscendence = Number($('#roll-select-transcendence').val())
|
|
|
|
})
|
|
|
|
html.find('#roll-use-spleen').change((event) => {
|
|
|
|
this.rollData.useSpleen = event.currentTarget.checked
|
|
|
|
})
|
|
|
|
html.find('#roll-use-ideal').change((event) => {
|
|
|
|
this.rollData.useIdeal = event.currentTarget.checked
|
|
|
|
})
|
|
|
|
|
2023-04-19 18:44:41 +02:00
|
|
|
}
|
|
|
|
}
|