From 3ae3003be3bec75aa806215f1838238aeabdae85 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 29 Jan 2022 18:50:37 +0100 Subject: [PATCH] Ajout async sur displayRollData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Préparation pour récupérer le message affiché et lui ajouter des flags --- module/actor.js | 26 +++++++++++++------------- module/chat-utility.js | 10 +++++----- module/rdd-possession.js | 14 +++++++------- module/rdd-resolution-table.js | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/module/actor.js b/module/actor.js index 2c0a7ec7..d7f361df 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2458,7 +2458,7 @@ export class RdDActor extends Actor { this.currentTMR.close(); // Close TMR ! } // Final chat message - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html'); + 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 !" }); @@ -2488,7 +2488,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _onRollCaracResult(rollData) { // Final chat message - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html'); + await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html'); } async rollCaracCompetence(caracName, compName, diff, options = { title: "", apprecier: false }) { @@ -2516,7 +2516,7 @@ export class RdDActor extends Actor { RollDataAjustements.calcul(rollData, this); await RdDResolutionTable.rollData(rollData); this._appliquerExperienceRollData(rollData); - RdDResolutionTable.displayRollData(rollData, this) + await RdDResolutionTable.displayRollData(rollData, this) return rollData.rolled; } @@ -2562,7 +2562,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _competenceResult(rollData) { - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html') + await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html') } /* -------------------------------------------- */ @@ -2641,7 +2641,7 @@ export class RdDActor extends Actor { this.updateEmbeddedDocuments('Item', [rollData.tache]); this.santeIncDec("fatigue", rollData.tache.data.fatigue); - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html'); + await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html'); } /* -------------------------------------------- */ @@ -2688,7 +2688,7 @@ export class RdDActor extends Actor { const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.data.niveau : artData.competence.data.niveau); artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.data.niveau) + artData.rolled.ptQualite; - RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); + await RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); } /* -------------------------------------------- */ @@ -2766,7 +2766,7 @@ export class RdDActor extends Actor { ui.notifications.info(`${platCuisine.data.quantite} rations de ${platCuisine.name} ont été ajoutés à votre équipement`); } artData.platCuisine = platCuisine; - RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); + await RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); } /* -------------------------------------------- */ @@ -2834,7 +2834,7 @@ export class RdDActor extends Actor { await this.createEmbeddedDocuments("Item", [signeData]); } - RdDResolutionTable.displayRollData(meditationData, this.name, 'chat-resultat-meditation.html'); + await RdDResolutionTable.displayRollData(meditationData, this.name, 'chat-resultat-meditation.html'); } /* -------------------------------------------- */ @@ -2914,7 +2914,7 @@ export class RdDActor extends Actor { await this.updateExperienceLog("XP Sort", rollData.xpSort, "Signe draconique en " + rollData.competence.name); } await this.deleteEmbeddedDocuments("Item", [rollData.signe._id]); - RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html'); + await RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-lecture-signedraconique.html'); this.currentTMR.close(); } @@ -3339,7 +3339,7 @@ export class RdDActor extends Actor { show: defenderRoll?.show ?? {} }); - ChatUtility.createChatWithRollMode(this.name, { + await ChatUtility.createChatWithRollMode(this.name, { roll: encaissement.roll, content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-resultat-encaissement.html', encaissement) }); @@ -3821,7 +3821,7 @@ export class RdDActor extends Actor { callbacks: [ this.createCallbackExperience(), this.createCallbackAppelAuMoral(), - { action: r => this._alchimieResult(r, false) } + { action: async r => await this._alchimieResult(r, false) } ] } ); @@ -3834,8 +3834,8 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - _alchimieResult(rollData) { - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html'); + async _alchimieResult(rollData) { + await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html'); } /* -------------------------------------------- */ diff --git a/module/chat-utility.js b/module/chat-utility.js index 65e0c557..6dd97b77 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -66,7 +66,7 @@ export class ChatUtility { /* -------------------------------------------- */ static removeMessages(data) { - if (Misc.isUniqueConnectedGM()){ + if (Misc.isUniqueConnectedGM()) { ChatUtility.onRemoveMessages(data); } else { @@ -86,12 +86,12 @@ export class ChatUtility { } /* -------------------------------------------- */ - static createChatWithRollMode(name, chatOptions) { - ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions); + static async createChatWithRollMode(name, chatOptions) { + return await ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions); } /* -------------------------------------------- */ - static createChatMessage(name, rollMode, chatOptions) { + static async createChatMessage(name, rollMode, chatOptions) { switch (rollMode) { case "blindroll": // GM only if (!game.user.isGM) { @@ -109,7 +109,7 @@ export class ChatUtility { break; } chatOptions.alias = chatOptions.alias || name; - ChatMessage.create(chatOptions); + return await ChatMessage.create(chatOptions); } /* -------------------------------------------- */ diff --git a/module/rdd-possession.js b/module/rdd-possession.js index 4d3b7b2c..4b9e0f36 100644 --- a/module/rdd-possession.js +++ b/module/rdd-possession.js @@ -50,13 +50,13 @@ export class RdDPossession { } /* -------------------------------------------- */ - static resultConjuration( rollData) { + static async resultConjuration( rollData) { console.log("RollData!!!", rollData); if ( !rollData.rolled.isSuccess ) { rollData.possession.data.compteur++; } this.updateEtatPossession(rollData.possession); - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html'); + await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html'); } /* -------------------------------------------- */ @@ -86,7 +86,7 @@ export class RdDPossession { name: 'conjurer', label: 'Conjurer une Possession', callbacks: [ - { action: async r => this.resultConjuration(r) } + { action: async r => await this.resultConjuration(r) } ] } ); @@ -94,11 +94,11 @@ export class RdDPossession { } /* -------------------------------------------- */ - static _onRollPossession( rollData, isSuccess ) { + static async _onRollPossession( rollData, isSuccess ) { let possession = rollData.possession; possession.isSuccess = isSuccess; this.updateEtatPossession( possession); - RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html'); + await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html'); } /* -------------------------------------------- */ @@ -141,8 +141,8 @@ export class RdDPossession { name: 'jet-possession', label: 'Possession: ', callbacks: [ - { condition: r => (r.rolled.isSuccess), action: r => this._onRollPossession(r, true) }, - { condition: r => (r.rolled.isEchec), action: r => this._onRollPossession(r, false) }, + { condition: r => (r.rolled.isSuccess), action: async r => await this._onRollPossession(r, true) }, + { condition: r => (r.rolled.isEchec), action: async r => await this._onRollPossession(r, false) }, ] }); dialog.render(true); diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index 52d0bd6a..6db89650 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -64,7 +64,7 @@ export class RdDResolutionTable { /* -------------------------------------------- */ static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') { - ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, { + return await ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, { content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template) }); }