diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index bca617fb..85083a2a 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -6,7 +6,7 @@ import { isEmpty, stopCtxPropagation } from '../utils/UtilityFunctions'; import cn from 'classnames'; import { Modifications } from 'coriolis-data/dist'; import Modification from './Modification'; -import { getBlueprint, blueprintTooltip, setWorst, setBest, setExtreme, setRandom } from '../utils/BlueprintFunctions'; +import { getBlueprint, blueprintTooltip, setPercent, setRandom } from '../utils/BlueprintFunctions'; /** * Modifications menu @@ -30,10 +30,10 @@ export default class ModificationsMenu extends TranslatedComponent { this._toggleBlueprintsMenu = this._toggleBlueprintsMenu.bind(this); this._toggleSpecialsMenu = this._toggleSpecialsMenu.bind(this); - this._rollWorst = this._rollWorst.bind(this); + this._rollFifty = this._rollFifty.bind(this); this._rollRandom = this._rollRandom.bind(this); this._rollBest = this._rollBest.bind(this); - this._rollExtreme = this._rollExtreme.bind(this); + this._rollSevenFive = this._rollSevenFive.bind(this); this._reset = this._reset.bind(this); this.state = { @@ -168,11 +168,11 @@ export default class ModificationsMenu extends TranslatedComponent { } /** - * Provide a 'worst' roll within the information we have + * Provide a '50%' roll within the information we have */ - _rollWorst() { + _rollFifty() { const { m, ship } = this.props; - setWorst(ship, m); + setPercent(ship, m, 50); this.props.onChange(); } @@ -190,16 +190,16 @@ export default class ModificationsMenu extends TranslatedComponent { */ _rollBest() { const { m, ship } = this.props; - setBest(ship, m); + setPercent(ship, m, 100); this.props.onChange(); } /** - * Provide an 'extreme' roll within the information we have + * Provide an '75%' roll within the information we have */ - _rollExtreme() { + _rollSevenFive() { const { m, ship } = this.props; - setExtreme(ship, m); + setPercent(ship, m, 75); this.props.onChange(); } @@ -226,9 +226,9 @@ export default class ModificationsMenu extends TranslatedComponent { const _toggleBlueprintsMenu = this._toggleBlueprintsMenu; const _toggleSpecialsMenu = this._toggleSpecialsMenu; - const _rollBest = this._rollBest; - const _rollExtreme = this._rollExtreme; - const _rollWorst = this._rollWorst; + const _rollFull = this._rollBest; + const _rollSevenFive = this._rollSevenFive; + const _rollFifty = this._rollFifty; const _rollRandom = this._rollRandom; const _reset = this._reset; @@ -275,9 +275,9 @@ export default class ModificationsMenu extends TranslatedComponent { { showRolls ? { translate('roll') }: - { translate('worst') } - { translate('best') } - { translate('extreme') } + { translate('50%') } + { translate('75%') } + { translate('100%') } { translate('random') } : null } { showReset ? diff --git a/src/app/i18n/en.json b/src/app/i18n/en.json index 8eb87450..ae9ecea7 100644 --- a/src/app/i18n/en.json +++ b/src/app/i18n/en.json @@ -16,6 +16,8 @@ "PHRASE_ENGAGEMENT_RANGE": "The distance between your ship and its target", "PHRASE_SELECT_BLUEPRINT": "Click to select a blueprint", "PHRASE_BLUEPRINT_WORST": "Worst primary values for this blueprint", + "PHRASE_BLUEPRINT_FIFTY": "50% of full values for this blueprint", + "PHRASE_BLUEPRINT_SEVEN_FIVE": "75% of full values for this blueprint", "PHRASE_BLUEPRINT_RANDOM": "Random selection between worst and best primary values for this blueprint", "PHRASE_BLUEPRINT_BEST": "Best primary values for this blueprint", "PHRASE_BLUEPRINT_EXTREME": "Best beneficial and worst detrimental primary values for this blueprint", diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index 10c84b55..69a8f97c 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -253,57 +253,19 @@ export function getBlueprint(name, module) { * Provide 'worst' primary modifications * @param {Object} ship The ship for which to perform the modifications * @param {Object} m The module for which to perform the modifications + * @param {Number} percent The percent to set values to of full. */ -export function setWorst(ship, m) { +export function setPercent(ship, m, percent) { ship.clearModifications(m); const features = m.blueprint.grades[m.blueprint.grade].features; for (const featureName in features) { const value = features[featureName][0]; - _setValue(ship, m, featureName, value); - } -} - -/** - * Provide 'best' primary modifications - * @param {Object} ship The ship for which to perform the modifications - * @param {Object} m The module for which to perform the modifications - */ -export function setBest(ship, m) { - ship.clearModifications(m); - const features = m.blueprint.grades[m.blueprint.grade].features; - for (const featureName in features) { - const value = features[featureName][1]; - _setValue(ship, m, featureName, value); - } -} - -/** - * Provide 'extreme' primary modifications - * @param {Object} ship The ship for which to perform the modifications - * @param {Object} m The module for which to perform the modifications - */ -export function setExtreme(ship, m) { - ship.clearModifications(m); - const features = m.blueprint.grades[m.blueprint.grade].features; - for (const featureName in features) { - let value; - if (Modifications.modifications[featureName].higherbetter) { - // Higher is better, but is this making it better or worse? - if (features[featureName][0] < 0 || (features[featureName][0] === 0 && features[featureName][1] < 0)) { - value = features[featureName][0]; - } else { - value = features[featureName][1]; - } + const featureIsBeneficial = isBeneficial(featureName, features[featureName]); + if (featureIsBeneficial === true) { + _setValue(ship, m, featureName, (percent / 100) * value); } else { - // Higher is worse, but is this making it better or worse? - if (features[featureName][0] < 0 || (features[featureName][0] === 0 && features[featureName][1] < 0)) { - value = features[featureName][1]; - } else { - value = features[featureName][0]; - } + _setValue(ship, m, featureName, value); } - - _setValue(ship, m, featureName, value); } }