From 9750d42bb8ebf2670d2ba813b7dee11b0da0f3e5 Mon Sep 17 00:00:00 2001 From: sdn-br <57860539+sdn-br@users.noreply.github.com> Date: Tue, 9 Mar 2021 18:57:43 +0100 Subject: [PATCH] Update kits.js fix for [#1536](https://github.com/dsiekiera/foe-helfer-extension/issues/1536) --- js/web/kits/js/kits.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/web/kits/js/kits.js b/js/web/kits/js/kits.js index f0a7ed82e..8ed97509c 100644 --- a/js/web/kits/js/kits.js +++ b/js/web/kits/js/kits.js @@ -408,7 +408,13 @@ let Kits = { for (let i in MainParser.Inventory) { if (!MainParser.Inventory.hasOwnProperty(i)) continue; - Ret.push(MainParser.Inventory[i]); + let itemIdx = Ret.findIndex(e => e["itemAssetName"] == MainParser.Inventory[i]["itemAssetName"]); + + if (itemIdx > -1) { + Ret[itemIdx]["inStock"] += MainParser.Inventory[i]["inStock"]; + } else { + Ret.push(Object.assign({}, MainParser.Inventory[i])); + } } return Ret; @@ -441,4 +447,4 @@ FoEproxy.addMetaHandler('selection_kits', (xhr, postData) => { FoEproxy.addMetaHandler('building_sets', (xhr, postData) => { Kits.BuildingSets = JSON.parse(xhr.responseText); -}); \ No newline at end of file +});