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

79 lines
2.4 KiB
JavaScript
Raw Normal View History

2022-02-23 22:31:53 +01:00
import { MournbladeUtility } from "./mournblade-utility.js";
export class MournbladeRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData ) {
2022-11-30 12:22:40 +01:00
let options = { classes: ["MournbladeDialog"], width: 340, height: 'fit-content', 'z-index': 99999 };
2022-02-23 22:31:53 +01:00
let html = await renderTemplate('systems/fvtt-mournblade/templates/roll-dialog-generic.html', rollData);
return new MournbladeRollDialog(actor, rollData, html, options );
}
/* -------------------------------------------- */
constructor(actor, rollData, html, options, close = undefined) {
let conf = {
title: "Test de Capacité",
2022-02-23 22:31:53 +01:00
content: html,
buttons: {
rolld10: {
2022-02-23 22:31:53 +01:00
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") }
2022-02-23 22:31:53 +01:00
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Annuler",
2022-02-23 22:31:53 +01:00
callback: () => { this.close() }
} },
close: close
}
super(conf, options);
this.actor = actor
this.rollData = rollData
2022-02-23 22:31:53 +01:00
}
/* -------------------------------------------- */
roll ( dice) {
this.rollData.mainDice = dice
2022-02-23 22:31:53 +01:00
MournbladeUtility.rollMournblade( this.rollData )
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
var dialog = this;
function onLoad() {
}
$(function () { onLoad(); });
html.find('#modificateur').change(async (event) => {
this.rollData.modificateur = Number(event.currentTarget.value)
})
html.find('#difficulte').change(async (event) => {
this.rollData.difficulte = Number(event.currentTarget.value)
})
2022-06-05 18:49:38 +02:00
html.find('#attrKey').change(async (event) => {
this.rollData.attrKey = String(event.currentTarget.value)
})
2022-06-26 18:52:31 +02:00
html.find('#runemode').change(async (event) => {
this.rollData.runemode = String(event.currentTarget.value)
})
html.find('#runeame').change(async (event) => {
this.rollData.runeame = Number(event.currentTarget.value)
})
2022-06-05 15:54:17 +02:00
html.find('#doubleD20').change(async (event) => {
this.rollData.doubleD20 = event.currentTarget.checked
})
2022-02-23 22:31:53 +01:00
}
}