diff --git a/src/app/components/HardpointSlot.jsx b/src/app/components/HardpointSlot.jsx index 0c5773a8..c9fc6ece 100644 --- a/src/app/components/HardpointSlot.jsx +++ b/src/app/components/HardpointSlot.jsx @@ -1,6 +1,8 @@ import React from 'react'; import Slot from './Slot'; -import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, Modifications } from './SvgIcons'; +import { DamageKinetic, DamageThermal, DamageExplosive, MountFixed, MountGimballed, MountTurret, ListModifications } from './SvgIcons'; +import { Modifications } from 'coriolis-data/dist'; + /** * Hardpoint / Utility Slot @@ -36,6 +38,7 @@ export default class HardpointSlot extends Slot { if (m) { let classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`; let { drag, drop } = this.props; + let validMods = Modifications.validity[m.grp] || []; return
@@ -59,7 +62,7 @@ export default class HardpointSlot extends Slot { { m.range && !m.dps ?
{translate('Range')} : {formats.round(m.range / 1000)}{u.km}
: null } { m.shieldmul ?
+{formats.rPct(m.shieldmul)}
: null } { m.ammo >= 0 ?
{translate('ammo')}: {formats.int(m.clip)}/{formats.int(m.ammo)}
: null } -
+ { validMods.length > 0 ?
: null }
; } else { diff --git a/src/app/components/InternalSlot.jsx b/src/app/components/InternalSlot.jsx index fa29f27c..6dcc25f3 100644 --- a/src/app/components/InternalSlot.jsx +++ b/src/app/components/InternalSlot.jsx @@ -1,6 +1,7 @@ import React from 'react'; import Slot from './Slot'; -import { Modifications } from './SvgIcons'; +import { ListModifications } from './SvgIcons'; +import { Modifications } from 'coriolis-data/dist'; /** * Internal Slot @@ -19,6 +20,7 @@ export default class InternalSlot extends Slot { if (m) { let classRating = m.class + m.rating; let { drag, drop } = this.props; + let validMods = Modifications.validity[m.grp] || []; return
@@ -42,7 +44,7 @@ export default class InternalSlot extends Slot { { m.rangeLS === null ?
∞{u.Ls}
: null } { m.rangeRating ?
{translate('range')}: {m.rangeRating}
: null } { m.armouradd ?
+{m.armouradd} {translate('armour')}
: null } -
+ { validMods.length > 0 ?
: null }
; } else { diff --git a/src/app/components/StandardSlot.jsx b/src/app/components/StandardSlot.jsx index c9fa45ea..94e177e4 100644 --- a/src/app/components/StandardSlot.jsx +++ b/src/app/components/StandardSlot.jsx @@ -4,8 +4,9 @@ import TranslatedComponent from './TranslatedComponent'; import { jumpRange } from '../shipyard/Calculations'; import { diffDetails } from '../utils/SlotFunctions'; import AvailableModulesMenu from './AvailableModulesMenu'; -import { Modifications } from './SvgIcons'; +import { ListModifications } from './SvgIcons'; import Slider from './Slider'; +import { Modifications } from 'coriolis-data/dist'; /** * Standard Slot @@ -33,6 +34,7 @@ export default class StandardSlot extends TranslatedComponent { let m = slot.m; let classRating = m.class + m.rating; let menu; + let validMods = m == null ? [] : (Modifications.validity[m.grp] || []); if (this.props.selected) { menu = {translate('WEP')}: {m.weaponcapacity}{units.MJ} / {m.weaponrecharge}{units.MW} : null } { m.systemcapacity ?
{translate('SYS')}: {m.systemcapacity}{units.MJ} / {m.systemrecharge}{units.MW}
: null } { m.enginecapacity ?
{translate('ENG')}: {m.enginecapacity}{units.MJ} / {m.enginerecharge}{units.MW}
: null } -
- -
- + { validMods.length > 0 ?
: null }
@@ -77,10 +76,12 @@ export default class StandardSlot extends TranslatedComponent { ); } + // {validMods.length > 0 ?
: null } /** * Update power usage modification given a slider value. * Note that this is a temporary function until we have a slider section + * @param {Number} value The value of the slider */ _updateSliderValue(value) { let m = this.props.slot.m; @@ -93,6 +94,7 @@ export default class StandardSlot extends TranslatedComponent { /** * Obtain slider value from a power usage modification. * Note that this is a temporary function until we have a slider section + * @return {Number} value The value of the slider */ _getSliderValue() { let m = this.props.slot.m; diff --git a/src/app/components/SvgIcons.jsx b/src/app/components/SvgIcons.jsx index 984415d1..50c13e16 100644 --- a/src/app/components/SvgIcons.jsx +++ b/src/app/components/SvgIcons.jsx @@ -489,9 +489,9 @@ export class Rocket extends SvgIcon { } /** - * Modifications (engineers) + * ListModifications (engineers) */ -export class Modifications extends SvgIcon { +export class ListModifications extends SvgIcon { /** * Overriden view box * @return {String} view box diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index acf666a0..d3377e6b 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -32,20 +32,20 @@ export default class Module { * @return {Number} The value of the modification, as a decimal value from -1 to 1 */ getModValue(modId) { - return this.mods ? this.mods[modId] / 100000 : null; + return this.mods ? this.mods[modId] / 10000 : null; } /** * Set a value for a given modification ID * @param {Number} modId The ID of the modification - * @param {Number} val The value of the modification, as a decimal value from -1 to 1 + * @param {Number} value The value of the modification, as a decimal value from -1 to 1 */ setModValue(modId, value) { if (value == null || value == 0) { delete this.mods[modId]; } else { - // Store value with 3dp - this.mods[modId] = Math.round(value * 100000); + // Store value with 2dp + this.mods[modId] = Math.round(value * 10000); } } diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 5905170a..36e6fe85 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -434,7 +434,7 @@ export default class Ship { this.bulkheads.m = null; this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true); - this.bulkheads.m.mods = mods && mods[0] ? mods[0] : {} + this.bulkheads.m.mods = mods && mods[0] ? mods[0] : {}; this.cargoHatch.priority = priorities ? priorities[0] * 1 : 0; this.cargoHatch.enabled = enabled ? enabled[0] * 1 : true; this.cargoHatch.mods = mods ? mods[0] : {}; @@ -896,8 +896,8 @@ export default class Ship { let bulkheadMods = new Array(); if (this.bulkheads.m && this.bulkheads.m.mods) { - for (var modKey in this.bulkheads.m.mods) { - bulkheadMods.push(modKey + ':' + Math.round(this.bulkheads.m.getModValue(modKey) * 100000)); + for (let modKey in this.bulkheads.m.mods) { + bulkheadMods.push(modKey + ':' + Math.round(this.bulkheads.m.getModValue(modKey) * 10000)); } } allMods.push(bulkheadMods.join(';')); @@ -905,8 +905,8 @@ export default class Ship { for (let slot of this.standard) { let slotMods = new Array(); if (slot.m && slot.m.mods) { - for (var modKey in slot.m.mods) { - slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 100000)); + for (let modKey in slot.m.mods) { + slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 10000)); } } allMods.push(slotMods.join(';')); @@ -914,8 +914,8 @@ export default class Ship { for (let slot of this.hardpoints) { let slotMods = new Array(); if (slot.m && slot.m.mods) { - for (var modKey in slot.m.mods) { - slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 100000)); + for (let modKey in slot.m.mods) { + slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 10000)); } } allMods.push(slotMods.join(';')); @@ -923,8 +923,8 @@ export default class Ship { for (let slot of this.internal) { let slotMods = new Array(); if (slot.m && slot.m.mods) { - for (var modKey in slot.m.mods) { - slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 100000)); + for (let modKey in slot.m.mods) { + slotMods.push(modKey + ':' + Math.round(slot.m.getModValue(modKey) * 10000)); } } allMods.push(slotMods.join(';'));