Fix suppression de messages
This commit is contained in:
parent
cf1c7003d1
commit
9bc24fd326
@ -3,12 +3,35 @@
|
|||||||
* Class providing helper methods to get the list of users, and
|
* Class providing helper methods to get the list of users, and
|
||||||
*/
|
*/
|
||||||
export class ChatUtility {
|
export class ChatUtility {
|
||||||
|
|
||||||
|
static onSocketMessage(sockmsg) {
|
||||||
|
switch (sockmsg.msg) {
|
||||||
|
case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.part, sockmsg.gmId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static onRemoveMessages(part, gmId) {
|
||||||
|
if (game.user._id == gmId) {
|
||||||
|
const toDelete = game.messages.filter(it => it.data.content.includes(part));
|
||||||
|
toDelete.forEach(it => it.delete());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static removeMyChatMessageContaining(part) {
|
static removeChatMessageContaining(part) {
|
||||||
const toDelete = game.messages.filter(it => it.user._id == game.user._id)
|
const gmId = game.user.isGM ? game.user._id : game.users.entities.find(u => u.isGM)?.id;
|
||||||
.filter(it => it.data.content.includes(part));
|
|
||||||
toDelete.forEach(it => it.delete());
|
if (!gmId || game.user.isGM) {
|
||||||
|
ChatUtility.onRemoveMessages(part, game.user._id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||||
|
msg: "msg_delete_chat_message", data: {
|
||||||
|
part:part,
|
||||||
|
gmId: gmId,
|
||||||
|
}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -44,18 +44,18 @@ export class RdDCombat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static onPreDeleteCombat(combat, options) {
|
static onPreDeleteCombat(combat, options) {
|
||||||
if (game.user.isGM) {
|
if (game.user.isGM) {
|
||||||
ChatUtility.removeMyChatMessageContaining(`<div data-combatid="${combat.id}" data-combatmessage="actor-turn-summary">`)
|
ChatUtility.removeChatMessageContaining(`<div data-combatid="${combat.id}" data-combatmessage="actor-turn-summary">`)
|
||||||
/*
|
/*
|
||||||
* TODO: support de plusieurs combats parallèles
|
* TODO: support de plusieurs combats parallèles
|
||||||
* il faudrait avoir un id de combat en plus de celui de passe d'armes
|
* il faudrait avoir un id de combat en plus de celui de passe d'armes
|
||||||
*/
|
*/
|
||||||
for (const key in game.system.rdd.combatStore.attaques) {
|
for (const key in game.system.rdd.combatStore.attaques) {
|
||||||
const attackerRoll = game.system.rdd.combatStore.attaques[key];
|
const attackerRoll = game.system.rdd.combatStore.attaques[key];
|
||||||
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${attackerRoll.passeArme}">`);
|
ChatUtility.removeChatMessageContaining(`<div data-passearme="${attackerRoll.passeArme}">`);
|
||||||
}
|
}
|
||||||
for (const key in game.system.rdd.combatStore.defenses) {
|
for (const key in game.system.rdd.combatStore.defenses) {
|
||||||
const defenderRoll = game.system.rdd.combatStore.defenses[key];
|
const defenderRoll = game.system.rdd.combatStore.defenses[key];
|
||||||
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${defenderRoll.passeArme}">`);
|
ChatUtility.removeChatMessageContaining(`<div data-passearme="${defenderRoll.passeArme}">`);
|
||||||
}
|
}
|
||||||
RdDCombat.initStorePasseArmes();
|
RdDCombat.initStorePasseArmes();
|
||||||
}
|
}
|
||||||
@ -174,6 +174,7 @@ export class RdDCombat {
|
|||||||
const defenderRoll = msg.defenderRoll;
|
const defenderRoll = msg.defenderRoll;
|
||||||
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
|
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
|
||||||
RdDCombat._storeDefense(defenderRoll);
|
RdDCombat._storeDefense(defenderRoll);
|
||||||
|
rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
|
||||||
rddCombat._chatMessageDefense(msg.paramChatDefense);
|
rddCombat._chatMessageDefense(msg.paramChatDefense);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,8 +311,8 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
removeChatMessageActionsPasseArme(passeArme) {
|
removeChatMessageActionsPasseArme(passeArme) {
|
||||||
if (game.user.isGM && game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
|
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
|
||||||
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
|
ChatUtility.removeChatMessageContaining(`<div data-passearme="${passeArme}">`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +561,8 @@ export class RdDCombat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async choixParticuliere(rollData, choix) {
|
async choixParticuliere(rollData, choix) {
|
||||||
console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
|
console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
|
||||||
// TODO
|
|
||||||
|
this.removeChatMessageActionsPasseArme(rollData.passeArme);
|
||||||
rollData.particuliere = choix;
|
rollData.particuliere = choix;
|
||||||
await this._onAttaqueNormale(rollData);
|
await this._onAttaqueNormale(rollData);
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,7 @@ Hooks.once("init", async function () {
|
|||||||
game.socket.on("system.foundryvtt-reve-de-dragon", data => {
|
game.socket.on("system.foundryvtt-reve-de-dragon", data => {
|
||||||
RdDUtility.onSocketMesssage(data);
|
RdDUtility.onSocketMesssage(data);
|
||||||
RdDCombat.onSocketMessage(data);
|
RdDCombat.onSocketMessage(data);
|
||||||
|
ChatUtility.onSocketMessage(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -224,14 +225,15 @@ Hooks.once("init", async function () {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
function messageDeBienvenue() {
|
function messageDeBienvenue() {
|
||||||
ChatUtility.removeMyChatMessageContaining('<div id="message-bienvenue-rdd">');
|
if (game.user.isGM) {
|
||||||
ChatMessage.create({
|
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
|
||||||
user: game.user._id,
|
ChatMessage.create({
|
||||||
whisper: [game.user._id],
|
user: game.user._id,
|
||||||
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
||||||
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
||||||
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
||||||
` });
|
` });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user