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