Fix remoteActorCall

This commit is contained in:
LeRatierBretonnien 2023-08-13 20:42:54 +02:00
parent 6de4fff403
commit 3c062afd56
3 changed files with 16 additions and 6 deletions

View File

@ -1741,6 +1741,7 @@ export class RdDActor extends RdDBaseActor {
async consommerNourritureboisson(itemId, choix = { doses: 1, seForcer: false, supprimerSiZero: false }, userId = undefined) { async consommerNourritureboisson(itemId, choix = { doses: 1, seForcer: false, supprimerSiZero: false }, userId = undefined) {
if (userId != undefined && userId != game.user.id) { if (userId != undefined && userId != game.user.id) {
RdDBaseActor.remoteActorCall({ RdDBaseActor.remoteActorCall({
tokenId: actor.token?.id,
actorId: this.id, actorId: this.id,
method: 'consommerNourritureboisson', method: 'consommerNourritureboisson',
args: [itemId, choix, userId] args: [itemId, choix, userId]
@ -3121,7 +3122,7 @@ export class RdDActor extends RdDBaseActor {
async onRollTachePremiersSoins(blessureId, rollData) { async onRollTachePremiersSoins(blessureId, rollData) {
if (!this.isOwner) { 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') const blessure = this.getItem(blessureId, 'blessure')
console.log('TODO update blessure', this, blessureId, rollData, rollData.tache); console.log('TODO update blessure', this, blessureId, rollData, rollData.tache);
@ -3151,7 +3152,7 @@ export class RdDActor extends RdDBaseActor {
async onRollSoinsComplets(blessureId, rollData) { async onRollSoinsComplets(blessureId, rollData) {
if (!this.isOwner) { 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') const blessure = this.getItem(blessureId, 'blessure')
if (blessure && blessure.system.premierssoins.done && !blessure.system.soinscomplets.done) { if (blessure && blessure.system.premierssoins.done && !blessure.system.soinscomplets.done) {
@ -3245,6 +3246,7 @@ export class RdDActor extends RdDBaseActor {
const attackerId = attacker?.id; const attackerId = attacker?.id;
if (ReglesOptionnelles.isUsing('validation-encaissement-gr') && !game.user.isGM) { if (ReglesOptionnelles.isUsing('validation-encaissement-gr') && !game.user.isGM) {
RdDBaseActor.remoteActorCall({ RdDBaseActor.remoteActorCall({
tokenId: actor.token?.id,
actorId: this.id, actorId: this.id,
method: 'appliquerEncaissement', method: 'appliquerEncaissement',
args: [rollData, show, attackerId] args: [rollData, show, attackerId]

View File

@ -50,7 +50,13 @@ export class RdDBaseActor extends Actor {
static onRemoteActorCall(callData, userId) { static onRemoteActorCall(callData, userId) {
if (userId == game.user.id) { 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 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; const args = callData.args;
console.info(`RdDBaseActor.onRemoteActorCall: pour l'Actor ${callData.actorId}, appel de RdDBaseActor.${callData.method}(`, ...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) { async creerObjetParMJ(object) {
if (!Misc.isUniqueConnectedGM()) { if (!Misc.isUniqueConnectedGM()) {
RdDBaseActor.remoteActorCall({ RdDBaseActor.remoteActorCall({
tokenId: this.token?.id,
actorId: this.id, actorId: this.id,
method: 'creerObjetParMJ', method: 'creerObjetParMJ',
args: [object] args: [object]
@ -220,6 +227,7 @@ export class RdDBaseActor extends Actor {
if (fromActorId && !game.user.isGM) { if (fromActorId && !game.user.isGM) {
RdDBaseActor.remoteActorCall({ RdDBaseActor.remoteActorCall({
userId: Misc.connectedGMOrUser(), userId: Misc.connectedGMOrUser(),
tokenId: actor.token?.id,
actorId: this.id, actorId: this.id,
method: 'ajouterSols', args: [sols, fromActorId] method: 'ajouterSols', args: [sols, fromActorId]
}); });
@ -250,6 +258,7 @@ export class RdDBaseActor extends Actor {
} }
if (!Misc.isUniqueConnectedGM()) { if (!Misc.isUniqueConnectedGM()) {
RdDBaseActor.remoteActorCall({ RdDBaseActor.remoteActorCall({
tokenId: actor.token?.id,
actorId: achat.vendeurId ?? achat.acheteurId, actorId: achat.vendeurId ?? achat.acheteurId,
method: 'achatVente', method: 'achatVente',
args: [achat] args: [achat]

View File

@ -1,14 +1,13 @@
{ {
"id": "foundryvtt-reve-de-dragon", "id": "foundryvtt-reve-de-dragon",
"title": "Rêve 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", "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", "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", "changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md",
"compatibility": { "compatibility": {
"minimum": "11", "minimum": "11",
"verified": "11", "verified": "11"
"maximum": "11"
}, },
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"authors": [ "authors": [