Merge branch 'stabilisation-v1.2' into 'v1.2'

Stabilisation v1.2

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!120
This commit is contained in:
Leratier Bretonnien 2021-01-20 07:41:19 +00:00
commit 25ba528201
3 changed files with 46 additions and 19 deletions

View File

@ -4,13 +4,36 @@
*/ */
export class ChatUtility { export class ChatUtility {
/* -------------------------------------------- */ static onSocketMessage(sockmsg) {
static removeMyChatMessageContaining(part) { switch (sockmsg.msg) {
const toDelete = game.messages.filter(it => it.user._id == game.user._id) case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.part, sockmsg.gmId);
.filter(it => it.data.content.includes(part)); }
}
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()); toDelete.forEach(it => it.delete());
} }
}
/* -------------------------------------------- */
static removeChatMessageContaining(part) {
const gmId = game.user.isGM ? game.user._id : game.users.entities.find(u => u.isGM)?.id;
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,
}});
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static createChatWithRollMode(name, chatOptions) { static createChatWithRollMode(name, chatOptions) {
ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions); ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);

View File

@ -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);
} }
@ -716,7 +718,7 @@ export class RdDCombat {
_onEsquiveParticuliere(rollData) { _onEsquiveParticuliere(rollData) {
console.log("RdDCombat._onEsquiveParticuliere >>>", rollData); console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
ChatUtility.createChatWithRollMode(this.defender.name, { ChatUtility.createChatWithRollMode(this.defender.name, {
content: "<strong>Vous pouvez esquiver une deuxième esquive!</strong>" content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>"
}); });
} }

View File

@ -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) {
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
ChatMessage.create({ ChatMessage.create({
user: game.user._id, user: game.user._id,
whisper: [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>
` }); ` });
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */