Vincent Vandemeulebrouck
441a5965c7
Au lieu de minimiser les TMRs, les actions dans les TMRs sont bloquées tant qu'une action liée au TMRs est en cours.
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
/* -------------------------------------------- */
|
|
export class RdDTMRRencontreDialog extends Dialog {
|
|
|
|
/* -------------------------------------------- */
|
|
constructor(actor, rencontre, tmr) {
|
|
const dialogConf = {
|
|
title: "Rencontre en TMR!",
|
|
content: "Vous rencontrez un " + rencontre.name + " de force " + rencontre.system.force + "<br>",
|
|
buttons: {
|
|
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') }
|
|
},
|
|
default: "derober"
|
|
}
|
|
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') }
|
|
}
|
|
|
|
const dialogOptions = {
|
|
classes: ["tmrrencdialog"],
|
|
width: 320, height: 'fit-content',
|
|
'z-index': 50
|
|
}
|
|
super(dialogConf, dialogOptions);
|
|
|
|
this.toClose = false;
|
|
this.tmr = tmr;
|
|
this.actor = actor;
|
|
this.rencontre = rencontre;
|
|
}
|
|
|
|
async onButtonAction(action) {
|
|
this.toClose = true;
|
|
this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre)
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
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();
|
|
}
|
|
}
|
|
|
|
}
|