From 009ec47709522b8a32aeaf34dece14806183b641 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 5 Dec 2021 21:18:00 +0100 Subject: [PATCH] Fix message sur-encombrement --- module/actor-creature-sheet.js | 2 +- module/actor-sheet.js | 3 +-- module/actor-vehicule-sheet.js | 4 ++-- module/actor.js | 7 +++---- module/rdd-roll.js | 2 +- module/rolldata-ajustements.js | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index 0ebbd63d..218ba08f 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -33,8 +33,8 @@ export class RdDActorCreatureSheet extends RdDActorSheet { caracTotal: RdDCarac.computeTotal(formData.data.carac), resumeBlessures: this.actor.computeResumeBlessure(formData.data.blessures), encTotal: await this.actor.computeEncombrementTotalEtMalusArmure(), + surEncombrementMessage: this.actor.getMessageSurEncombrement() } - formData.calc.surEncombrementMessage = (formData.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; RdDUtility.filterItemsPerTypeForSheet(formData); this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets); diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 5c9d99b4..21c172db 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -75,8 +75,8 @@ export class RdDActorSheet extends ActorSheet { surprise: RdDBonus.find(this.actor.getSurprise(false)).descr, fatigue: RdDUtility.calculFatigueHtml(formData.data.sante.fatigue.value, formData.data.sante.endurance.max), resumeBlessures: this.actor.computeResumeBlessure(formData.data.blessures), + surEncombrementMessage: this.actor.getMessageSurEncombrement() }; - formData.calc.surEncombrementMessage = (formData.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; formData.competences.forEach(item => { item.visible = this.options.cherchercompetence @@ -136,7 +136,6 @@ export class RdDActorSheet extends ActorSheet { this.actor.addSubacteur(dragData.id || dragData.data._id); super._onDropActor(event, dragData); } - /* -------------------------------------------- */ async _onDropItem(event, dragData) { const callSuper = await this.actor.processDropItem(RdDSheetUtility.extractItemDropParameters(event, dragData, this.actor, this.objetVersConteneur)); diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js index 2db4466f..8413933b 100644 --- a/module/actor-vehicule-sheet.js +++ b/module/actor-vehicule-sheet.js @@ -58,10 +58,10 @@ export class RdDActorVehiculeSheet extends ActorSheet { formData.options.isGM = game.user.isGM; - formData.calc ={ + formData.calc = { encTotal: await this.actor.computeEncombrementTotalEtMalusArmure(), + surEncombrementMessage: this.actor.getMessageSurEncombrement() } - formData.calc.surEncombrementMessage = formData.calc.encTotal > formData.data.capacite_encombrement ? "Sur-Encombrement!" : "", console.log("DATA", formData); diff --git a/module/actor.js b/module/actor.js index 168019d3..b05ea40c 100644 --- a/module/actor.js +++ b/module/actor.js @@ -308,10 +308,6 @@ export class RdDActor extends Actor { return Math.floor(Misc.templateData(this).prixTotalEquipement ?? 0); } - /* -------------------------------------------- */ - getSurenc() { - return Misc.templateData(this).compteurs.surenc?.value ?? 0; - } /* -------------------------------------------- */ getCompetence(idOrName, options = {}) { return RdDItemCompetence.findCompetence(this.data.items, idOrName, options); @@ -1294,6 +1290,9 @@ export class RdDActor extends Actor { computeMalusSurEncombrement() { return Math.min(0, this.getEncombrementMax() - Math.ceil(Number(this.getEncTotal()))); } + getMessageSurEncombrement(){ + return this.computeMalusSurEncombrement() <0 ? "Sur-Encombrement!" : ""; + } getEncombrementMax() { return (this.data.type == 'vehicule') diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 243d5b6a..41c38ff5 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -51,7 +51,7 @@ export class RdDRoll extends Dialog { diffLibre: rollData.competence?.data.default_diffLibre ?? 0, malusArmureValue: actor.getMalusArmure(), surencMalusFlag: actor.isPersonnage() ? (actorData.data.compteurs.surenc.value < 0) : false, - surencMalusValue: actor.getSurenc(), + surencMalusValue: actor.computeMalusSurEncombrement(), useMalusSurenc: false, useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associƩe. */ perteMoralEchec: false, /* Pour l'affichage dans le chat */ diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index ea72ec0a..752b2c84 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -71,7 +71,7 @@ export const referenceAjustements = { isVisible: (rollData, actor) => rollData.useMalusSurenc, isUsed: (rollData, actor) => rollData.useMalusSurenc, getLabel: (rollData, actor) => 'Sur-encombrement', - getValue: (rollData, actor) => actor.getSurenc() + getValue: (rollData, actor) => actor.computeMalusSurEncombrement() }, moral: { isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.useMoral,