From bd2e6eaf510b98a19cacf9b55658b22ce6d0a300 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Sun, 2 Jun 2024 11:36:36 +0100 Subject: [PATCH] Fixed miscalculation of mats and got rid of unhelpful 'rolls' table, as the mats are calculated for the whole build and some blueprints may not be all the way up to g5. --- src/app/components/ModalShoppingList.jsx | 33 +++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/app/components/ModalShoppingList.jsx b/src/app/components/ModalShoppingList.jsx index 300e3332..d6b70e71 100644 --- a/src/app/components/ModalShoppingList.jsx +++ b/src/app/components/ModalShoppingList.jsx @@ -248,33 +248,36 @@ export default class ModalShoppingList extends TranslatedComponent { if (!module.m.blueprint.grade || !module.m.blueprint.grades) { continue; } - for (const g in module.m.blueprint.grades) { + for (let g in module.m.blueprint.grades) { if (!module.m.blueprint.grades.hasOwnProperty(g)) { continue; } - if (g > module.m.blueprint.grade) { + // Ignore grades higher than the grade selected + if (Number(g) > module.m.blueprint.grade) { continue; } - for (const i in module.m.blueprint.grades[g].components) { + for (let i in module.m.blueprint.grades[g].components) { if (!module.m.blueprint.grades[g].components.hasOwnProperty(i)) { continue; } + console.log("Grade: " + g + " Component: " + i + " Amount: " + module.m.blueprint.grades[g].components[i] + " Rolls: " + this.state.matsPerGrade[g]) if (mats[i]) { mats[i] += module.m.blueprint.grades[g].components[i] * this.state.matsPerGrade[g]; } else { mats[i] = module.m.blueprint.grades[g].components[i] * this.state.matsPerGrade[g]; } + console.log(mats[i]) } - if (module.m.blueprint.special) { - for (const j in module.m.blueprint.special.components) { - if (!module.m.blueprint.special.components.hasOwnProperty(j)) { - continue; - } - if (mats[j]) { - mats[j] += module.m.blueprint.special.components[j]; - } else { - mats[j] = module.m.blueprint.special.components[j]; - } + } + if (module.m.blueprint.special) { + for (const j in module.m.blueprint.special.components) { + if (!module.m.blueprint.special.components.hasOwnProperty(j)) { + continue; + } + if (mats[j]) { + mats[j] += module.m.blueprint.special.components[j]; + } else { + mats[j] = module.m.blueprint.special.components[j]; } } } @@ -332,7 +335,7 @@ export default class ModalShoppingList extends TranslatedComponent { this.sendToEDOMH = this.sendToEDOMH.bind(this); return
e.stopPropagation() }>

{translate('PHRASE_SHOPPING_MATS')}

- + {/*
@@ -345,7 +348,7 @@ export default class ModalShoppingList extends TranslatedComponent {
- + */}