Merge branch 'v1.4-fix-193' into 'v1.4'
#193: utiliser isElectedUser pour les défenses See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!250
This commit is contained in:
commit
a22c435ca5
@ -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 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -190,7 +190,7 @@ 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) {
|
||||||
|
if (Misc.isElectedUser()) {
|
||||||
let turn = combat.turns.find(t => t.tokenId == combat.current.tokenId);
|
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);
|
this.displayActorCombatStatus(combat, turn.actor);
|
||||||
// TODO Playaudio for player??
|
// TODO Playaudio for player??
|
||||||
}
|
}
|
||||||
@ -477,19 +476,18 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static onMsgEncaisser(data) {
|
static onMsgEncaisser(data) {
|
||||||
|
if (Misc.isElectedUser()) {
|
||||||
let attackerRoll = RdDCombat._getAttaque(data.attackerId); // Retrieve the rolldata from the store
|
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._deleteDefense(attackerRoll.passeArme);
|
||||||
RdDCombat._deleteAttaque(data.attackerId);
|
RdDCombat._deleteAttaque(data.attackerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static onMsgDefense(msg) {
|
static onMsgDefense(msg) {
|
||||||
let defenderToken = canvas.tokens.get(msg.defenderTokenId);
|
let defenderToken = canvas.tokens.get(msg.defenderTokenId);
|
||||||
@ -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