From d610a92003bc1198e8186716f4a965db36b1c6f0 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 26 May 2021 19:04:36 +0200 Subject: [PATCH 01/12] =?UTF-8?q?Fix:=20la=20cl=C3=A9=20pour=20un=20type?= =?UTF-8?q?=20utilise=20des=20minuscules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/fr.json b/lang/fr.json index 58483e89..6d5cbe9b 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -14,7 +14,7 @@ "TypeNombreastral": "Nombre astral", "TypeTarot": "Carte de tarot", "TypeCasetmr": "TMR spéciale", - "TypeRencontresTMR": "Rencontre TMR", + "TypeRencontrestmr": "Rencontre TMR", "TypeMunition": "Munition", "TypeMonnaie": "Monnaie", "TypeHerbe": "Herbe ou plante", From c77d5e3c93b96a40017d45f6ba414f402e46aae7 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 00:19:31 +0200 Subject: [PATCH 02/12] Fix: boucle infinie de messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit en cas d'appel de ChatUtility.onRemoveMessages par un joueur, on entre en boucle infinie de messages envoyés sur les sockets --- module/chat-utility.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/module/chat-utility.js b/module/chat-utility.js index 59269d81..1a51e194 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -23,19 +23,19 @@ export class ChatUtility { game.messages.get(data.messageId)?.delete(); } } - else { - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: data }); - } } + static removeMessages(data) { + game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: data }); + } /* -------------------------------------------- */ static removeChatMessageContaining(part) { - ChatUtility.onRemoveMessages({ part: part }); + ChatUtility.removeMessages({ part: part }); } static removeChatMessageId(messageId) { - ChatUtility.onRemoveMessages({ messageId: messageId }); + ChatUtility.removeMessages({ messageId: messageId }); } /* -------------------------------------------- */ From 1d10c0bd3f4c5240049db86265f73405a74b3540 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 00:20:40 +0200 Subject: [PATCH 03/12] mineur: plus besoin de joueur pour la defense --- module/rdd-combat.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 6072a668..0fb909b4 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -491,20 +491,14 @@ export class RdDCombat { /* -------------------------------------------- */ static onMsgDefense(msg) { let defenderToken = canvas.tokens.get(msg.defenderTokenId); - if (defenderToken) { - if (!game.user.isGM && !game.user.character) { // vérification / sanity check - ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer."); - return; - } - if (Misc.isElectedUser()) { - const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); - if (rddCombat) { - const defenderRoll = msg.defenderRoll; - RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll); - RdDCombat._storeDefense(defenderRoll); - rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme); - rddCombat._chatMessageDefense(msg.paramChatDefense); - } + if (defenderToken && Misc.isElectedUser()) { + const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); + if (rddCombat) { + const defenderRoll = msg.defenderRoll; + RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll); + RdDCombat._storeDefense(defenderRoll); + rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme); + rddCombat._chatMessageDefense(msg.paramChatDefense); } } } From 06cf01b26931ea1a8a3dfd06ce581d9fc7a07c80 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 00:21:43 +0200 Subject: [PATCH 04/12] =?UTF-8?q?ic=C3=B4ne=20main=20pour=20=C3=A9quiper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/actor-sheet-inventaire-conteneur.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/actor-sheet-inventaire-conteneur.html b/templates/actor-sheet-inventaire-conteneur.html index 235ceebf..0c3c0570 100644 --- a/templates/actor-sheet-inventaire-conteneur.html +++ b/templates/actor-sheet-inventaire-conteneur.html @@ -14,7 +14,7 @@ {{numberFormat item.data.encTotal decimals=2}}
{{#unless item.estContenu}} - {{#if item.data.equipe}}{{else}}{{/if}} + {{#if item.data.equipe}}{{else}}{{/if}} {{/unless}} From 8eaa12e2c63e1f8ed5132e0bd50f20326643f196 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 00:22:05 +0200 Subject: [PATCH 05/12] Boutons de configuration du calendrier en blanc --- templates/calendar-template.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/calendar-template.html b/templates/calendar-template.html index b4ed6be7..cde29a9b 100644 --- a/templates/calendar-template.html +++ b/templates/calendar-template.html @@ -1,8 +1,8 @@
{{#if isGM}} - - + + {{/if}}

Jour {{jourMois}} de {{nomMois}} ({{nomSaison}})

From 22f12b8f0681111232f269c4c78533eff884866f Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 00:29:33 +0200 Subject: [PATCH 06/12] fix inventaire MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pas de notion d'équiper pour les conteneurs, affichés en dernier --- templates/actor-sheet-inventaire-conteneur.html | 2 ++ templates/actor-sheet.html | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/actor-sheet-inventaire-conteneur.html b/templates/actor-sheet-inventaire-conteneur.html index 0c3c0570..bc58f94c 100644 --- a/templates/actor-sheet-inventaire-conteneur.html +++ b/templates/actor-sheet-inventaire-conteneur.html @@ -14,7 +14,9 @@ {{numberFormat item.data.encTotal decimals=2}}
{{#unless item.estContenu}} + {{#if (ne item.type 'conteneur')}} {{#if item.data.equipe}}{{else}}{{/if}} + {{/if}} {{/unless}} diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 6db86c66..6c035741 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -610,13 +610,14 @@ {{#each objets as |item id|}} {{#unless item.estContenu}} - {{#if (eq item.type 'conteneur')}} - {{buildConteneur this}} - {{else}} + {{#if (ne item.type 'conteneur')}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html" item=item }} {{/if}} {{/unless}} {{/each}} + {{#each conteneurs as |conteneur id|}} + {{buildConteneur this}} + {{/each}}

Montures

From 5aa0f62b83afb9f4198c545b0fd2900547ac3dc9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 01:08:17 +0200 Subject: [PATCH 07/12] Correction des ajustements astrologiques MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ne pas avoir d'async pour déterminer l'ajustement astrologique. Si on n'a pas de chiffre astral du jour (ie: n'arrivera pas, on calcule à l'init), on utilise 0 et on lance le calcul async pour la prochaine fois.. --- module/rdd-calendrier.js | 58 +++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index d695bd98..b790cf39 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -37,17 +37,23 @@ const MAX_NOMBRE_ASTRAL = 12; /* -------------------------------------------- */ export class RdDCalendrier extends Application { + getCalendrier(index) { + let calendrier = { + heureRdD: 0, // Index dans heuresList + minutesRelative: 0, + moisRdD: Math.floor(index / 28) % 12, + jour: (index - (month * 28)) + 1 + } + return calendrier; + } + /* -------------------------------------------- */ async initCalendrier() { // Calendrier this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier")); //console.log("CALENDRIER", this.calendrier); if (this.calendrier == undefined || this.calendrier.moisRdD == undefined) { - this.calendrier = {}; - this.calendrier.heureRdD = 0; // Index dans heuresList - this.calendrier.minutesRelative = 0; - this.calendrier.moisRdD = 0; // Index dans heuresList - this.calendrier.jour = 0; + this.calendrier = this.getCalendrier(0); if (game.user.isGM) { // Uniquement si GM game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier); } @@ -86,8 +92,8 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - getDateFromIndex(index = undefined) { - if (!index) index = this.getCurrentDayIndex(); + getDateFromIndex(index) { + index = index ?? this.getCurrentDayIndex(); let month = Math.floor(index / 28); let day = (index - (month * 28)) + 1; return day + " " + heuresList[month]; @@ -131,6 +137,11 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ async ajouterNombreAstral(index) { const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: true, rollMode: "selfroll" }); + const dateFuture = this.getDateFromIndex(index); + ChatMessage.create({ + whisper: ChatMessage.getWhisperRecipients("GM"), + content: `Le chiffre astrologique du ${dateFuture} sera le ${nombreAstral}` + }); return { nombreAstral: nombreAstral, valeursFausses: [], @@ -139,9 +150,9 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async getCurrentNombreAstral() { + getCurrentNombreAstral() { let indexDate = this.getCurrentDayIndex(); - return await this.getNombreAstral(indexDate); + return this.getNombreAstral(indexDate); } /* -------------------------------------------- */ @@ -151,14 +162,13 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async getNombreAstral(indexDate) { + getNombreAstral(indexDate) { const liste = this.listeNombreAstral ?? this._loadListNombreAstral(); let astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate); if (!astralData?.nombreAstral) { - await this.rebuildListeNombreAstral(); - astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate); + this.rebuildListeNombreAstral(); } - return astralData?.nombreAstral ?? "N/A"; + return astralData?.nombreAstral; } /* -------------------------------------------- */ @@ -217,7 +227,7 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async incrementerJour() { + incrementerJour() { this.calendrier.jour += 1; if (this.calendrier.jour >= RDD_JOUR_PAR_MOIS) { this.calendrier.jour -= RDD_JOUR_PAR_MOIS; @@ -226,13 +236,13 @@ export class RdDCalendrier extends Application { this.calendrier.moisRdD += 1; // Reconstruire les nombres astraux } - await this.rebuildListeNombreAstral(); + this.rebuildListeNombreAstral(); } /* -------------------------------------------- */ - async syncPlayerTime(calendrier) { + syncPlayerTime(calendrier) { this.calendrier = duplicate(calendrier); // Local copy update - await this.updateDisplay(); + this.updateDisplay(); } /* -------------------------------------------- */ @@ -287,7 +297,7 @@ export class RdDCalendrier extends Application { showDice: false }; await RdDResolutionTable.rollData(rollData); - let nbAstral = await this.getNombreAstral(request.date); + let nbAstral = this.getNombreAstral(request.date); request.rolled = rollData.rolled; request.isValid = true; if (!request.rolled.isSuccess) { @@ -311,11 +321,11 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async getAjustementAstrologique(heureNaissance, name = 'inconnu') { + getAjustementAstrologique(heureNaissance, name = 'inconnu') { let heure = Grammar.toLowerCaseNoAccent(heureNaissance); if (heure && heuresDef[heure]) { let hn = heuresDef[heure].heure; - let chiffreAstral = await this.getCurrentNombreAstral(); + let chiffreAstral = this.getCurrentNombreAstral() ?? 0; let heureCourante = this.calendrier.heureRdD; let ecartChance = (hn + chiffreAstral - heureCourante) % 12; switch (ecartChance) { @@ -362,12 +372,12 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async updateDisplay() { + updateDisplay() { let data = this.fillCalendrierData(); // Rebuild data - let dateHTML = `Jour ${data.jourMois} de ${data.nomMois} (${data.nomSaison})`; + let dateHTML = `Jour ${data.jourMois} de ${data.nomMois} (${data.nomSaison})` if (game.user.isGM) { - dateHTML = dateHTML + " - NA: " + await this.getCurrentNombreAstral(); + dateHTML = dateHTML + " - NA: " + (this.getCurrentNombreAstral() ?? "indéterminé"); } for (let handle of document.getElementsByClassName("calendar-date-rdd")) { handle.innerHTML = dateHTML; @@ -393,7 +403,7 @@ export class RdDCalendrier extends Application { await this.rebuildListeNombreAstral(); - await this.updateDisplay(); + this.updateDisplay(); } /* -------------------------------------------- */ From 8ffecc45ca4ced6589779ed2396f990bc118c19c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 01:10:05 +0200 Subject: [PATCH 08/12] typo - espace manquant --- templates/chat-vente-item.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/chat-vente-item.html b/templates/chat-vente-item.html index a291cedc..04ef2f24 100644 --- a/templates/chat-vente-item.html +++ b/templates/chat-vente-item.html @@ -1,5 +1,5 @@
-

{{#if alias}}{{alias}} propose:{{else}}Acheter {{/if}}{{item.name}}

+

{{#if alias}}{{alias}} propose: {{else}}Acheter {{/if}}{{item.name}}

{{#if item.img}} {{/if}} From effb50e778e934678dfd7777be587ec50a3e3c7e Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 01:13:42 +0200 Subject: [PATCH 09/12] =?UTF-8?q?Permettre=20des=20conditions=20sur=20une?= =?UTF-8?q?=20t=C3=A2che?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/actor.js b/module/actor.js index 51d719df..1cdbd3d7 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2400,8 +2400,9 @@ export class RdDActor extends Actor { let rollData = { competence: compData, tache: tacheData, - diffConditions: tacheData.data.difficulte, - use: { libre: false, conditions: false }, + diffLibre: tacheData.data.difficulte, + diffConditions: 0, + use: { libre: false, conditions: true }, carac: {} }; rollData.carac[tacheData.data.carac] = duplicate(actorData.data.carac[tacheData.data.carac]); // Single carac From bd7f3a9b3ded2146aa1ac7c95c14ab4cafd01eb5 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 01:18:21 +0200 Subject: [PATCH 10/12] clean log socket message log des messages sockets dans le hook (car plusieurs handlers) --- module/actor.js | 1 - module/rdd-main.js | 2 ++ module/rdd-utility.js | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/module/actor.js b/module/actor.js index 1cdbd3d7..be01a33a 100644 --- a/module/actor.js +++ b/module/actor.js @@ -57,7 +57,6 @@ export class RdDActor extends Actor { } static remoteActorCall(options) { - console.log("remoteActorCall ", options) options.userId = options.userId ?? Misc.connectedGMOrUser(); game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_remote_actor_call", data: options }); } diff --git a/module/rdd-main.js b/module/rdd-main.js index d96303cc..c8e2ed2d 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -143,6 +143,8 @@ Hooks.once("init", async function () { /* -------------------------------------------- */ game.socket.on("system.foundryvtt-reve-de-dragon", sockmsg => { + console.log(">>>>> MSG RECV", sockmsg); + RdDUtility.onSocketMesssage(sockmsg); RdDCombat.onSocketMessage(sockmsg); ChatUtility.onSocketMessage(sockmsg); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 460642e3..d981ecb9 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -602,9 +602,6 @@ export class RdDUtility { let actor = RdDUtility.getSelectedActor("Pour effectuer le paiement:"); if (actor) { actor.depenserDeniers(sumdenier, objData, quantite, fromActorId); - // TODO: diminuer la quantité ou supprimer le message - // message: => document.querySelector("#chat-log > li:nth-child(61) > div > div > span > a") - // => ../../../..[@data-message-id] let chatMessageId = RdDUtility.findChatMessageId(event.currentTarget); if (chatMessageId) { ChatUtility.removeChatMessageId(chatMessageId); From 6a85073dbb809fe880d73e796d31d52237aef0b4 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 01:47:18 +0200 Subject: [PATCH 11/12] fix: suppression message par MJ Ne pas passer par un socket pour le user qui va traiter le message --- module/chat-utility.js | 5 +++++ module/rdd-utility.js | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/module/chat-utility.js b/module/chat-utility.js index 1a51e194..06eb5fac 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -26,7 +26,12 @@ export class ChatUtility { } static removeMessages(data) { + if (Misc.isElectedUser()){ + ChatUtility.onRemoveMessages(data); + } + else { game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: data }); + } } /* -------------------------------------------- */ diff --git a/module/rdd-utility.js b/module/rdd-utility.js index d981ecb9..de4da058 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -547,7 +547,6 @@ export class RdDUtility { /* -------------------------------------------- */ static onSocketMesssage(sockmsg) { - console.log(">>>>> MSG RECV", sockmsg); switch (sockmsg.msg) { case "msg_gm_chat_message": return ChatUtility.handleGMChatMessage(sockmsg.data); From d874720973d8045893c056eaa3621e77ba833f2d Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 May 2021 01:47:34 +0200 Subject: [PATCH 12/12] Fix achat par un joueur --- module/actor.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/module/actor.js b/module/actor.js index be01a33a..0defc7d9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -56,13 +56,17 @@ export class RdDActor extends Actor { } } - static remoteActorCall(options) { - options.userId = options.userId ?? Misc.connectedGMOrUser(); - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_remote_actor_call", data: options }); + static remoteActorCall(data) { + if (Misc.isElectedUser()){ + RdDActor.onRemoteActorCall(data); + } + else{ + game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_remote_actor_call", data: data }); + } } static onRemoteActorCall(data) { - if (game.user.id == data.userId) { // Seul le joueur choisi effectue l'appel + if (Misc.isElectedUser()) { // Seul le joueur choisi effectue l'appel const actor = game.actors.get(data?.actorId); if (!actor) { console.info("RdDActor.onRemoteActorCall: Pas d'Actor disponible ", data); @@ -3425,8 +3429,7 @@ export class RdDActor extends Actor { } if (!Misc.isElectedUser()) { RdDActor.remoteActorCall({ - userId: Misc.connectedGMOrUser(), - actorId: this.vendeur?.id ?? this.acheteur?.id, + actorId: vendeurId ?? acheteurId, method: 'achatVente', args: [vendeurId, acheteurId, venteData, chatMessageIdVente] }); return;