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

50 lines
1.6 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
/* -------------------------------------------- */
2022-11-07 00:04:43 +01:00
constructor(tmrApp, 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;
2020-11-29 18:21:34 +01:00
this.tmrApp = tmrApp;
this.tmrApp.minimize();
}
async onButtonAction(action) {
this.toClose = true;
2022-11-07 00:04:43 +01:00
this.tmrApp.onActionRencontre(action, this.tmr)
}
2020-11-29 18:21:34 +01:00
/* -------------------------------------------- */
close() {
if (this.toClose) {
2020-11-29 18:21:34 +01:00
this.tmrApp.maximize();
return super.close();
}
ui.notifications.info("Vous devez résoudre la rencontre.");
}
}