From a7e7eec26120b8848e6a2a5b43d1e639c94271b4 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 ++-- templates/chat-resultat-encaissement.html | 1 - 3 files changed, 13 insertions(+), 14 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, { diff --git a/templates/chat-resultat-encaissement.html b/templates/chat-resultat-encaissement.html index d2c7ce22..f10b9ee5 100644 --- a/templates/chat-resultat-encaissement.html +++ b/templates/chat-resultat-encaissement.html @@ -1,5 +1,4 @@ {{#if isGM}} -{{log this}} {{#if (gt endurance 0)}} De plus, {{alias}} a perdu {{endurance}} points d'endurance