From 6414f76d676d043b23bb803a54b307e83c4853d2 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 9 Mar 2024 23:12:13 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20ignorer=20personnages=20joueurs=20non=20?= =?UTF-8?q?li=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour les fenêtres de stress/repos/voyage/astrologie, ignorer les personnages non liés (par exemple, un guerrier sorde) --- module/actor.js | 4 ++++ module/actor/base-actor.js | 2 ++ module/actor/experience-log.js | 2 +- module/rdd-commands.js | 7 +++---- module/sommeil/app-astrologie.js | 2 +- module/sommeil/dialog-chateau-dormant.js | 4 +--- module/sommeil/dialog-stress.js | 2 +- module/voyage/dialog-fatigue-voyage.js | 5 ++--- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/module/actor.js b/module/actor.js index 7cdcf1d7..9b2ae3f2 100644 --- a/module/actor.js +++ b/module/actor.js @@ -95,6 +95,10 @@ export class RdDActor extends RdDBaseActorSang { return ![TYPES.competencecreature, TYPES.tarot, TYPES.service].includes(item.type) } + isPersonnageJoueur() { + return this.hasPlayerOwner && this.prototypeToken.actorLink + } + isPersonnage() { return true } isHautRevant() { return this.system.attributs.hautrevant.value != "" } diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index 2cd4f79c..acc22ee4 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -85,6 +85,8 @@ export class RdDBaseActor extends Actor { return game.actors.get(actorId) } + isPersonnageJoueur() { return false } + static extractActorMin = (actor) => { return { id: actor?.id, type: actor?.type, name: actor?.name, img: actor?.img }; }; static getParentActor(document) { diff --git a/module/actor/experience-log.js b/module/actor/experience-log.js index 2d60ed9e..ad282e78 100644 --- a/module/actor/experience-log.js +++ b/module/actor/experience-log.js @@ -12,7 +12,7 @@ export const XP_TOPIC = { export class ExperienceLog { static async add(actor, topic, from, to, raison, manuel = false) { - if (!actor.hasPlayerOwner || !actor.isPersonnage()) { + if (!actor.isPersonnageJoueur()) { return } if (from == to) { diff --git a/module/rdd-commands.js b/module/rdd-commands.js index fdf88956..88b08dc3 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -463,14 +463,13 @@ export class RdDCommands { let motif = params.slice(1, params.length - 2); let name = params[params.length - 1]; + const personnages = game.actors.filter(actor => actor.isPersonnageJoueur()); if (name == undefined) { - for (let actor of game.actors) { - // TODO: ne plus stresser les entités de cauchemar! + for (let actor of personnages) { await actor.distribuerStress('stress', stress, motif); } } else { - //console.log(stressValue, nomJoueur); - let actor = Misc.findActor(name, game.actors.filter(it => it.hasPlayerOwner)) ?? Misc.findPlayer(name)?.character + let actor = Misc.findActor(name, personnages) ?? Misc.findPlayer(name)?.character if (actor) { await actor.distribuerStress('stress', stress, motif); } diff --git a/module/sommeil/app-astrologie.js b/module/sommeil/app-astrologie.js index d993eaf7..bd09f0ed 100644 --- a/module/sommeil/app-astrologie.js +++ b/module/sommeil/app-astrologie.js @@ -85,7 +85,7 @@ export class AppAstrologie extends Application { const nbAstral = calendrier.getNombreAstral() const heures = RdDTimestamp.heures(); return { - ajustementsActors: game.actors.filter(it => it.isPersonnage() && it.hasPlayerOwner) + ajustementsActors:game.actors.filter(actor => actor.isPersonnageJoueur()) .map(actor => this.getAjustementActor(actor, nbAstral, heures)), nombresAstraux: calendrier.getNombresAstraux().map(na => this.getDetailNombreAstral(na)) } diff --git a/module/sommeil/dialog-chateau-dormant.js b/module/sommeil/dialog-chateau-dormant.js index 49faa706..0a928e29 100644 --- a/module/sommeil/dialog-chateau-dormant.js +++ b/module/sommeil/dialog-chateau-dormant.js @@ -3,10 +3,8 @@ export class DialogChateauDormant extends Dialog { static async create() { const date = game.system.rdd.calendrier.dateCourante(); - const actors = game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage()); - const dialogData = { - actors: actors, + actors: game.actors.filter(actor => actor.isPersonnageJoueur()), date: date, motifStress: `Nuit du ${date}`, finChateauDormant: game.system.rdd.calendrier.getTimestampFinChateauDormant() diff --git a/module/sommeil/dialog-stress.js b/module/sommeil/dialog-stress.js index fd413798..1a6502f2 100644 --- a/module/sommeil/dialog-stress.js +++ b/module/sommeil/dialog-stress.js @@ -6,7 +6,7 @@ export class DialogStress extends Dialog { motif: "Motif", stress: 10, immediat: false, - actors: game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage()) + actors: game.actors.filter(actor => actor.isPersonnageJoueur()) .map(actor => ({ id: actor.id, name: actor.name, diff --git a/module/voyage/dialog-fatigue-voyage.js b/module/voyage/dialog-fatigue-voyage.js index a874d1fc..d8bfde69 100644 --- a/module/voyage/dialog-fatigue-voyage.js +++ b/module/voyage/dialog-fatigue-voyage.js @@ -33,11 +33,10 @@ export class DialogFatigueVoyage extends Dialog { return } if (!DialogFatigueVoyage.dialog) { - const playerActors = game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage()) - .map(actor => DialogFatigueVoyage.prepareActor(actor)) const parameters = { tableauFatigueMarche: TABLEAU_FATIGUE_MARCHE, - playerActors: playerActors, + playerActors: game.actors.filter(actor => actor.isPersonnageJoueur()) + .map(actor => DialogFatigueVoyage.prepareActor(actor)), nombreHeures: 1, } DialogFatigueVoyage.setModeDeplacement(parameters, undefined, undefined)