From 3c062afd564b2dc9190701affd0ce016664e1756 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sun, 13 Aug 2023 20:42:54 +0200 Subject: [PATCH] Fix remoteActorCall --- module/actor.js | 6 ++++-- module/actor/base-actor.js | 11 ++++++++++- system.json | 5 ++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/module/actor.js b/module/actor.js index f7a62b52..c1fc82aa 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1741,6 +1741,7 @@ export class RdDActor extends RdDBaseActor { async consommerNourritureboisson(itemId, choix = { doses: 1, seForcer: false, supprimerSiZero: false }, userId = undefined) { if (userId != undefined && userId != game.user.id) { RdDBaseActor.remoteActorCall({ + tokenId: actor.token?.id, actorId: this.id, method: 'consommerNourritureboisson', args: [itemId, choix, userId] @@ -3121,7 +3122,7 @@ export class RdDActor extends RdDBaseActor { async onRollTachePremiersSoins(blessureId, rollData) { if (!this.isOwner) { - return RdDBaseActor.remoteActorCall({ actorId: this.id, method: 'onRollTachePremiersSoins', args: [blessureId, rollData] }); + return RdDBaseActor.remoteActorCall({ tokenId: actor.token?.id, actorId: this.id, method: 'onRollTachePremiersSoins', args: [blessureId, rollData] }); } const blessure = this.getItem(blessureId, 'blessure') console.log('TODO update blessure', this, blessureId, rollData, rollData.tache); @@ -3151,7 +3152,7 @@ export class RdDActor extends RdDBaseActor { async onRollSoinsComplets(blessureId, rollData) { if (!this.isOwner) { - return RdDBaseActor.remoteActorCall({ actorId: this.id, method: 'onRollSoinsComplets', args: [blessureId, rollData] }); + return RdDBaseActor.remoteActorCall({ tokenId: actor.token?.id, actorId: this.id, method: 'onRollSoinsComplets', args: [blessureId, rollData] }); } const blessure = this.getItem(blessureId, 'blessure') if (blessure && blessure.system.premierssoins.done && !blessure.system.soinscomplets.done) { @@ -3245,6 +3246,7 @@ export class RdDActor extends RdDBaseActor { const attackerId = attacker?.id; if (ReglesOptionnelles.isUsing('validation-encaissement-gr') && !game.user.isGM) { RdDBaseActor.remoteActorCall({ + tokenId: actor.token?.id, actorId: this.id, method: 'appliquerEncaissement', args: [rollData, show, attackerId] diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index 1d1b3b6b..01881549 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -50,7 +50,13 @@ export class RdDBaseActor extends Actor { static onRemoteActorCall(callData, userId) { if (userId == game.user.id) { - const actor = game.actors.get(callData?.actorId); + let actor = game.actors.get(callData?.actorId); + if ( callData.tokenId) { + let token = canvas.tokens.placeables.find(t => t.id == callData.tokenId) + if (token) { + actor = token.actor + } + } if (Misc.isOwnerPlayerOrUniqueConnectedGM(actor)) { // Seul le joueur choisi effectue l'appel: le joueur courant si propriétaire de l'actor, ou le MJ sinon const args = callData.args; console.info(`RdDBaseActor.onRemoteActorCall: pour l'Actor ${callData.actorId}, appel de RdDBaseActor.${callData.method}(`, ...args, ')'); @@ -147,6 +153,7 @@ export class RdDBaseActor extends Actor { async creerObjetParMJ(object) { if (!Misc.isUniqueConnectedGM()) { RdDBaseActor.remoteActorCall({ + tokenId: this.token?.id, actorId: this.id, method: 'creerObjetParMJ', args: [object] @@ -220,6 +227,7 @@ export class RdDBaseActor extends Actor { if (fromActorId && !game.user.isGM) { RdDBaseActor.remoteActorCall({ userId: Misc.connectedGMOrUser(), + tokenId: actor.token?.id, actorId: this.id, method: 'ajouterSols', args: [sols, fromActorId] }); @@ -250,6 +258,7 @@ export class RdDBaseActor extends Actor { } if (!Misc.isUniqueConnectedGM()) { RdDBaseActor.remoteActorCall({ + tokenId: actor.token?.id, actorId: achat.vendeurId ?? achat.acheteurId, method: 'achatVente', args: [achat] diff --git a/system.json b/system.json index cce7035c..aa330092 100644 --- a/system.json +++ b/system.json @@ -1,14 +1,13 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "11.0.15", + "version": "11.0.16", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.0.15.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json", "changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md", "compatibility": { "minimum": "11", - "verified": "11", - "maximum": "11" + "verified": "11" }, "description": "Rêve de Dragon RPG for FoundryVTT", "authors": [