diff --git a/ChangeLog.md b/ChangeLog.md index 4841ab12..0b03097a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,7 +9,7 @@ * Fix issue with miner role where refinery would not be present in ships with class 5 slots but no class 4 * Ensure that boost value is set correctly when modifications to power distributor enable/disable boost * Ensure that hull reinforcement modifications take the inherent resistance in to account when calculating modification percentages - * Add tooltip for blueprints providing details of the features they alter + * Add tooltip for blueprints providing details of the features they alter, the components required for the blueprint and the engineer(s) who cam craft them * Use opponent's saved pips if available * Ignore rounds per shot for EPS and HPS calculations; it's already factored in to the numbers * Ensure that clip size modification imports result in whole numbers diff --git a/src/app/components/HardpointSlot.jsx b/src/app/components/HardpointSlot.jsx index ca76bd80..2dd96bb3 100644 --- a/src/app/components/HardpointSlot.jsx +++ b/src/app/components/HardpointSlot.jsx @@ -55,7 +55,7 @@ export default class HardpointSlot extends Slot { modTT = (
{modTT}
- {blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], m)} + {blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], null, m)}
); } diff --git a/src/app/components/InternalSlot.jsx b/src/app/components/InternalSlot.jsx index fad3e2cf..12cfe0aa 100644 --- a/src/app/components/InternalSlot.jsx +++ b/src/app/components/InternalSlot.jsx @@ -34,7 +34,7 @@ export default class InternalSlot extends Slot { modTT = (
{modTT}
- {blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], m)} + {blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], null, m)}
); } diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index 108bf578..3a8a19ed 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -50,11 +50,11 @@ export default class ModificationsMenu extends TranslatedComponent { // Set up the blueprints let blueprints = []; for (const blueprintName in Modifications.modules[m.grp].blueprints) { - for (const grade of Modifications.modules[m.grp].blueprints[blueprintName]) { + for (const grade in Modifications.modules[m.grp].blueprints[blueprintName].grades) { const close = this._blueprintSelected.bind(this, blueprintName, grade); const key = blueprintName + ':' + grade; const blueprint = getBlueprint(blueprintName, m); - const tooltipContent = blueprintTooltip(translate, blueprint.grades[grade]); + const tooltipContent = blueprintTooltip(translate, blueprint.grades[grade], Modifications.modules[m.grp].blueprints[blueprintName].grades[grade].engineers); blueprints.push(
{translate(blueprint.name + ' grade ' + grade)}
); } } @@ -279,7 +279,7 @@ export default class ModificationsMenu extends TranslatedComponent { if (m.blueprint && !isEmpty(m.blueprint)) { blueprintLabel = translate(m.blueprint.name) + ' ' + translate('grade') + ' ' + m.blueprint.grade; haveBlueprint = true; - blueprintTt = blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade]); + blueprintTt = blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], Modifications.modules[m.grp].blueprints[m.blueprint.fdname].grades[m.blueprint.grade].engineers); } let specialLabel; diff --git a/src/app/components/StandardSlot.jsx b/src/app/components/StandardSlot.jsx index effc1480..eabaa353 100644 --- a/src/app/components/StandardSlot.jsx +++ b/src/app/components/StandardSlot.jsx @@ -57,7 +57,7 @@ export default class StandardSlot extends TranslatedComponent { modTT = (
{modTT}
- {blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], m)} + {blueprintTooltip(translate, m.blueprint.grades[m.blueprint.grade], null, m)}
); } diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index f5f42dc6..ef2dde0b 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -5,10 +5,11 @@ import { Modifications } from 'coriolis-data/dist'; * Generate a tooltip with details of a blueprint's effects * @param {Object} translate The translate object * @param {Object} blueprint The blueprint at the required grade + * @param {Array} engineers The engineers supplying this blueprint * @param {Object} m The module to compare with * @returns {Object} The react components */ -export function blueprintTooltip(translate, blueprint, m) { +export function blueprintTooltip(translate, blueprint, engineers, m) { const effects = []; for (const feature in blueprint.features) { const featureIsBeneficial = isBeneficial(feature, blueprint.features[feature]); @@ -33,7 +34,9 @@ export function blueprintTooltip(translate, blueprint, m) { let current = m.getModValue(feature); if (featureDef.type === 'percentage' || featureDef.name === 'burst' || featureDef.name === 'burstrof') { current = Math.round(current / 10) / 10; - } + } else if (featureDef.type === 'numeric') { + current /= 100; + } const currentIsBeneficial = isValueBeneficial(feature, current); effects.push( @@ -55,43 +58,96 @@ export function blueprintTooltip(translate, blueprint, m) { } } } + if (m) { + // Because we have a module add in any benefits that aren't part of the primary blueprint + for (const feature in m.mods) { + if (!blueprint.features[feature]) { + const featureDef = Modifications.modifications[feature]; + let symbol = ''; + if (feature === 'jitter') { + symbol = '°'; + } else if (featureDef.type === 'percentage') { + symbol = '%'; + } + let current = m.getModValue(feature); + if (featureDef.type === 'percentage' || featureDef.name === 'burst' || featureDef.name === 'burstrof') { + current = Math.round(current / 10) / 10; + } else if (featureDef.type === 'numeric') { + current /= 100; + } + const currentIsBeneficial = isValueBeneficial(feature, current); + effects.push( + + {translate(feature)} +   + {current}{symbol} +   + + ); + } + } + } + let components; + if (!m) { + components = []; + for (const component in blueprint.components) { + components.push( + + {translate(component)} + {blueprint.components[component]} + + ); + } + } - const components = []; - for (const component in blueprint.components) { - components.push( - - {translate(component)} - {blueprint.components[component]} - - ); + let engineersList; + if (engineers) { + engineersList = []; + for (const engineer of engineers) { + engineersList.push( + + {engineer} + + ); + } } return (
- - - - - - {m ? : null } - - - - - {effects} - -
{translate('feature')}{translate('worst')}{translate('current')}{translate('best')}
- { m ? null : - - - - - - - - {components} - -
{translate('component')}{translate('amount')}
} + + + + + + {m ? : null } + + + + + {effects} + +
{translate('feature')}{translate('worst')}{translate('current')}{translate('best')}
+ { components ? + + + + + + + + {components} + +
{translate('component')}{translate('amount')}
: null } + { engineersList ? + + + + + + + {engineersList} + +
{translate('engineers')}
: null }
); } diff --git a/src/app/utils/SlotFunctions.js b/src/app/utils/SlotFunctions.js index cca7eb1e..8a57e63e 100644 --- a/src/app/utils/SlotFunctions.js +++ b/src/app/utils/SlotFunctions.js @@ -243,7 +243,7 @@ export function diffDetails(language, m, mm) { } } - let mIntegrity = m.integrity; + let mIntegrity = m.integrity || 0; let mmIntegrity = mm ? mm.getIntegrity() || 0 : 0; if (mIntegrity != mmIntegrity) { propDiffs.push(
{translate('integrity')}: {diff(formats.round, mIntegrity, mmIntegrity)}
);