2022-12-09 02:00:31 +01:00
|
|
|
import { ENTITE_BLURETTE, ENTITE_INCARNE } from "./constants.js";
|
|
|
|
import { RdDUtility } from "./rdd-utility.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
|
|
|
|
2022-12-09 02:00:31 +01:00
|
|
|
static async encaisser(actor) {
|
|
|
|
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
|
|
|
|
{ ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }
|
|
|
|
);
|
|
|
|
new RdDEncaisser(html, actor).render(true);
|
|
|
|
}
|
|
|
|
|
2020-11-11 04:21:25 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-11-10 13:53:51 +01:00
|
|
|
constructor(html, actor) {
|
2022-12-09 02:00:31 +01:00
|
|
|
let dialogConf = {
|
|
|
|
title: "Jet d'Encaissement",
|
|
|
|
content: html,
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!actor.isEntite()) {
|
|
|
|
dialogConf.default = "mortel";
|
|
|
|
dialogConf.buttons = {
|
2022-07-22 21:38:15 +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() },
|
|
|
|
};
|
|
|
|
}
|
2022-12-09 02:00:31 +01:00
|
|
|
else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])) {
|
|
|
|
dialogConf.default = "cauchemar"
|
|
|
|
dialogConf.buttons = {
|
|
|
|
"cauchemar": { label: "Cauchemar", callback: html => this.performEncaisser("cauchemar") }
|
2022-07-22 21:38:15 +02:00
|
|
|
}
|
|
|
|
}
|
2021-03-30 22:27:30 +02:00
|
|
|
|
2020-11-11 04:21:25 +01:00
|
|
|
let dialogOptions = {
|
2022-12-06 01:30:12 +01:00
|
|
|
classes: ["rdd-roll-dialog"],
|
2020-11-11 04:21:25 +01:00
|
|
|
width: 320,
|
2022-11-16 02:46:26 +01:00
|
|
|
height: 'fit-content'
|
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
|
|
|
}
|
|
|
|
|
2022-12-09 02:00:31 +01:00
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
this.html = html;
|
2021-03-30 22:27:30 +02:00
|
|
|
|
2022-12-09 02:00:31 +01:00
|
|
|
this.html.find('[name="modificateurDegats"]').val("0");
|
|
|
|
this.html.find('[name="modificateurDegats"]').change((event) => {
|
|
|
|
this.modifier = event.currentTarget.value; // Update the selected bonus/malus
|
|
|
|
});
|
|
|
|
this.html.find('[name="encaisserSpecial"]').change((event) => {
|
|
|
|
this.encaisserSpecial = event.currentTarget.value; // Update the selected bonus/malus
|
|
|
|
});
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
}
|
2020-11-07 21:06:37 +01:00
|
|
|
}
|