diff --git a/module/rdd-combat.js b/module/rdd-combat.js index ea574f09..1f42618e 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -465,15 +465,15 @@ export class RdDCombat { } /* -------------------------------------------- */ - static onMsgEncaisser(data) { - let defender = canvas.tokens.get(data.defenderTokenId).actor; + static onMsgEncaisser(msg) { + let defender = canvas.tokens.get(msg.defenderTokenId).actor; if (Misc.isOwnerPlayerOrUniqueConnectedGM()) { - let attackerRoll = data.attackerRoll; - let attacker = data.attackerId ? game.actors.get(data.attackerId) : null; + let attackerRoll = msg.attackerRoll; + let attacker = msg.attackerId ? game.actors.get(msg.attackerId) : null; defender.encaisserDommages(attackerRoll, attacker); - RdDCombat._deleteDefense(attackerRoll.passeArme); - RdDCombat._deleteAttaque(data.attackerId); + const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); + rddCombat?.removeChatMessageActionsPasseArme(attackerRoll.passeArme); } } @@ -482,11 +482,8 @@ export class RdDCombat { let defenderToken = canvas.tokens.get(msg.defenderTokenId); if (defenderToken && Misc.isUniqueConnectedGM()) { const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); - if (rddCombat) { - const defenderRoll = msg.defenderRoll; - rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme); - rddCombat._chatMessageDefense(msg.paramChatDefense, msg.defenderRoll); - } + rddCombat?.removeChatMessageActionsPasseArme(msg.defenderRoll.passeArme); + rddCombat?._chatMessageDefense(msg.paramChatDefense, msg.defenderRoll); } } @@ -1005,8 +1002,7 @@ export class RdDCombat { await this.computeRecul(defenderRoll); await this.computeDeteriorationArme(defenderRoll); await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html'); - - RdDCombat._deleteDefense(defenderRoll.passeArme); + this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); } /* -------------------------------------------- */ @@ -1077,7 +1073,7 @@ export class RdDCombat { async _onEsquiveNormale(defenderRoll) { console.log("RdDCombat._onEsquiveNormal >>>", defenderRoll); await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-esquive.html'); - RdDCombat._deleteDefense(defenderRoll.passeArme); + this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); } /* -------------------------------------------- */ @@ -1217,7 +1213,6 @@ export class RdDCombat { } }); } - RdDCombat._deleteDefense(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); }