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

99 lines
2.8 KiB
JavaScript
Raw Normal View History

2023-11-26 16:18:04 +01:00
import { WastelandUtility } from "./wasteland-utility.js";
export class WastelandRollDialog extends Dialog {
/* -------------------------------------------- */
2023-11-29 22:04:17 +01:00
static async create(actor, rollData) {
2023-11-26 16:18:04 +01:00
let options = { classes: ["WastelandDialog"], width: 340, height: 'fit-content', 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-wasteland/templates/roll-dialog-generic.html', rollData);
2023-11-29 22:04:17 +01:00
return new WastelandRollDialog(actor, rollData, html, options);
2023-11-26 16:18:04 +01:00
}
/* -------------------------------------------- */
constructor(actor, rollData, html, options, close = undefined) {
2023-11-29 22:04:17 +01:00
let buttons = {
rolld10: {
icon: '<i class="fas fa-check"></i>',
label: "Lancer 1d10",
callback: () => { this.roll("1d10") }
},
rolld20: {
icon: '<i class="fas fa-check"></i>',
label: "Lancer 1d20",
callback: () => { this.roll("1d20") }
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Annuler",
callback: () => { this.close() }
}
}
if (rollData.charme) {
buttons = {
roll: {
icon: '<i class="fas fa-check"></i>',
label: "Lancer",
callback: () => { this.roll() }
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Annuler",
callback: () => { this.close() }
}
}
}
2023-11-26 16:18:04 +01:00
let conf = {
title: "Test de Capacité",
content: html,
2023-11-29 22:04:17 +01:00
buttons: buttons,
2023-11-26 16:18:04 +01:00
close: close
}
super(conf, options);
this.actor = actor
this.rollData = rollData
}
/* -------------------------------------------- */
2023-11-29 22:04:17 +01:00
roll(dice) {
2023-11-26 16:18:04 +01:00
this.rollData.mainDice = dice
2023-11-29 22:04:17 +01:00
WastelandUtility.rollWasteland(this.rollData)
2023-11-26 16:18:04 +01:00
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
2023-11-29 22:04:17 +01:00
html.find('#modificateur').change(async (event) => {
2023-11-26 16:18:04 +01:00
this.rollData.modificateur = Number(event.currentTarget.value)
})
2023-11-29 22:04:17 +01:00
html.find('#difficulte').change(async (event) => {
2023-11-26 16:18:04 +01:00
this.rollData.difficulte = Number(event.currentTarget.value)
})
2023-11-29 22:04:17 +01:00
html.find('#attrKey').change(async (event) => {
2023-11-26 16:18:04 +01:00
this.rollData.attrKey = String(event.currentTarget.value)
2023-11-29 22:04:17 +01:00
})
html.find('#runemode').change(async (event) => {
2023-11-26 16:18:04 +01:00
this.rollData.runemode = String(event.currentTarget.value)
2023-11-29 22:04:17 +01:00
})
html.find('#runeame').change(async (event) => {
2023-11-26 16:18:04 +01:00
this.rollData.runeame = Number(event.currentTarget.value)
2023-11-29 22:04:17 +01:00
})
html.find('#doubleD20').change(async (event) => {
2023-11-26 16:18:04 +01:00
this.rollData.doubleD20 = event.currentTarget.checked
2023-11-29 22:04:17 +01:00
})
html.find('#charmeDice').change(async (event) => {
this.rollData.charmeDice = String(event.currentTarget.value)
})
2023-11-26 16:18:04 +01:00
}
}