foundryvtt-reve-de-dragon/module/rdd-roll-encaisser.js
Vincent Vandemeulebrouck 52caf1b39a Separation difficulte libre/conditions
* ajout de diffConditions pour gérer l'ajustement de conditions
* renommage de bmValue en diffLibre
* calcul de l'ajustement (etat+conditions+difficulté libre)
* présentation des 2 champs

fix:
* utiliser .change() au lieu de .click() permet de supporter aussi
les changements au clavier
2020-11-15 02:08:22 +01:00

59 lines
1.6 KiB
JavaScript

/**
* Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog}
*/
export class RdDEncaisser extends Dialog {
/* -------------------------------------------- */
constructor(html, actor) {
// Common conf
let dialogConf = {
title: "Jet d'Encaissement",
content: html,
buttons: {
"mortel": { label: "mortel", callback: html => this.performEncaisser(html, "mortel") },
"non-mortel": { label: "non-mortel", callback: html => this.performEncaisser(html, "non-mortel") },
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser(html, "cauchemar") }
},
default: "coupMortel"
}
let dialogOptions = {
classes: ["rdddialog"],
width: 320,
height: 240
}
// Select proper roll dialog template and stuff
super(dialogConf, dialogOptions);
this.actor = actor;
this.modifier = 0;
}
/* -------------------------------------------- */
performEncaisser(html, mortalite = "mortel") {
this.actor.encaisserDommages({
degats: new Roll("2d10").roll().total,
domArmePlusDom: Number(this.modifier),
loc: { result: 0, label: "Corps" },
mortalite: mortalite
});
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
// Setup everything onload
$(function () {
$("#modificateurDegats").val("0");
});
html.find('#modificateurDegats').change((event) => {
this.modifier = event.currentTarget.value; // Update the selected bonus/malus
});
}
}