2022-10-08 15:38:56 +02:00
|
|
|
import { ENTITE_BLURETTE, ENTITE_INCARNE} from "./constants.js";
|
2022-07-22 21:38:15 +02:00
|
|
|
|
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
|
2022-07-22 21:38:15 +02:00
|
|
|
let buttons = {};
|
|
|
|
if (!actor.isEntite()){
|
|
|
|
buttons = {
|
|
|
|
"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() },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])){
|
|
|
|
buttons = {
|
|
|
|
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") }
|
|
|
|
}
|
|
|
|
}
|
2021-03-30 22:27:30 +02:00
|
|
|
|
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,
|
2021-11-10 00:11:15 +01:00
|
|
|
default: "mortel"
|
2020-11-07 21:06:37 +01:00
|
|
|
}
|
2020-11-11 04:21:25 +01:00
|
|
|
|
|
|
|
let dialogOptions = {
|
|
|
|
classes: ["rdddialog"],
|
|
|
|
width: 320,
|
2022-10-09 02:19:33 +02:00
|
|
|
height: 260
|
2020-11-11 04:21:25 +01:00
|
|
|
}
|
|
|
|
|
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),
|
2022-10-14 00:45:53 +02:00
|
|
|
ajustement: 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
|
|
|
}
|