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", diff --git a/module/actor.js b/module/actor.js index 51d719df..0defc7d9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -56,14 +56,17 @@ 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 }); + 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); @@ -2400,8 +2403,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 @@ -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; diff --git a/module/chat-utility.js b/module/chat-utility.js index 59269d81..06eb5fac 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -23,19 +23,24 @@ export class ChatUtility { game.messages.get(data.messageId)?.delete(); } } + } + + 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 }); } } - /* -------------------------------------------- */ static removeChatMessageContaining(part) { - ChatUtility.onRemoveMessages({ part: part }); + ChatUtility.removeMessages({ part: part }); } static removeChatMessageId(messageId) { - ChatUtility.onRemoveMessages({ messageId: messageId }); + ChatUtility.removeMessages({ messageId: messageId }); } /* -------------------------------------------- */ 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(); } /* -------------------------------------------- */ 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); } } } 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..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); @@ -602,9 +601,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); diff --git a/templates/actor-sheet-inventaire-conteneur.html b/templates/actor-sheet-inventaire-conteneur.html index 235ceebf..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}}
Jour {{jourMois}} de {{nomMois}} ({{nomSaison}})
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 @@