## v11.0.26 - le crépuscule de Khrachtchoum #673
@@ -2149,7 +2149,6 @@ export class RdDActor extends RdDBaseActor {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    const draconicList = this.computeDraconicAndSortIndex(sorts);
 | 
			
		||||
    const reve = duplicate(this.system.carac.reve);
 | 
			
		||||
 | 
			
		||||
@@ -2169,7 +2168,10 @@ export class RdDActor extends RdDBaseActor {
 | 
			
		||||
        diffLibre: RdDItemSort.getDifficulte(sorts[0], -7), // Per default at startup
 | 
			
		||||
        coutreve: Array(30).fill().map((item, index) => 1 + index),
 | 
			
		||||
      },
 | 
			
		||||
      callbackAction: r => this._rollUnSortResult(r)
 | 
			
		||||
      callbackAction: async r => {
 | 
			
		||||
        await this._rollUnSortResult(r);
 | 
			
		||||
        if (!r.isSortReserve) this.tmrApp?.close();
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
    this.tmrApp?.setTMRPendingAction(dialog);
 | 
			
		||||
  }
 | 
			
		||||
@@ -2262,17 +2264,11 @@ export class RdDActor extends RdDBaseActor {
 | 
			
		||||
    reveActuel = Math.max(reveActuel - rollData.depenseReve, 0);
 | 
			
		||||
    await this.update({ "system.reve.reve.value": reveActuel });
 | 
			
		||||
 | 
			
		||||
    if (rollData.isSortReserve) {
 | 
			
		||||
      this.tmrApp.maximize(); // Re-display TMR
 | 
			
		||||
    } else {
 | 
			
		||||
      this.tmrApp.close(); // Close TMR !
 | 
			
		||||
    }
 | 
			
		||||
    // Final chat message
 | 
			
		||||
    await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html');
 | 
			
		||||
 | 
			
		||||
    if (reveActuel == 0) { // 0 points de reve
 | 
			
		||||
      ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
 | 
			
		||||
      closeTMR = true;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,8 @@ export class RdDTMRDialog extends Dialog {
 | 
			
		||||
      content: html,
 | 
			
		||||
      buttons: {
 | 
			
		||||
        closeButton: {
 | 
			
		||||
          label: "Fermer", callback: html => this.close() }
 | 
			
		||||
          label: "Fermer", callback: html => this.close()
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      default: "closeButton"
 | 
			
		||||
    }
 | 
			
		||||
@@ -93,6 +94,9 @@ export class RdDTMRDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
  setTMRPendingAction(dialog) {
 | 
			
		||||
    this.subdialog = dialog
 | 
			
		||||
    if (dialog instanceof Application) {
 | 
			
		||||
      dialog.bringToTop();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  isDemiReveCache() {
 | 
			
		||||
@@ -579,9 +583,12 @@ export class RdDTMRDialog extends Dialog {
 | 
			
		||||
  _presentCite(tmr) {
 | 
			
		||||
    const presentCite = this.casesSpeciales.find(c => EffetsDraconiques.presentCites.isCase(c, tmr.coord));
 | 
			
		||||
    if (presentCite) {
 | 
			
		||||
      this.minimize();
 | 
			
		||||
      const caseData = presentCite;
 | 
			
		||||
      EffetsDraconiques.presentCites.choisirUnPresent(caseData, (present => this._utiliserPresentCite(presentCite, present, tmr)));
 | 
			
		||||
      const dialog = EffetsDraconiques.presentCites.choisirUnPresent(caseData, present => {
 | 
			
		||||
        this._utiliserPresentCite(presentCite, present, tmr)
 | 
			
		||||
        this.restoreTMRAfterAction();
 | 
			
		||||
      });
 | 
			
		||||
      this.setTMRPendingAction(dialog);
 | 
			
		||||
    }
 | 
			
		||||
    return presentCite;
 | 
			
		||||
  }
 | 
			
		||||
@@ -607,8 +614,6 @@ export class RdDTMRDialog extends Dialog {
 | 
			
		||||
      presentCite: presentCite
 | 
			
		||||
    };
 | 
			
		||||
    await this._tentativeMaitrise(rencontreData);
 | 
			
		||||
 | 
			
		||||
    this.maximize();
 | 
			
		||||
    this.postRencontre(tmr);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -815,22 +820,22 @@ export class RdDTMRDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
  /* -------------------------------------------- */
 | 
			
		||||
  async _maitriserTMR(rollData, callbackMaitrise) {
 | 
			
		||||
    this.minimize(); // Hide
 | 
			
		||||
    rollData.isTMRCache = rollData.actor.isTMRCache();
 | 
			
		||||
    const dialog = await RdDRoll.create(this.actor, rollData,
 | 
			
		||||
      {
 | 
			
		||||
        html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-maitrise-tmr.html',
 | 
			
		||||
        close: html => { this.restoreTMRAfterAction(); }
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        name: rollData.maitrise.verbe, label: rollData.maitrise.action,
 | 
			
		||||
        callbacks: [
 | 
			
		||||
          this.actor.createCallbackExperience(),
 | 
			
		||||
          { action: r => { this.restoreTMRAfterAction() } },
 | 
			
		||||
          { action: callbackMaitrise }
 | 
			
		||||
        ]
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
    dialog.render(true);
 | 
			
		||||
    this.setTMRPendingAction(dialog);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* -------------------------------------------- */
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ export class RdDTMRRencontreDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
  async onButtonAction(action) {
 | 
			
		||||
    this.toClose = true;
 | 
			
		||||
    await this.actor.tmrApp?.restoreTMRAfterAction();
 | 
			
		||||
    this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre)
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
@@ -41,7 +42,6 @@ export class RdDTMRRencontreDialog extends Dialog {
 | 
			
		||||
  async close() {
 | 
			
		||||
    if (this.actor.tmrApp){
 | 
			
		||||
      if (this.toClose) {
 | 
			
		||||
        this.actor.tmrApp?.restoreTMRAfterAction();
 | 
			
		||||
        return await super.close();
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
 
 | 
			
		||||
@@ -49,12 +49,13 @@ export class PresentCites extends Draconique {
 | 
			
		||||
    const presents = await game.system.rdd.rencontresTMR.getPresentsCite()
 | 
			
		||||
    const buttons = {};
 | 
			
		||||
    presents.forEach(r =>  buttons['present'+r.id] = { icon: '<i class="fas fa-check"></i>', label: r.name, callback: async () => onChoixPresent(r) });
 | 
			
		||||
    let d = new Dialog({
 | 
			
		||||
    let dialog = new Dialog({
 | 
			
		||||
      title: "Présent des cités",
 | 
			
		||||
      content: `La ${this.tmrLabel(casetmr)} vous offre un présent, faites votre choix`,
 | 
			
		||||
      buttons: buttons
 | 
			
		||||
    });
 | 
			
		||||
    d.render(true);
 | 
			
		||||
    dialog.render(true);
 | 
			
		||||
    return dialog
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async ouvrirLePresent(actor, casetmr) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user