foundryvtt-reve-de-dragon/module/rdd-roll-encaisser.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-11-07 21:06:37 +01:00
/**
* Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog}
*/
export class RdDEncaisser extends Dialog {
2020-11-11 04:21:25 +01:00
/* -------------------------------------------- */
2020-11-10 13:53:51 +01:00
constructor(html, actor) {
2020-11-07 21:06:37 +01:00
// Common conf
2020-11-11 04:21:25 +01:00
let dialogConf = {
title: "Jet d'Encaissement",
2020-11-07 21:06:37 +01:00
content: html,
2020-11-11 04:21:25 +01:00
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"
2020-11-07 21:06:37 +01:00
}
2020-11-11 04:21:25 +01:00
let dialogOptions = {
classes: ["rdddialog"],
width: 320,
height: 240
}
2020-11-07 21:06:37 +01:00
// Select proper roll dialog template and stuff
super(dialogConf, dialogOptions);
2020-11-11 04:21:25 +01:00
this.actor = actor;
2020-11-10 13:53:51 +01:00
this.modifier = 0;
2020-11-07 21:06:37 +01:00
}
2020-11-11 04:21:25 +01:00
/* -------------------------------------------- */
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) {
2020-11-07 21:06:37 +01:00
super.activateListeners(html);
2020-11-10 13:53:51 +01:00
// Setup everything onload
2020-11-11 04:21:25 +01:00
$(function () {
$("#modificateurDegats").val("0");
2020-11-10 13:53:51 +01:00
});
html.find('#modificateurDegats').change((event) => {
2020-11-10 13:53:51 +01:00
this.modifier = event.currentTarget.value; // Update the selected bonus/malus
});
2020-11-07 21:06:37 +01:00
}
2020-11-11 04:21:25 +01:00
2020-11-07 21:06:37 +01:00
}