#193: utiliser isElectedUser pour les défenses #466
@ -1,3 +1,4 @@
|
||||
import { Misc } from "./misc";
|
||||
|
||||
/**
|
||||
* Class providing helper methods to get the list of users, and
|
||||
@ -7,13 +8,13 @@ export class ChatUtility {
|
||||
/* -------------------------------------------- */
|
||||
static onSocketMessage(sockmsg) {
|
||||
switch (sockmsg.msg) {
|
||||
case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.part, sockmsg.gmId);
|
||||
case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.part);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static onRemoveMessages(part, gmId) {
|
||||
if (game.user._id == gmId) {
|
||||
static onRemoveMessages(part) {
|
||||
if (Misc.isElectedUser()) {
|
||||
const toDelete = game.messages.filter(it => it.data.content.includes(part));
|
||||
toDelete.forEach(it => it.delete());
|
||||
}
|
||||
@ -21,17 +22,13 @@ export class ChatUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static removeChatMessageContaining(part) {
|
||||
const gmId = game.user.isGM ? game.user._id : game.users.entities.find(u => u.isGM && u.active)?.id;
|
||||
|
||||
if (!gmId || game.user.isGM) {
|
||||
ChatUtility.onRemoveMessages(part, game.user._id);
|
||||
if (Misc.isElectedUser()) {
|
||||
ChatUtility.onRemoveMessages(part);
|
||||
}
|
||||
else {
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
msg: "msg_delete_chat_message", data: {
|
||||
part:part,
|
||||
gmId: gmId,
|
||||
}});
|
||||
msg: "msg_delete_chat_message", data: { part: part }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,9 +395,8 @@ export class RdDCombat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static combatNouveauTour(combat) {
|
||||
if (Misc.isElectedUser()) {
|
||||
let turn = combat.turns.find(t => t.tokenId == combat.current.tokenId);
|
||||
if (game.user.isGM) {
|
||||
// seul le GM notifie le status
|
||||
this.displayActorCombatStatus(combat, turn.actor);
|
||||
// TODO Playaudio for player??
|
||||
}
|
||||
@ -482,18 +481,16 @@ export class RdDCombat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static onMsgEncaisser(data) {
|
||||
if (Misc.isElectedUser()) {
|
||||
let attackerRoll = RdDCombat._getAttaque(data.attackerId); // Retrieve the rolldata from the store
|
||||
|
||||
if (game.user.id === data.gmId) { // Seul le GM effectue l'encaissement sur la fiche
|
||||
let attacker = data.attackerId ? game.actors.get(data.attackerId) : null;
|
||||
let defender = canvas.tokens.get(data.defenderTokenId).actor;
|
||||
|
||||
defender.encaisserDommages(attackerRoll, attacker);
|
||||
}
|
||||
|
||||
RdDCombat._deleteDefense(attackerRoll.passeArme);
|
||||
RdDCombat._deleteAttaque(data.attackerId);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static onMsgDefense(msg) {
|
||||
@ -503,7 +500,7 @@ export class RdDCombat {
|
||||
ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer.");
|
||||
return;
|
||||
}
|
||||
if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character?._id == defenderToken.actor.data._id))) {
|
||||
if (Misc.isElectedUser()) {
|
||||
const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId);
|
||||
if (rddCombat) {
|
||||
const defenderRoll = msg.defenderRoll;
|
||||
@ -825,8 +822,7 @@ export class RdDCombat {
|
||||
dmg: attackerRoll.dmg,
|
||||
};
|
||||
|
||||
const selfMessage = essaisPrecedents != undefined;
|
||||
if (!selfMessage && (!game.user.isGM || this.defender.hasPlayerOwner)) {
|
||||
if (!Misc.isElectedUser()) {
|
||||
this._socketSendMessageDefense(paramChatDefense, defenderRoll);
|
||||
}
|
||||
else {
|
||||
@ -1203,7 +1199,7 @@ export class RdDCombat {
|
||||
this._onEchecTotal(defenderRoll);
|
||||
}
|
||||
|
||||
if (game.user.isGM) { // Current user is the GM -> direct access
|
||||
if (Misc.isElectedUser()) {
|
||||
attackerRoll.attackerId = this.attackerId;
|
||||
attackerRoll.defenderTokenId = defenderTokenId;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user