#193: utiliser isElectedUser pour les défenses
Misc.isElectedUser renvoit true pour un seul MJ connecté, ou le joueur connecté s'il n'y a pas de MJ. Ca veut dire que sans MJ, les messages de combat ne marcheront peut-être pas, mais pour tous les autres cas, ça marchera correctement, vu que ce sera toujours un MJ qui postera le message de défense au joueur (connecté ou pas) et au MJ
This commit is contained in:
parent
8947681e95
commit
d201a91d41
@ -14,40 +14,28 @@ export class ChatUtility {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static onRemoveMessages(data) {
|
static onRemoveMessages(data) {
|
||||||
if (game.user.isGM || game.user.id == data.gmId) {
|
if (Misc.isElectedUser()) {
|
||||||
if (data.part){
|
if (data.part) {
|
||||||
const toDelete = game.messages.filter(it => it.data.content.includes(data.part));
|
const toDelete = game.messages.filter(it => it.data.content.includes(data.part));
|
||||||
toDelete.forEach(it => it.delete());
|
toDelete.forEach(it => it.delete());
|
||||||
}
|
}
|
||||||
if (data.messageId){
|
if (data.messageId) {
|
||||||
game.messages.get(data.messageId)?.delete();
|
game.messages.get(data.messageId)?.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: data });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static removeChatMessageContaining(part) {
|
static removeChatMessageContaining(part) {
|
||||||
const removeMessageData = {
|
ChatUtility.onRemoveMessages({ part: part });
|
||||||
part: part,
|
|
||||||
gmId: Misc.connectedGMOrUser()
|
|
||||||
};
|
|
||||||
|
|
||||||
if (game.user.isGM) {
|
|
||||||
ChatUtility.onRemoveMessages(removeMessageData);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: removeMessageData });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static removeChatMessageId(messageId) {
|
static removeChatMessageId(messageId) {
|
||||||
const removeMessageData = { messageId: messageId, gmId: Misc.connectedGMOrUser() };
|
ChatUtility.onRemoveMessages({ messageId: messageId });
|
||||||
if (game.user.isGM) {
|
|
||||||
ChatUtility.onRemoveMessages(removeMessageData);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: removeMessageData });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -146,7 +146,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
let armeData = Misc.data(arme);
|
let armeData = Misc.data(arme);
|
||||||
if (armeData.data.equipe) {
|
if (armeData.data.equipe) {
|
||||||
let compData = competences.map(c => Misc.data(c)).find(c => c.name == armeData.data.competence);
|
let compData = competences.map(c => Misc.data(c)).find(c => c.name == armeData.data.competence);
|
||||||
|
|
||||||
armesEquipe.push(armeData);
|
armesEquipe.push(armeData);
|
||||||
armeData.data.initiative = RdDCombatManager.calculInitiative(armeData.data.niveau, carac[compData.data.defaut_carac].value);
|
armeData.data.initiative = RdDCombatManager.calculInitiative(armeData.data.niveau, carac[compData.data.defaut_carac].value);
|
||||||
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
|
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
|
||||||
@ -189,8 +189,8 @@ export class RdDCombatManager extends Combat {
|
|||||||
|
|
||||||
let competences = items.filter(it => it.type == 'competence');
|
let competences = items.filter(it => it.type == 'competence');
|
||||||
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, actorData.data.carac));
|
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, actorData.data.carac));
|
||||||
|
|
||||||
if (actorData.data.attributs.hautrevant.value){
|
if (actorData.data.attributs.hautrevant.value) {
|
||||||
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
|
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,9 +390,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??
|
||||||
}
|
}
|
||||||
@ -477,17 +476,16 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -498,10 +496,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;
|
||||||
}
|
}
|
||||||
const isDefenderConnectedPlayer = defenderToken.actor.hasPlayerOwner; // TODO: tester si le joueur est pas connecté
|
if (Misc.isElectedUser()) {
|
||||||
if (isDefenderConnectedPlayer
|
|
||||||
? game.user.character?._id == defenderToken.actor.data._id // TODO: vérifier le cas d'un joueur qui est owner de plusieurs personnages
|
|
||||||
: game.user.isGM) {
|
|
||||||
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;
|
||||||
@ -821,8 +816,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 {
|
||||||
@ -1200,13 +1194,14 @@ 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;
|
||||||
|
|
||||||
await this.computeRecul(defenderRoll);
|
await this.computeRecul(defenderRoll);
|
||||||
this.defender.encaisserDommages(attackerRoll, this.attacker, defenderRoll);
|
this.defender.encaisserDommages(attackerRoll, this.attacker, defenderRoll);
|
||||||
} else { // envoi à un GM: les joueurs n'ont pas le droit de modifier les personnages qu'ils ne possèdent pas
|
}
|
||||||
|
else { // envoi à un GM: les joueurs n'ont pas le droit de modifier les personnages qu'ils ne possèdent pas
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||||
msg: "msg_encaisser",
|
msg: "msg_encaisser",
|
||||||
data: {
|
data: {
|
||||||
|
Loading…
Reference in New Issue
Block a user