From 7445e9e51b1485eae248a0ff9c87edc65eebb931 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 23 Jan 2021 23:56:43 +0100 Subject: [PATCH] #49 - Suivi des deplacements en TMR par le MJ --- module/actor.js | 8 ++++++++ module/rdd-main.js | 2 +- module/rdd-tmr-dialog.js | 12 +++++++++++- module/rdd-utility.js | 5 +++++ module/tmr-utility.js | 2 +- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/module/actor.js b/module/actor.js index ca5560b7..cf6b7268 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2119,6 +2119,14 @@ export class RdDActor extends Actor { return 0; } + /* -------------------------------------------- */ + refreshTMRView( tmrData ) { + console.log("REFRESH !!!!"); + if ( this.currentTMR ) { + this.currentTMR.forceDemiRevePositionView(tmrData.tmrPos); + } + } + /* -------------------------------------------- */ async displayTMR(mode = "normal") { let isRapide = mode == "rapide"; diff --git a/module/rdd-main.js b/module/rdd-main.js index 85b6e2a4..5f0860b4 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -186,7 +186,7 @@ Hooks.once("init", async function () { game.socket.on("system.foundryvtt-reve-de-dragon", data => { RdDUtility.onSocketMesssage(data); RdDCombat.onSocketMessage(data); - ChatUtility.onSocketMessage(data); + ChatUtility.onSocketMessage(data); }); /* -------------------------------------------- */ diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index 226649ff..fc54fa2b 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -589,7 +589,12 @@ export class RdDTMRDialog extends Dialog { myself._updateDemiReve(myself); myself.nbFatigue += 1; myself.updateValuesDisplay(); - + game.socket.emit("system.foundryvtt-reve-de-dragon", { + msg: "msg_tmr_move", data: { + actorId: myself.actor.data._id, + tmrPos: tmrPos + } + }); if ( deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/... await myself.manageRencontre(coordTMR, cellDescr); @@ -615,6 +620,11 @@ export class RdDTMRDialog extends Dialog { myself.checkQuitterTMR(); // Vérifier l'état des compteurs reve/fatigue/vie } + /* -------------------------------------------- */ + async forceDemiRevePositionView( coordTMR ) { + this._updateDemiReve(this); + } + /* -------------------------------------------- */ async forceDemiRevePosition( coordTMR ) { await this.actor.updateCoordTMR(coordTMR); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 92651a28..da714c1f 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -647,6 +647,11 @@ export class RdDUtility { return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data); case "msg_response_nombre_astral": return RdDUtility.responseNombreAstral(sockmsg.data); + case "msg_tmr_move": + if ( game.user.isGM ) { + let actor = game.actors.get( sockmsg.data.actorId); + actor.refreshTMRView( sockmsg.data.tmrPos ); + } } } diff --git a/module/tmr-utility.js b/module/tmr-utility.js index 29f9a6fd..ebde45cb 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -492,7 +492,7 @@ export class TMRUtility { } else if (rencontre.name == "Rêve de Dragon") { // TODO: xp particulière message += "Vous maîtrisez le Rêve de Dragon !" - message += actor.appliquerReveDeDragon(rolled, rencontre.force); + message += await actor.appliquerReveDeDragon(rolled, rencontre.force); } return { message: message, state: state }; }