fvtt-imperium5/modules/imperium5-roll-dialog.js

81 lines
2.4 KiB
JavaScript
Raw Normal View History

2022-03-13 16:17:04 +01:00
import { Imperium5Utility } from "./imperium5-utility.js";
2022-03-19 09:30:00 +01:00
export class Imperium5RollDialog extends Dialog {
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
static async create(actor, rollData ) {
2022-10-19 17:30:47 +02:00
let options = { classes: ["Imperium5Dialog"], width: 320, height: 380, 'z-index': 99999 }
2022-03-19 09:30:00 +01:00
let html = await renderTemplate('systems/fvtt-imperium5/templates/roll-dialog-generic.html', rollData)
2022-03-13 16:17:04 +01:00
2022-03-19 09:30:00 +01:00
return new Imperium5RollDialog(actor, rollData, html, options )
2022-03-13 16:17:04 +01:00
}
/* -------------------------------------------- */
constructor(actor, rollData, html, options, close = undefined) {
let conf = {
2022-03-19 09:30:00 +01:00
title:"Jet",
2022-03-13 16:17:04 +01:00
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 () {
2022-03-19 09:30:00 +01:00
Imperium5Utility.rollImperium5( this.rollData )
2022-03-13 16:17:04 +01:00
}
2022-10-19 17:30:47 +02:00
/* -------------------------------------------- */
updatePCPool() {
let value = Imperium5Utility.computeDiceReserve(this.rollData)
$('#ame-total').html(value )
}
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
activateListeners(html) {
2022-03-19 09:30:00 +01:00
super.activateListeners(html)
2022-03-13 16:17:04 +01:00
2022-03-19 09:30:00 +01:00
var dialog = this
2022-03-13 16:17:04 +01:00
function onLoad() {
2022-10-19 17:30:47 +02:00
dialog.updatePCPool()
2022-03-13 16:17:04 +01:00
}
2022-10-19 17:30:47 +02:00
$(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()
})
2022-03-13 16:17:04 +01:00
}
}