From ab4c118d12b3250449b14c7bbacc495dfda51717 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 2 Feb 2023 00:53:20 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20Sustentation=20consomm=C3=A9e=20parfois?= =?UTF-8?q?=20concat=C3=A9n=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/module/actor.js b/module/actor.js index 18bfd7b5..6c8be21a 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1722,16 +1722,17 @@ export class RdDActor extends RdDBaseActor { async manger(item, doses, options = { diminuerQuantite: true }) { const sust = item.system.sust if (sust > 0) { - await this.updateCompteurValue('sust', Misc.keepDecimals(this.system.compteurs.sust.value + sust * doses, 1)); + await this.updateCompteurValue('sust', RdDActor.$calculNewSust(this.system.compteurs.sust.value, sust, doses)); } await item.diminuerQuantite(doses, options); } + /* -------------------------------------------- */ async boire(item, doses, options = { diminuerQuantite: true }) { const desaltere = item.system.desaltere; if (desaltere > 0) { - await this.updateCompteurValue('eau', Misc.keepDecimals(this.system.compteurs.eau.value + desaltere * doses, 1)); + await this.updateCompteurValue('eau', RdDActor.$calculNewSust(this.system.compteurs.eau.value, desaltere, doses)); } if (item.isAlcool()) { for (let i = 0; i < doses; i++) { @@ -1740,6 +1741,10 @@ export class RdDActor extends RdDBaseActor { } await item.diminuerQuantite(doses, options); } + + static $calculNewSust(value, sust, doses) { + return Misc.keepDecimals(Number(value) + Number(sust) * Number(doses), 1); + } /* -------------------------------------------- */ async saouler(forceAlcool, alcool = undefined) {