63770790b9
Arrêter d'utiliser le jQuery $(selector) qui cause des effets de bord si plusieurs élements de la page (ie: foundry) correspondent au selector. Stocker le html dans les Sheet/Dialogs lors de l'appel activateListeners afin de pouvoir s'y référer ensuite. Utiliser this.html.find pour chercher dans le html de la fenêtre courante. Eliminer les référence par id html car l'id est unique (donc ne marche pas en multi-fenêtres)
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
import { ENTITE_BLURETTE, ENTITE_INCARNE } from "./constants.js";
|
|
import { RdDUtility } from "./rdd-utility.js";
|
|
|
|
/**
|
|
* Extend the base Dialog entity by defining a custom window to perform roll.
|
|
* @extends {Dialog}
|
|
*/
|
|
export class RdDEncaisser extends Dialog {
|
|
|
|
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);
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
constructor(html, actor) {
|
|
let dialogConf = {
|
|
title: "Jet d'Encaissement",
|
|
content: html,
|
|
}
|
|
|
|
if (!actor.isEntite()) {
|
|
dialogConf.default = "mortel";
|
|
dialogConf.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])) {
|
|
dialogConf.default = "cauchemar"
|
|
dialogConf.buttons = {
|
|
"cauchemar": { label: "Cauchemar", callback: html => this.performEncaisser("cauchemar") }
|
|
}
|
|
}
|
|
|
|
let dialogOptions = {
|
|
classes: ["rdd-roll-dialog"],
|
|
width: 320,
|
|
height: 'fit-content'
|
|
}
|
|
|
|
// Select proper roll dialog template and stuff
|
|
super(dialogConf, dialogOptions);
|
|
|
|
this.actor = actor;
|
|
this.modifier = 0;
|
|
this.encaisserSpecial = "aucun";
|
|
}
|
|
|
|
activateListeners(html) {
|
|
super.activateListeners(html);
|
|
this.html = html;
|
|
|
|
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
|
|
});
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
performEncaisser(mortalite) {
|
|
this.actor.encaisserDommages({
|
|
dmg: {
|
|
total: Number(this.modifier),
|
|
ajustement: Number(this.modifier),
|
|
encaisserSpecial: this.encaisserSpecial,
|
|
loc: { result: 0, label: "" },
|
|
mortalite: mortalite
|
|
}
|
|
});
|
|
}
|
|
}
|