diff --git a/ChangeLog.md b/ChangeLog.md index 62b69b9a..7b4c7da5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,7 @@ #2.2.11 * Add help system and initial help file * Make absolute damage visible + * Add 'average' roll for blueprints #2.2.10 * Fix detailed export of module reinforcement packages diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 1e05deaa..3e0f558d 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -31,6 +31,7 @@ export default class ModificationsMenu extends TranslatedComponent { this._toggleBlueprintsMenu = this._toggleBlueprintsMenu.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._reset = this._reset.bind(this); } @@ -133,6 +134,34 @@ 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.features[m.blueprint.grade]; + 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); + } + } + } + + this.setState({ modifications: this._setModifications(this.props) }); + this.props.onChange(); + } + /** * Provide a random roll within the information we have */ @@ -215,6 +244,7 @@ export default class ModificationsMenu extends TranslatedComponent { const _toggleBlueprintsMenu = this._toggleBlueprintsMenu; const _rollBest = this._rollBest; const _rollWorst = this._rollWorst; + const _rollAverage = this._rollAverage; const _rollRandom = this._rollRandom; const _reset = this._reset; @@ -241,8 +271,9 @@ export default class ModificationsMenu extends TranslatedComponent {