From 45852db5077fb38587d17c112df84ebabe20b74a Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Sat, 11 Feb 2017 19:57:46 +0000 Subject: [PATCH] Add 'Extreme' roll --- ChangeLog.md | 1 + src/app/components/ModificationsMenu.jsx | 55 +++++++++++++----------- src/app/i18n/en.js | 3 +- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index a3e42176..f15a156e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ * Ensure that standard slots are repainted when any component changes * Reload page if Safari throws a security error * Handle import of ships with incorrectly-sized slots + * Add 'Extreme' blueprint roll: best beneficial and worst detrimental outcome (in place of 'Average' roll) #2.2.14 * Ensure that jitter is shown correctly when the result of a special effect diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 02267b0e..facdd9c9 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -32,8 +32,8 @@ export default class ModificationsMenu extends TranslatedComponent { this._toggleSpecialsMenu = this._toggleSpecialsMenu.bind(this); this._rollWorst = this._rollWorst.bind(this); this._rollRandom = this._rollRandom.bind(this); - this._rollAverage = this._rollAverage.bind(this); this._rollBest = this._rollBest.bind(this); + this._rollExtreme = this._rollExtreme.bind(this); this._reset = this._reset.bind(this); } @@ -185,20 +185,6 @@ export default class ModificationsMenu extends TranslatedComponent { this.props.onChange(); } - /** - * Provide an 'average' roll within the information we have - */ - _rollAverage() { - const { m, ship } = this.props; - const features = m.blueprint.grades[m.blueprint.grade].features; - for (const featureName in features) { - 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(); - } - /** * Provide a random roll within the information we have */ @@ -227,6 +213,20 @@ export default class ModificationsMenu extends TranslatedComponent { this.props.onChange(); } + /** + * Provide an 'extreme' roll within the information we have + */ + _rollExtreme() { + const { m, ship } = this.props; + const features = m.blueprint.grades[m.blueprint.grade].features; + for (const featureName in features) { + const value = Math.abs(features[featureName][0]) < Math.abs(features[featureName][1]) ? features[featureName][1] : features[featureName][0]; + this._setRollResult(ship, m, featureName, value); + } + this.setState({ modifications: this._setModifications(this.props) }); + this.props.onChange(); + } + /** * Reset modification information */ @@ -252,8 +252,8 @@ 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 _rollAverage = this._rollAverage; const _rollRandom = this._rollRandom; const _reset = this._reset; @@ -278,6 +278,7 @@ export default class ModificationsMenu extends TranslatedComponent { const showSpecial = haveBlueprint && this.state.specials.length > 0; const showSpecialsMenu = specialMenuOpened; const showRolls = haveBlueprint && !blueprintMenuOpened && !specialMenuOpened; + const showReset = !blueprintMenuOpened && !specialMenuOpened; const showMods = !blueprintMenuOpened && !specialMenuOpened; return ( @@ -287,26 +288,30 @@ export default class ModificationsMenu extends TranslatedComponent { onContextMenu={stopCtxPropagation} >
{blueprintLabel}
- { showBlueprintsMenu ? this.state.blueprints : '' } - { showSpecial ?
{specialLabel}
: '' } - { showSpecialsMenu ? this.state.specials : '' } - { showRolls ? + { showBlueprintsMenu ? this.state.blueprints : null } + { showSpecial ?
{specialLabel}
: null } + { showSpecialsMenu ? this.state.specials : null } + { showRolls || showReset ? + { showRolls ? - + - - + : null } + { showReset ? + + + : null } -
{ translate('roll') }: { translate('worst') } { translate('average') } { translate('best') } { translate('extreme') } { translate('random') } { translate('reset') }
{ translate('reset') }
: '' } + : null } { showMods ? { this.state.modifications } - : '' } + : null } ); } diff --git a/src/app/i18n/en.js b/src/app/i18n/en.js index 86b56bf8..e4979ff1 100644 --- a/src/app/i18n/en.js +++ b/src/app/i18n/en.js @@ -31,9 +31,9 @@ export const terms = { 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_AVERAGE: 'Average primary 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', PHRASE_BLUEPRINT_RESET: 'Remove all modifications and blueprint', PHRASE_SELECT_SPECIAL: 'Click to select an experimental effect', PHRASE_NO_SPECIAL: 'No experimental effect', @@ -115,6 +115,7 @@ export const terms = { average: 'Average', random: 'Random', best: 'Best', + extreme: 'Extreme', reset: 'Reset', // Weapon, offence, defence and movement