Remplacement progressif rencontres

This commit is contained in:
Vincent Vandemeulebrouck
2022-11-07 00:04:43 +01:00
parent d20a6a1506
commit f659a7508a
21 changed files with 460 additions and 746 deletions

View File

@ -2,20 +2,22 @@
export class RdDTMRRencontreDialog extends Dialog {
/* -------------------------------------------- */
constructor(tmrApp, rencontre, postRencontre) {
constructor(tmrApp, rencontre, tmr) {
const dialogConf = {
title: "Rencontre en TMR!",
content: "Vous rencontrez un " + rencontre.name + " de force " + rencontre.force + "<br>",
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.onButtonFuir(() => tmrApp.derober()); } },
refouler: { icon: '<i class="fas fa-check"></i>', label: "Refouler", callback: () => this.onButtonAction(() => tmrApp.refouler()) },
maitiser: { icon: '<i class="fas fa-check"></i>', label: "Maîtriser", callback: () => this.onButtonAction(() => tmrApp.maitriserRencontre()) }
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.ignorer) {
dialogConf.buttons.ignorer = { icon: '<i class="fas fa-check"></i>', label: "Ignorer", callback: () => this.onButtonAction(() => tmrApp.ignorerRencontre()) }
};
}
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"],
@ -25,23 +27,16 @@ export class RdDTMRRencontreDialog extends Dialog {
super(dialogConf, dialogOptions);
this.toClose = false;
this.rencontreData = duplicate(rencontre);
this.postRencontre = postRencontre;
this.tmr = tmr;
this.tmrApp = tmrApp;
this.tmrApp.minimize();
}
async onButtonAction(action) {
this.toClose = true;
await action();
this.postRencontre();
this.tmrApp.onActionRencontre(action, this.tmr)
}
async onButtonFuir(action) {
this.toClose = true;
await action();
}
/* -------------------------------------------- */
close() {
if (this.toClose) {