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
|
|
|
/* -------------------------------------------- */
|
2021-02-05 01:38:40 +01:00
|
|
|
constructor(html, tmrApp, rencontre, postRencontre) {
|
2020-11-29 18:21:34 +01:00
|
|
|
const dialogConf = {
|
|
|
|
title: "Rencontre en TMR!",
|
2021-01-29 15:13:59 +01:00
|
|
|
content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "<br>",
|
2020-11-29 18:21:34 +01:00
|
|
|
buttons: {
|
2021-02-05 01:38:40 +01:00
|
|
|
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()) },
|
2021-02-11 02:48:27 +01:00
|
|
|
maitiser: { icon: '<i class="fas fa-check"></i>', label: "Maîtriser", callback: () => this.onButtonAction(() => tmrApp.maitriserRencontre()) }
|
2020-11-29 18:21:34 +01:00
|
|
|
},
|
|
|
|
default: "derober"
|
2021-02-05 01:38:40 +01:00
|
|
|
};
|
2021-01-29 15:13:59 +01:00
|
|
|
if (rencontre.ignorer) {
|
2021-02-05 01:38:40 +01:00
|
|
|
dialogConf.buttons.ignorer = { icon: '<i class="fas fa-check"></i>', label: "Ignorer", callback: () => this.onButtonAction(() => tmrApp.ignorerRencontre()) }
|
|
|
|
};
|
|
|
|
|
2020-11-29 18:21:34 +01:00
|
|
|
const dialogOptions = {
|
|
|
|
classes: ["tmrrencdialog"],
|
|
|
|
width: 320, height: 240,
|
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;
|
2021-01-29 15:13:59 +01:00
|
|
|
this.rencontreData = duplicate(rencontre);
|
2021-02-05 01:38:40 +01:00
|
|
|
this.postRencontre = postRencontre;
|
2020-11-29 18:21:34 +01:00
|
|
|
this.tmrApp = tmrApp;
|
|
|
|
this.tmrApp.minimize();
|
|
|
|
}
|
2021-02-05 01:38:40 +01:00
|
|
|
|
|
|
|
async onButtonAction(action) {
|
|
|
|
this.toClose = true;
|
|
|
|
await action();
|
|
|
|
this.postRencontre();
|
|
|
|
}
|
2020-11-29 18:21:34 +01:00
|
|
|
|
2021-02-05 23:51:12 +01:00
|
|
|
async onButtonFuir(action) {
|
2021-02-05 01:38:40 +01:00
|
|
|
this.toClose = true;
|
|
|
|
await action();
|
|
|
|
}
|
|
|
|
|
2020-11-29 18:21:34 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
close() {
|
2021-02-05 01:38:40 +01:00
|
|
|
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.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|