foundryvtt-reve-de-dragon/module/rdd-tmr-rencontre-dialog.js
Vincent Vandemeulebrouck a2ec26c4c0 Extraction méthodes identification items
Pour savoir si certaines queues/souffles sont là et rendre
le code plus lisible
2021-02-06 01:36:46 +01:00

55 lines
1.8 KiB
JavaScript

/* -------------------------------------------- */
export class RdDTMRRencontreDialog extends Dialog {
/* -------------------------------------------- */
constructor(html, tmrApp, rencontre, postRencontre) {
const dialogConf = {
title: "Rencontre en TMR!",
content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "<br>",
buttons: {
derober: { icon: '<i class="fas fa-check"></i>', label: "Se dérober", callback: () => { this.onButtonFuir(() => tmrApp.derober()); } },
refouler: { icon: '<i class="fas fa-check"></i>', label: "Refouler", callback: () => this.onButtonAction(() => tmrApp.refouler()) },
maitiser: { icon: '<i class="fas fa-check"></i>', label: "Maîtriser", callback: () => this.onButtonAction(() => tmrApp.maitriser()) }
},
default: "derober"
};
if (rencontre.ignorer) {
dialogConf.buttons.ignorer = { icon: '<i class="fas fa-check"></i>', label: "Ignorer", callback: () => this.onButtonAction(() => tmrApp.ignorerRencontre()) }
};
const dialogOptions = {
classes: ["tmrrencdialog"],
width: 320, height: 240,
'z-index': 20
}
super(dialogConf, dialogOptions);
this.toClose = false;
this.rencontreData = duplicate(rencontre);
this.postRencontre = postRencontre;
this.tmrApp = tmrApp;
this.tmrApp.minimize();
}
async onButtonAction(action) {
this.toClose = true;
await action();
this.postRencontre();
}
async onButtonFuir(action) {
this.toClose = true;
await action();
}
/* -------------------------------------------- */
close() {
if (this.toClose) {
this.tmrApp.maximize();
return super.close();
}
ui.notifications.info("Vous devez résoudre la rencontre.");
}
}