From 191e31ff1834fc5ec6dead2afa8929ab831e94dc Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Sun, 5 Feb 2017 15:38:04 +0000 Subject: [PATCH 1/2] Use new-style blueprint data; fix numeric special effect calculations --- ChangeLog.md | 4 ++++ src/app/components/ModificationsMenu.jsx | 8 ++++---- src/app/shipyard/Module.js | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index e3d5949c..36cd33e0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +#2.2.14 + * Ensure that jitter is shown correctly when the result of a special effect + * Use restyled blueprint information + #2.2.13 * Add 'time to drain' summary value. This is the time to drain the WEP capacitor if firing all enabled weapons * Do not include utility slot DPS/EPS/HPS in summary information diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index ee662e8f..0ba1caeb 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -152,7 +152,7 @@ export default class ModificationsMenu extends TranslatedComponent { */ _rollWorst() { const { m, ship } = this.props; - const features = m.blueprint.features[m.blueprint.grade]; + const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { if (Modifications.modifications[featureName].method == 'overwrite') { ship.setModification(m, featureName, features[featureName][1]); @@ -180,7 +180,7 @@ export default class ModificationsMenu extends TranslatedComponent { */ _rollAverage() { const { m, ship } = this.props; - const features = m.blueprint.features[m.blueprint.grade]; + const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { if (Modifications.modifications[featureName].method == 'overwrite') { ship.setModification(m, featureName, (features[featureName][0] + features[featureName][1]) / 2); @@ -208,7 +208,7 @@ export default class ModificationsMenu extends TranslatedComponent { */ _rollRandom() { const { m, ship } = this.props; - const features = m.blueprint.features[m.blueprint.grade]; + const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { if (Modifications.modifications[featureName].method == 'overwrite') { ship.setModification(m, featureName, features[featureName][1]); @@ -236,7 +236,7 @@ export default class ModificationsMenu extends TranslatedComponent { */ _rollBest() { const { m, ship } = this.props; - const features = m.blueprint.features[m.blueprint.grade]; + const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { if (Modifications.modifications[featureName].method == 'overwrite') { ship.setModification(m, featureName, features[featureName][1]); diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index b47dec02..7f357f51 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -60,7 +60,8 @@ export default class Module { } else { mod = modifierActions[name]; } - result = (((1 + result / 10000) * (1 + mod)) - 1) * 10000; + const multiplier = modification.type === 'percentage' ? 10000 : 100; + result = (((1 + result / multiplier) * (1 + mod)) - 1) * multiplier; } } } From 6e71f5e6db8b21f487abeb6e6d5390b56a4e80ce Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Wed, 8 Feb 2017 09:24:13 +0000 Subject: [PATCH 2/2] Use ship name rather than model if possible --- ChangeLog.md | 1 + src/app/components/ModificationsMenu.jsx | 98 ++++++++---------------- src/app/pages/OutfittingPage.jsx | 2 +- 3 files changed, 35 insertions(+), 66 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 36cd33e0..e443f042 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,7 @@ #2.2.14 * Ensure that jitter is shown correctly when the result of a special effect * Use restyled blueprint information + * Use the ship name (if available) rather than the ship model for the window title #2.2.13 * Add 'time to drain' summary value. This is the time to drain the WEP capacitor if firing all enabled weapons diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 0ba1caeb..02267b0e 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -87,7 +87,7 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, onChange, ship } = props; let modifications = []; for (const modName of Modifications.modules[m.grp].modifications) { - if (Modifications.modifications[modName].type === 'percentage' || Modifications.modifications[modName].type === 'numeric') { + if (!Modifications.modifications[modName].hidden) { const key = modName + (m.getModValue(modName) / 100 || 0); modifications.push(); } @@ -147,6 +147,30 @@ export default class ModificationsMenu extends TranslatedComponent { this.props.onChange(); } + /** + * Set the result of a roll + * @param {object} ship The ship to which the roll applies + * @param {object} m The module to which the roll applies + * @param {string} featureName The modification feature to which the roll applies + * @param {number} value The value of the roll + */ + _setRollResult(ship, m, featureName, value) { + if (Modifications.modifications[featureName].method !== 'overwrite') { + if (m.grp == 'sb' && featureName == 'shieldboost') { + // 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') { + ship.setModification(m, featureName, value * 100); + } else { + ship.setModification(m, featureName, value); + } + } + /** * Provide a 'worst' roll within the information we have */ @@ -154,23 +178,9 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { - if (Modifications.modifications[featureName].method == 'overwrite') { - ship.setModification(m, featureName, features[featureName][1]); - } else { - let value = features[featureName][0]; - if (m.grp == 'sb' && featureName == 'shieldboost') { - // 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') { - ship.setModification(m, featureName, value * 100); - } - } + let value = features[featureName][0]; + this._setRollResult(ship, m, featureName, value); } - this.setState({ modifications: this._setModifications(this.props) }); this.props.onChange(); } @@ -182,23 +192,9 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { - if (Modifications.modifications[featureName].method == 'overwrite') { - ship.setModification(m, featureName, (features[featureName][0] + features[featureName][1]) / 2); - } else { - let value = (features[featureName][0] + features[featureName][1]) / 2; - if (m.grp == 'sb' && featureName == 'shieldboost') { - // 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') { - ship.setModification(m, featureName, value * 100); - } - } + let value = (features[featureName][0] + features[featureName][1]) / 2; + this._setRollResult(ship, m, featureName, value); } - this.setState({ modifications: this._setModifications(this.props) }); this.props.onChange(); } @@ -210,23 +206,9 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { - if (Modifications.modifications[featureName].method == 'overwrite') { - ship.setModification(m, featureName, features[featureName][1]); - } else { - let value = features[featureName][0] + (Math.random() * (features[featureName][1] - features[featureName][0])); - if (m.grp == 'sb' && featureName == 'shieldboost') { - // 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') { - ship.setModification(m, featureName, value * 100); - } - } + let value = features[featureName][0] + (Math.random() * (features[featureName][1] - features[featureName][0])); + this._setRollResult(ship, m, featureName, value); } - this.setState({ modifications: this._setModifications(this.props) }); this.props.onChange(); } @@ -238,23 +220,9 @@ export default class ModificationsMenu extends TranslatedComponent { const { m, ship } = this.props; const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { - if (Modifications.modifications[featureName].method == 'overwrite') { - ship.setModification(m, featureName, features[featureName][1]); - } else { - let value = features[featureName][1]; - if (m.grp == 'sb' && featureName == 'shieldboost') { - // 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') { - ship.setModification(m, featureName, value * 100); - } - } + let value = features[featureName][1]; + this._setRollResult(ship, m, featureName, value); } - this.setState({ modifications: this._setModifications(this.props) }); this.props.onChange(); } diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index e2345fbc..95547a95 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -36,7 +36,7 @@ const SPEED_COLORS = ['#0088d2', '#ff8c0d', '#D26D00', '#c06400']; * @return {String} Document title */ function getTitle(shipName, buildName) { - return `${shipName}${buildName ? ` - ${buildName}` : ''}`; + return buildName ? buildName : shipName; } /**