From c63a1d09912e206d8009afadc104231daeff5d86 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 26 Oct 2024 01:38:36 +0200 Subject: [PATCH] Utilisation du nom du Nom du token suite (pour les encaissements) --- module/actor/base-actor-reve.js | 22 +++++++++++----------- module/rdd-combat.js | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index 02e549d5..21d2e608 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -415,47 +415,47 @@ export class RdDBaseActorReve extends RdDBaseActor { /* -------------------------------------------- */ async encaisser() { await RdDEncaisser.encaisser(this) } - async encaisserDommages(rollData, attacker = undefined, attackerToken = undefined, show = undefined) { + async encaisserDommages(rollData, attacker = undefined, show = undefined, attackerToken = undefined, defenderToken = undefined) { if (attacker && !await attacker.accorder(this, 'avant-encaissement')) { return; } const armure = await this.computeArmure(rollData); if (ReglesOptionnelles.isUsing('validation-encaissement-gr')) { - await this.encaisserDommagesValidationGR(rollData, armure, attackerToken, show); + await this.encaisserDommagesValidationGR(rollData, armure, show, attackerToken, defenderToken); } else { const jet = await RdDUtility.jetEncaissement(this, rollData, armure, { showDice: SHOW_DICE }); - await this.$onEncaissement(jet, show, attackerToken) + await this.$onEncaissement(jet, show, attackerToken, defenderToken) } } - async encaisserDommagesValidationGR(rollData, armure, attackerToken, show) { + async encaisserDommagesValidationGR(rollData, armure, show, attackerToken, defenderToken) { if (!game.user.isGM) { RdDBaseActor.remoteActorCall({ tokenId: this.token?.id, actorId: this.id, method: 'encaisserDommagesValidationGR', - args: [rollData, armure, attackerToken, show] + args: [rollData, armure, show, attackerToken, defenderToken] }) } else { DialogValidationEncaissement.validerEncaissement(this, rollData, armure, - jet => this.$onEncaissement(jet, show, attackerToken)); + jet => this.$onEncaissement(jet, show, attackerToken, defenderToken)); } } - async $onEncaissement(jet, show, attackerToken) { + async $onEncaissement(jet, show, attackerToken, defenderToken) { await this.onAppliquerJetEncaissement(jet, attackerToken); - await this.$afficherEncaissement(jet, show); + await this.$afficherEncaissement(jet, show, defenderToken); } async onAppliquerJetEncaissement(encaissement, attackerToken) { } - async $afficherEncaissement(encaissement, show) { + async $afficherEncaissement(encaissement, show, defenderToken) { foundry.utils.mergeObject(encaissement, { - alias: this.name, + alias: defenderToken?.name ?? this.name, hasPlayerOwner: this.hasPlayerOwner, show: show ?? {} - }); + }, {overwrite: false}); await ChatUtility.createChatWithRollMode( { diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 4de3fb5b..22cca49a 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -887,7 +887,7 @@ export class RdDCombat { attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite()); let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} } attackerRoll.show = { - cible: this.target ? this.defender.name : 'la cible', + cible: this.defenderToken?.name ?? 'la cible', isRecul: (attackerRoll.particuliere == 'force' || attackerRoll.tactique == 'charge') } await RdDResolutionTable.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.html'); @@ -1317,7 +1317,7 @@ export class RdDCombat { attackerRoll.defenderTokenId = this.defenderToken.id; await this.computeRecul(defenderRoll); - await this.defender.encaisserDommages(attackerRoll, this.attacker, this.attackerToken, defenderRoll?.show); + await this.defender.encaisserDommages(attackerRoll, this.attacker, defenderRoll?.show, this.attackerToken, this.defenderToken); } 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_SOCKET_ID, {