Simplify ChatMessage whispers
Les messages dans les TMRs sont envoyés au GM Simplification des messages de tchat liés à un actor: on peut utiliser les Owners (car les GMs sont owner). Au lieu de passer le name de l'Actor (qui peut être incorrect si deux actors ont le même, mais pas les mêmes propriétaires), on passe directement l'actor pour déterminer mles destinataires de messages
This commit is contained in:
@ -99,9 +99,7 @@ export class RdDUtility {
|
||||
// persistent handling of conteneur show/hide
|
||||
static afficheContenu = {}
|
||||
/* -------------------------------------------- */
|
||||
static async init() {
|
||||
Hooks.on("renderChatMessage", async (app, html, msg) => await ChatUtility.onRenderChatMessage(app, html, msg))
|
||||
Hooks.on("createChatMessage", async (chatMessage, options, id) => await ChatUtility.onCreateChatMessage(chatMessage, options, id))
|
||||
static async initHooks() {
|
||||
Hooks.on('renderChatLog', (log, html, chatLog) => RdDUtility.chatListeners(html))
|
||||
}
|
||||
|
||||
@ -292,7 +290,7 @@ export class RdDUtility {
|
||||
|
||||
Handlebars.registerHelper('array-includes', (array, value) => array.includes(value));
|
||||
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
|
||||
Handlebars.registerHelper('isLastIndex', (index, list) => index+1 >= list.length);
|
||||
Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length);
|
||||
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option));
|
||||
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
|
||||
Handlebars.registerHelper('filtreTriCompetences', competences => RdDItemCompetence.triVisible(competences));
|
||||
@ -645,18 +643,16 @@ export class RdDUtility {
|
||||
/* -------------------------------------------- */
|
||||
static onSocketMessage(sockmsg) {
|
||||
switch (sockmsg.msg) {
|
||||
case "msg_gm_chat_message":
|
||||
return ChatUtility.handleGMChatMessage(sockmsg.data);
|
||||
case "msg_app_astrologie_refresh":
|
||||
return Hooks.callAll(APP_ASTROLOGIE_REFRESH);
|
||||
return Hooks.callAll(APP_ASTROLOGIE_REFRESH)
|
||||
case "msg_request_nombre_astral":
|
||||
return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data);
|
||||
return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data)
|
||||
case "msg_tmr_move":
|
||||
let actor = game.actors.get(sockmsg.data.actorId);
|
||||
if (actor.isOwner || game.user.isGM) {
|
||||
actor.refreshTMRView();
|
||||
actor.refreshTMRView()
|
||||
}
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -808,17 +804,13 @@ export class RdDUtility {
|
||||
user: game.user.id,
|
||||
rollMode: modeOverride || game.settings.get("core", "rollMode"),
|
||||
content: content
|
||||
};
|
||||
|
||||
if (["gmroll", "blindroll"].includes(chatData.rollMode)) chatData["whisper"] = ChatMessage.getWhisperRecipients("GM").map(u => u.id);
|
||||
if (chatData.rollMode === "blindroll") chatData["blind"] = true;
|
||||
else if (chatData.rollMode === "selfroll") chatData["whisper"] = [game.user];
|
||||
}
|
||||
ChatUtility.applyRollMode(chatData)
|
||||
|
||||
if (forceWhisper) { // Final force !
|
||||
chatData["speaker"] = ChatMessage.getSpeaker();
|
||||
chatData["whisper"] = ChatMessage.getWhisperRecipients(forceWhisper);
|
||||
chatData.speaker = ChatMessage.getSpeaker();
|
||||
chatData.whisper = ChatMessage.getWhisperRecipients(forceWhisper);
|
||||
}
|
||||
|
||||
return chatData;
|
||||
}
|
||||
|
||||
@ -881,7 +873,7 @@ export class RdDUtility {
|
||||
const current = game.system.rdd.calendrier.heureCourante();
|
||||
ChatMessage.create({
|
||||
content: `A l'heure de <strong>${current.label}</strong>, le modificateur de Chance/Malchance est de <strong>${Misc.toSignedString(ajustement)}</strong> pour l'heure de naissance <strong>${heure.label}</strong>.`,
|
||||
whisper: ChatMessage.getWhisperRecipients("GM")
|
||||
whisper: ChatUtility.getGMs()
|
||||
});
|
||||
}
|
||||
else if (heureNaissance) {
|
||||
@ -900,7 +892,7 @@ export class RdDUtility {
|
||||
if (compName.includes('Thanatos')) {
|
||||
let message = "Vous avez mis des points d'Expérience dans la Voie de Thanatos !<br>Vous devez réduire manuellement d'un même montant d'XP une autre compétence Draconique.";
|
||||
ChatMessage.create({
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name),
|
||||
whisper: ChatUtility.getUserAndGMs(),
|
||||
content: message
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user