foundryvtt-reve-de-dragon/module/rdd-tmr-rencontre-dialog.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-11-29 18:21:34 +01:00
/* -------------------------------------------- */
export class RdDTMRRencontreDialog extends Dialog {
2020-11-29 18:21:34 +01:00
/* -------------------------------------------- */
constructor(actor, rencontre, tmr) {
2020-11-29 18:21:34 +01:00
const dialogConf = {
title: "Rencontre en TMR!",
2022-11-07 00:04:43 +01:00
content: "Vous rencontrez un " + rencontre.name + " de force " + rencontre.system.force + "<br>",
2020-11-29 18:21:34 +01:00
buttons: {
2022-11-07 00:04:43 +01:00
derober: { icon: '<i class="fas fa-check"></i>', label: "Se dérober", callback: () => this.onButtonAction('derober') },
maitiser: { icon: '<i class="fas fa-check"></i>', label: "Maîtriser", callback: () => this.onButtonAction('maitriser') }
2020-11-29 18:21:34 +01:00
},
default: "derober"
2022-11-07 00:04:43 +01:00
}
if ((rencontre.system.refoulement ?? 0) == 0) {
dialogConf.buttons.ignorer = { icon: '<i class="fas fa-check"></i>', label: "Ignorer", callback: () => this.onButtonAction('ignorer') }
}
else {
dialogConf.buttons.refouler = { icon: '<i class="fas fa-check"></i>', label: "Refouler", callback: () => this.onButtonAction('refouler') }
}
2020-11-29 18:21:34 +01:00
const dialogOptions = {
classes: ["tmrrencdialog"],
width: 320, height: 'fit-content',
'z-index': 50
2020-11-29 18:21:34 +01:00
}
super(dialogConf, dialogOptions);
this.toClose = false;
2022-11-07 00:04:43 +01:00
this.tmr = tmr;
this.actor = actor;
this.rencontre = rencontre;
2020-11-29 18:21:34 +01:00
}
async onButtonAction(action) {
this.toClose = true;
2023-10-24 00:30:00 +02:00
await this.actor.tmrApp?.restoreTMRAfterAction();
this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre)
}
2020-11-29 18:21:34 +01:00
/* -------------------------------------------- */
async close() {
if (this.actor.tmrApp){
if (this.toClose) {
return await super.close();
}
else {
ui.notifications.info("Vous devez résoudre la rencontre.");
return this.actor.tmrApp.forceTMRContinueAction();
}
}
else {
return await super.close();
2020-11-29 18:21:34 +01:00
}
}
}