change preset rolls to 100%, 75%, 50% and random

This commit is contained in:
willyb321
2018-04-21 11:03:23 +10:00
parent 53f62f96d0
commit e391b563fb
3 changed files with 24 additions and 60 deletions

View File

@@ -6,7 +6,7 @@ import { isEmpty, stopCtxPropagation } from '../utils/UtilityFunctions';
import cn from 'classnames'; import cn from 'classnames';
import { Modifications } from 'coriolis-data/dist'; import { Modifications } from 'coriolis-data/dist';
import Modification from './Modification'; import Modification from './Modification';
import { getBlueprint, blueprintTooltip, setWorst, setBest, setExtreme, setRandom } from '../utils/BlueprintFunctions'; import { getBlueprint, blueprintTooltip, setPercent, setRandom } from '../utils/BlueprintFunctions';
/** /**
* Modifications menu * Modifications menu
@@ -30,10 +30,10 @@ export default class ModificationsMenu extends TranslatedComponent {
this._toggleBlueprintsMenu = this._toggleBlueprintsMenu.bind(this); this._toggleBlueprintsMenu = this._toggleBlueprintsMenu.bind(this);
this._toggleSpecialsMenu = this._toggleSpecialsMenu.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._rollRandom = this._rollRandom.bind(this);
this._rollBest = this._rollBest.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._reset = this._reset.bind(this);
this.state = { 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; const { m, ship } = this.props;
setWorst(ship, m); setPercent(ship, m, 50);
this.props.onChange(); this.props.onChange();
} }
@@ -190,16 +190,16 @@ export default class ModificationsMenu extends TranslatedComponent {
*/ */
_rollBest() { _rollBest() {
const { m, ship } = this.props; const { m, ship } = this.props;
setBest(ship, m); setPercent(ship, m, 100);
this.props.onChange(); 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; const { m, ship } = this.props;
setExtreme(ship, m); setPercent(ship, m, 75);
this.props.onChange(); this.props.onChange();
} }
@@ -226,9 +226,9 @@ export default class ModificationsMenu extends TranslatedComponent {
const _toggleBlueprintsMenu = this._toggleBlueprintsMenu; const _toggleBlueprintsMenu = this._toggleBlueprintsMenu;
const _toggleSpecialsMenu = this._toggleSpecialsMenu; const _toggleSpecialsMenu = this._toggleSpecialsMenu;
const _rollBest = this._rollBest; const _rollFull = this._rollBest;
const _rollExtreme = this._rollExtreme; const _rollSevenFive = this._rollSevenFive;
const _rollWorst = this._rollWorst; const _rollFifty = this._rollFifty;
const _rollRandom = this._rollRandom; const _rollRandom = this._rollRandom;
const _reset = this._reset; const _reset = this._reset;
@@ -275,9 +275,9 @@ export default class ModificationsMenu extends TranslatedComponent {
{ showRolls ? { showRolls ?
<tr> <tr>
<td> { translate('roll') }: </td> <td> { translate('roll') }: </td>
<td style={{ cursor: 'pointer' }} onClick={_rollWorst} onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_WORST')} onMouseOut={tooltip.bind(null, null)}> { translate('worst') } </td> <td style={{ cursor: 'pointer' }} onClick={_rollFifty} onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_FIFTY')} onMouseOut={tooltip.bind(null, null)}> { translate('50%') } </td>
<td style={{ cursor: 'pointer' }} onClick={_rollBest}onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_BEST')} onMouseOut={tooltip.bind(null, null)}> { translate('best') } </td> <td style={{ cursor: 'pointer' }} onClick={_rollSevenFive} onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_SEVEN_FIVE')} onMouseOut={tooltip.bind(null, null)}> { translate('75%') } </td>
<td style={{ cursor: 'pointer' }} onClick={_rollExtreme}onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_EXTREME')} onMouseOut={tooltip.bind(null, null)}> { translate('extreme') } </td> <td style={{ cursor: 'pointer' }} onClick={_rollFull} onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_BEST')} onMouseOut={tooltip.bind(null, null)}> { translate('100%') } </td>
<td style={{ cursor: 'pointer' }} onClick={_rollRandom} onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_RANDOM')} onMouseOut={tooltip.bind(null, null)}> { translate('random') } </td> <td style={{ cursor: 'pointer' }} onClick={_rollRandom} onMouseOver={termtip.bind(null, 'PHRASE_BLUEPRINT_RANDOM')} onMouseOut={tooltip.bind(null, null)}> { translate('random') } </td>
</tr> : null } </tr> : null }
{ showReset ? { showReset ?

View File

@@ -16,6 +16,8 @@
"PHRASE_ENGAGEMENT_RANGE": "The distance between your ship and its target", "PHRASE_ENGAGEMENT_RANGE": "The distance between your ship and its target",
"PHRASE_SELECT_BLUEPRINT": "Click to select a blueprint", "PHRASE_SELECT_BLUEPRINT": "Click to select a blueprint",
"PHRASE_BLUEPRINT_WORST": "Worst primary values for this 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_RANDOM": "Random selection between worst and best primary values for this blueprint",
"PHRASE_BLUEPRINT_BEST": "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_EXTREME": "Best beneficial and worst detrimental primary values for this blueprint",

View File

@@ -253,57 +253,19 @@ export function getBlueprint(name, module) {
* Provide 'worst' primary modifications * Provide 'worst' primary modifications
* @param {Object} ship The ship for which to perform the modifications * @param {Object} ship The ship for which to perform the modifications
* @param {Object} m The module 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); ship.clearModifications(m);
const features = m.blueprint.grades[m.blueprint.grade].features; const features = m.blueprint.grades[m.blueprint.grade].features;
for (const featureName in features) { for (const featureName in features) {
const value = features[featureName][0]; const value = features[featureName][0];
_setValue(ship, m, featureName, value); const featureIsBeneficial = isBeneficial(featureName, features[featureName]);
} if (featureIsBeneficial === true) {
} _setValue(ship, m, featureName, (percent / 100) * 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];
}
} else { } else {
// Higher is worse, but is this making it better or worse? _setValue(ship, m, featureName, value);
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);
} }
} }