From 3e5e745067e7ae2170ef6672b9296fd21e778079 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 8 Apr 2021 20:37:11 +0200 Subject: [PATCH] Les monnaies ont de la valeur et enc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RĂ©sout un pb de NaN sur enc total --- module/item.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/module/item.js b/module/item.js index 5bf3e624..5c94099f 100644 --- a/module/item.js +++ b/module/item.js @@ -1,7 +1,7 @@ import { Misc } from "./misc.js"; import { RdDUtility } from "./rdd-utility.js"; -const typesObjetsEquipement = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "nourritureboisson"]; +const typesObjetsEquipement = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "nourritureboisson", "monnaie"]; const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"]; /* -------------------------------------------- */ export class RdDItem extends Item { @@ -15,15 +15,19 @@ export class RdDItem extends Item { prepareDerivedData() { super.prepareDerivedData(); const itemData = this.data; - const tplData = itemData.data; if (RdDItem.getTypeObjetsEquipement().includes(itemData.type)) { - const quantite = itemData.type == 'conteneur' ? 1 : (tplData.quantite ?? 0); - if (tplData.encombrement != undefined) { - tplData.encTotal = Math.max(tplData.encombrement, 0) * quantite; - } - if (tplData.cout != undefined) { - tplData.prixTotal = Math.max(tplData.cout, 0) * quantite; - } + this._calculsEquipement(itemData); + } + } + + _calculsEquipement(itemData) { + const tplData = itemData.data; + const quantite = itemData.type == 'conteneur' ? 1 : (tplData.quantite ?? 0); + if (tplData.encombrement != undefined) { + tplData.encTotal = Math.max(tplData.encombrement, 0) * quantite; + } + if (tplData.cout != undefined) { + tplData.prixTotal = Math.max(tplData.cout, 0) * quantite; } }