Executions une seule fois

Fix sur les actions à faire une seule fois en cas de plusieurs GM

Quand plusieurs GM ou assistant GM sont connectés, ils exécutaient
tous certaines actions.

Conséquence: ajout de casetmr en doublon, détermination de 2 chiffres
astraux, modification d'initiative de premier tour en double
This commit is contained in:
Vincent Vandemeulebrouck
2021-11-26 00:45:21 +01:00
parent a1972073d5
commit 4f91fab3d5
7 changed files with 40 additions and 30 deletions

View File

@ -227,7 +227,7 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */
static processPremierRoundInit() {
// Check if we have the whole init !
if (game.user.isGM && game.combat.current.round == 1) {
if (Misc.isUniqueConnectedGM() && game.combat.current.round == 1) {
let initMissing = game.combat.data.combatants.find(it => !it.initiative);
if (!initMissing) { // Premier round !
for (let combatant of game.combat.data.combatants) {
@ -422,7 +422,7 @@ export class RdDCombat {
/* -------------------------------------------- */
static combatNouveauTour(combat) {
if (Misc.isElectedUser()) {
if (Misc.isUniqueSingleUser()) {
let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
if (turn?.actor) {
RdDCombat.displayActorCombatStatus(combat, turn.actor);
@ -540,7 +540,7 @@ export class RdDCombat {
/* -------------------------------------------- */
static onMsgEncaisser(data) {
if (Misc.isElectedUser()) {
if (Misc.isUniqueSingleUser()) {
let attackerRoll = RdDCombat._getAttaque(data.attackerId); // Retrieve the rolldata from the store
let attacker = data.attackerId ? game.actors.get(data.attackerId) : null;
let defender = canvas.tokens.get(data.defenderTokenId).actor;
@ -555,7 +555,7 @@ export class RdDCombat {
/* -------------------------------------------- */
static onMsgDefense(msg) {
let defenderToken = canvas.tokens.get(msg.defenderTokenId);
if (defenderToken && Misc.isElectedUser()) {
if (defenderToken && Misc.isUniqueSingleUser()) {
const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId);
if (rddCombat) {
const defenderRoll = msg.defenderRoll;
@ -913,7 +913,7 @@ export class RdDCombat {
dmg: attackerRoll.dmg,
};
if (!Misc.isElectedUser()) {
if (!Misc.isUniqueSingleUser()) {
this._socketSendMessageDefense(paramChatDefense, defenderRoll);
}
else {
@ -1286,7 +1286,7 @@ export class RdDCombat {
this._onEchecTotal(defenderRoll);
}
if (Misc.isElectedUser()) {
if (Misc.isUniqueSingleUser()) {
attackerRoll.attackerId = this.attackerId;
attackerRoll.defenderTokenId = defenderTokenId;