From fd404b5155c6260b85e0830f676a97cd65ef5a12 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Sun, 22 Jan 2017 10:59:36 +0000 Subject: [PATCH] Handle heavy duty shield booster special modification value --- src/app/components/ModificationsMenu.jsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index a15114d9..d2de4f32 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -111,7 +111,12 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.features[m.blueprint.grade]; for (const featureName in features) { - const value = features[featureName][0]; + let value = features[featureName][0]; + if (m.grp == 'sb') { + // Shield boosters are a special case. Their boost is dependent on their base so we need to calculate the value here + value = ((1 + m.shieldboost)*(1 + value) - 1) / m.shieldboost - 1 + } + if (Modifications.modifications[featureName].type == 'percentage') { ship.setModification(m, featureName, value * 10000); } else if (Modifications.modifications[featureName].type == 'numeric') { @@ -130,7 +135,12 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.features[m.blueprint.grade]; for (const featureName in features) { - const value = features[featureName][0] + (Math.random() * (features[featureName][1] - features[featureName][0])); + let value = features[featureName][0] + (Math.random() * (features[featureName][1] - features[featureName][0])); + if (m.grp == 'sb') { + // Shield boosters are a special case. Their boost is dependent on their base so we need to calculate the value here + value = ((1 + m.shieldboost)*(1 + value) - 1) / m.shieldboost - 1 + } + if (Modifications.modifications[featureName].type == 'percentage') { ship.setModification(m, featureName, value * 10000); } else if (Modifications.modifications[featureName].type == 'numeric') { @@ -149,7 +159,12 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.features[m.blueprint.grade]; for (const featureName in features) { - const value = features[featureName][1]; + let value = features[featureName][1]; + if (m.grp == 'sb') { + // Shield boosters are a special case. Their boost is dependent on their base so we need to calculate the value here + value = ((1 + m.shieldboost)*(1 + value) - 1) / m.shieldboost - 1 + } + if (Modifications.modifications[featureName].type == 'percentage') { ship.setModification(m, featureName, value * 10000); } else if (Modifications.modifications[featureName].type == 'numeric') {