diff --git a/module/actor.js b/module/actor.js index d7f361df..717152c0 100644 --- a/module/actor.js +++ b/module/actor.js @@ -33,7 +33,7 @@ import { RollDataAjustements } from "./rolldata-ajustements.js"; import { DialogItemAchat } from "./dialog-item-achat.js"; import { RdDItem } from "./item.js"; import { RdDPossession } from "./rdd-possession.js"; -import { SYSTEM_RDD } from "./constants.js"; +import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; /* -------------------------------------------- */ /** @@ -68,7 +68,7 @@ export class RdDActor extends Actor { return false; } else { - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_remote_actor_call", data: data }); + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_remote_actor_call", data: data }); return true; } } @@ -494,11 +494,11 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _recupereChance() { // On ne récupère un point de chance que si aucun appel à la chance dans la journée - if (this.getChanceActuel() < this.getChance() && !this.getFlag('foundryvtt-reve-de-dragon', 'utilisationChance')) { + if (this.getChanceActuel() < this.getChance() && !this.getFlag(SYSTEM_RDD, 'utilisationChance')) { await this.chanceActuelleIncDec(1); } // Nouveau jour, suppression du flag - await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance'); + await this.unsetFlag(SYSTEM_RDD, 'utilisationChance'); } async _jetDeMoralChateauDormant(message) { @@ -1469,7 +1469,7 @@ export class RdDActor extends Actor { async cacheTMRetMessage() { await this.reinsertionAleatoire("Action MJ"); await this.cacheTMR(); - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_tmr_move", data: { actorId: this.data._id, tmrPos: this.data.data.reve.tmrpos @@ -1480,7 +1480,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async afficheTMRetMessage() { await this.montreTMR(); - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_tmr_move", data: { actorId: this.data._id, tmrPos: this.data.data.reve.tmrpos @@ -2940,7 +2940,7 @@ export class RdDActor extends Actor { async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) { await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html') if (rollData.rolled.isSuccess) { - await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true); + await this.setFlag(SYSTEM_RDD, 'utilisationChance', true); await this.chanceActuelleIncDec(-1); onSuccess(); } @@ -3493,21 +3493,21 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async resetItemUse() { - await this.unsetFlag('foundryvtt-reve-de-dragon', 'itemUse'); - await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', {}); + await this.unsetFlag(SYSTEM_RDD, 'itemUse'); + await this.setFlag(SYSTEM_RDD, 'itemUse', {}); } /* -------------------------------------------- */ async incDecItemUse(itemId, inc = 1) { - let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {}); + let itemUse = duplicate(this.getFlag(SYSTEM_RDD, 'itemUse') ?? {}); itemUse[itemId] = (itemUse[itemId] ?? 0) + inc; - await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', itemUse); + await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse); console.log("ITEM USE INC", inc, itemUse); } /* -------------------------------------------- */ getItemUse(itemId) { - let itemUse = this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {}; + let itemUse = this.getFlag(SYSTEM_RDD, 'itemUse') ?? {}; console.log("ITEM USE GET", itemUse); return itemUse[itemId] ?? 0; } diff --git a/module/chat-utility.js b/module/chat-utility.js index 6dd97b77..ba8fdf4c 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -1,4 +1,5 @@ import { Misc } from "./misc.js"; +import { SYSTEM_SOCKET_ID } from "./constants.js"; /** * Class providing helper methods to get the list of users, and @@ -23,7 +24,7 @@ export class ChatUtility { ChatUtility.onNotifyUser(data); } else { - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_user_ui_notifications", data: data }); } @@ -70,7 +71,7 @@ export class ChatUtility { ChatUtility.onRemoveMessages(data); } else { - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: data }); + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_delete_chat_message", data: data }); } } @@ -147,7 +148,7 @@ export class ChatUtility { chatGM.whisper = ChatUtility.getUsers(user => user.isGM); chatGM.content = "Message aveugle de " + game.user.name + "
" + chatOptions.content; console.log("blindMessageToGM", chatGM); - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_gm_chat_message", data: chatGM }); + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_gm_chat_message", data: chatGM }); } /* -------------------------------------------- */ diff --git a/module/constants.js b/module/constants.js index be1d1c86..865a0559 100644 --- a/module/constants.js +++ b/module/constants.js @@ -1,4 +1,5 @@ -export const SYSTEM_RDD = "foundryvtt-reve-de-dragon"; +export const SYSTEM_RDD = 'foundryvtt-reve-de-dragon'; +export const SYSTEM_SOCKET_ID = 'system.foundryvtt-reve-de-dragon'; export const HIDE_DICE = 'hide'; export const SHOW_DICE = 'show'; diff --git a/module/rdd-astrologie-joueur.js b/module/rdd-astrologie-joueur.js index bf0c3692..7497a97a 100644 --- a/module/rdd-astrologie-joueur.js +++ b/module/rdd-astrologie-joueur.js @@ -1,5 +1,6 @@ import { RdDItemCompetence } from "./item-competence.js"; import { Misc } from "./misc.js"; +import { SYSTEM_SOCKET_ID } from "./constants.js"; /** @@ -74,7 +75,7 @@ export class RdDAstrologieJoueur extends Dialog { if (Misc.isUniqueConnectedGM()) { game.system.rdd.calendrier.requestNombreAstral(data); } else { - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_request_nombre_astral", data: data }); diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 7cc351c5..73a97003 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -7,7 +7,7 @@ import { RdDUtility } from "./rdd-utility.js"; import { Grammar } from "./grammar.js"; import { RdDDice } from "./rdd-dice.js"; import { Misc } from "./misc.js"; -import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD } from "./constants.js"; +import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; /* -------------------------------------------- */ const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/' @@ -172,7 +172,7 @@ export class RdDCalendrier extends Application { this.listeNombreAstral = []; game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral); - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_reset_nombre_astral", data: {} }); @@ -254,8 +254,8 @@ export class RdDCalendrier extends Application { this.checkMaladie("jour"); } game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier)); - // Notification aux joueurs - game.socket.emit("system.foundryvtt-reve-de-dragon", { + // Notification aux joueurs // TODO: replace with Hook on game settings update + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_sync_time", data: duplicate(this.calendrier) }); @@ -343,7 +343,7 @@ export class RdDCalendrier extends Application { if (Misc.getActiveUser(request.userId)?.isGM) { RdDUtility.responseNombreAstral(request); } else { - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_response_nombre_astral", data: request }); @@ -474,7 +474,7 @@ export class RdDCalendrier extends Application { await this.rebuildListeNombreAstral(); - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_sync_time", data: duplicate(this.calendrier) }); diff --git a/module/rdd-combat.js b/module/rdd-combat.js index b350c398..d7a38e3f 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -1,5 +1,5 @@ import { ChatUtility } from "./chat-utility.js"; -import { HIDE_DICE, SYSTEM_RDD } from "./constants.js"; +import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { RdDItemArme } from "./item-arme.js"; import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetenceCreature } from "./item-competencecreature.js"; @@ -473,7 +473,8 @@ export class RdDCombat { /* -------------------------------------------- */ static messagePasseArme(data) { - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_combat_passearme", data: data }); + // TODO: store required info for combat in the chat message presenting choices? + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_combat_passearme", data: data }); RdDCombat.onMsgPasseArme(data); } @@ -938,7 +939,7 @@ export class RdDCombat { /* -------------------------------------------- */ _socketSendMessageDefense(paramChatDefense, defenderRoll) { // envoyer le message au destinataire - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_defense", data: { attackerId: this.attacker?.data._id, defenderId: this.defender?.data._id, @@ -1302,7 +1303,7 @@ export class RdDCombat { this.defender.encaisserDommages(attackerRoll, this.attacker, defenderRoll); } else { // envoi à un GM: les joueurs n'ont pas le droit de modifier les personnages qu'ils ne possèdent pas - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_encaisser", data: { attackerId: this.attackerId, diff --git a/module/rdd-compendium-organiser.js b/module/rdd-compendium-organiser.js index 91611194..7f4a4665 100644 --- a/module/rdd-compendium-organiser.js +++ b/module/rdd-compendium-organiser.js @@ -1,3 +1,4 @@ +import { SYSTEM_RDD } from "./constants.js"; import { Misc } from "./misc.js"; export class RddCompendiumOrganiser { @@ -8,7 +9,7 @@ export class RddCompendiumOrganiser { static async onRenderCompendium(compendium, html, data) { console.log('onRenderCompendium', compendium, html, data); const pack = compendium.collection - if (pack.metadata.system === 'foundryvtt-reve-de-dragon') { + if (pack.metadata.system === SYSTEM_RDD) { html.find('.directory-item').each((i, element) => { RddCompendiumOrganiser.setEntityTypeName(pack, element); }); diff --git a/module/rdd-main.js b/module/rdd-main.js index 1c7321c9..90852f7d 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -8,7 +8,7 @@ /* -------------------------------------------- */ // Import Modules -import { SYSTEM_RDD } from "./constants.js"; +import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { RdDActor } from "./actor.js"; import { RdDItemSheet } from "./item-sheet.js"; import { RdDActorSheet } from "./actor-sheet.js"; @@ -147,7 +147,7 @@ Hooks.once("init", async function () { }; /* -------------------------------------------- */ - game.socket.on("system.foundryvtt-reve-de-dragon", sockmsg => { + game.socket.on(SYSTEM_SOCKET_ID, sockmsg => { console.log(">>>>> MSG RECV", sockmsg); RdDUtility.onSocketMessage(sockmsg); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index ce522327..3d62ddac 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -1,3 +1,4 @@ +import { SYSTEM_SOCKET_ID } from "./constants.js"; import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RdDUtility } from "./rdd-utility.js"; import { TMRUtility } from "./tmr-utility.js"; @@ -947,7 +948,7 @@ export class RdDTMRDialog extends Dialog { this.cumulFatigue += this.fatigueParCase; } this.updateValuesDisplay(); - game.socket.emit("system.foundryvtt-reve-de-dragon", { + game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_tmr_move", data: { actorId: this.actor.data._id, tmrPos: Misc.data(this.actor).data.reve.tmrpos