forked from public/foundryvtt-reve-de-dragon
Remplacement progressif rencontres
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user