2020-11-29 18:21:34 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
export class RdDTMRRencontreDialog extends Dialog {
|
2021-02-05 01:38:40 +01:00
|
|
|
|
2020-11-29 18:21:34 +01:00
|
|
|
/* -------------------------------------------- */
|
2023-10-22 15:53:03 +02: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') }
|
|
|
|
}
|
2021-02-05 01:38:40 +01:00
|
|
|
|
2020-11-29 18:21:34 +01:00
|
|
|
const dialogOptions = {
|
|
|
|
classes: ["tmrrencdialog"],
|
2022-11-16 02:46:26 +01:00
|
|
|
width: 320, height: 'fit-content',
|
2021-05-04 12:22:19 +02:00
|
|
|
'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;
|
2023-10-22 15:53:03 +02:00
|
|
|
this.actor = actor;
|
2023-01-19 01:45:30 +01:00
|
|
|
this.rencontre = rencontre;
|
2020-11-29 18:21:34 +01:00
|
|
|
}
|
2021-02-05 01:38:40 +01:00
|
|
|
|
|
|
|
async onButtonAction(action) {
|
|
|
|
this.toClose = true;
|
2023-10-22 15:53:03 +02:00
|
|
|
this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre)
|
2021-02-05 01:38:40 +01:00
|
|
|
}
|
2020-11-29 18:21:34 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2023-10-22 15:53:03 +02:00
|
|
|
async close() {
|
|
|
|
if (this.actor.tmrApp){
|
|
|
|
if (this.toClose) {
|
|
|
|
this.actor.tmrApp?.restoreTMRAfterAction();
|
|
|
|
return await super.close();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui.notifications.info("Vous devez résoudre la rencontre.");
|
|
|
|
this.actor.tmrApp.forceTMRContinueAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return await super.close();
|
2020-11-29 18:21:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|