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
|
2021-03-30 22:27:30 +02:00
|
|
|
const buttonsCreatures = {
|
2021-06-30 01:01:24 +02:00
|
|
|
"mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") },
|
|
|
|
"non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") },
|
|
|
|
"sonne": { label: "Sonné", callback: html => this.actor.setSonne() },
|
2021-03-30 22:27:30 +02:00
|
|
|
};
|
|
|
|
const buttonsEntitesCauchemar = {
|
|
|
|
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") }
|
|
|
|
};
|
|
|
|
const buttons = actor.isEntiteCauchemar() ? buttonsEntitesCauchemar : buttonsCreatures;
|
|
|
|
|
2020-11-11 04:21:25 +01:00
|
|
|
let dialogConf = {
|
|
|
|
title: "Jet d'Encaissement",
|
2020-11-07 21:06:37 +01:00
|
|
|
content: html,
|
2021-03-30 22:27:30 +02:00
|
|
|
buttons: buttons,
|
2020-11-11 04:21:25 +01:00
|
|
|
default: "coupMortel"
|
2020-11-07 21:06:37 +01:00
|
|
|
}
|
2020-11-11 04:21:25 +01:00
|
|
|
|
2021-03-30 22:27:30 +02: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;
|
2021-02-17 14:52:50 +01:00
|
|
|
this.encaisserSpecial = "aucun";
|
2020-11-07 21:06:37 +01:00
|
|
|
}
|
|
|
|
|
2021-03-30 22:27:30 +02:00
|
|
|
|
|
|
|
|
2020-11-11 04:21:25 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-03-30 22:27:30 +02:00
|
|
|
performEncaisser(mortalite) {
|
2020-11-11 04:21:25 +01:00
|
|
|
this.actor.encaisserDommages({
|
2021-03-30 22:27:30 +02:00
|
|
|
dmg: {
|
2020-12-15 02:20:24 +01:00
|
|
|
total: Number(this.modifier),
|
2021-02-17 14:52:50 +01:00
|
|
|
encaisserSpecial: this.encaisserSpecial,
|
2021-03-30 22:27:30 +02:00
|
|
|
loc: { result: 0, label: "" },
|
2020-12-16 23:02:15 +01:00
|
|
|
mortalite: mortalite
|
|
|
|
}
|
2020-11-11 04:21:25 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
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
|
|
|
});
|
|
|
|
|
2020-11-15 02:07:41 +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
|
|
|
|
});
|
2021-02-17 14:52:50 +01:00
|
|
|
html.find('#encaisserSpecial').change((event) => {
|
|
|
|
this.encaisserSpecial = 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
|
|
|
}
|