diff --git a/src/app/components/ModalImport.jsx b/src/app/components/ModalImport.jsx index b698a9d9..9d5f4ff6 100644 --- a/src/app/components/ModalImport.jsx +++ b/src/app/components/ModalImport.jsx @@ -346,6 +346,7 @@ export default class ModalImport extends TranslatedComponent { } } } catch (e) { + // console.log(e.stack); this.setState({ errorMsg: (typeof e == 'string') ? e : 'Cannot Parse the data!' }); return; } diff --git a/src/app/components/Modification.jsx b/src/app/components/Modification.jsx index 6a1464d4..b6a6aea0 100644 --- a/src/app/components/Modification.jsx +++ b/src/app/components/Modification.jsx @@ -63,9 +63,24 @@ export default class Modification extends TranslatedComponent { let translate = this.context.language.translate; let name = this.props.name; + if (name === 'type') { + // We don't show type + return null; + } + + var symbol; + if (name === 'jitter') { + symbol = '°'; + } else if (name !== 'burst') { + symbol = '%'; + } + if (symbol) { + symbol = ' (' + symbol + ')'; + } + return (
-
{translate(name)}{name === 'jitter' ? ' (°)' : ' (%)'}
+
{translate(name)}{symbol}
); diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index 72a1ec1f..d20a2cf9 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -1,5 +1,6 @@ import * as ModuleUtils from './ModuleUtils'; import * as _ from 'lodash'; +import { Modifications } from 'coriolis-data/dist'; /** * Module - active module in a ship's buildout @@ -65,8 +66,20 @@ export default class Module { _getModifiedValue(name, additive) { let result = this[name] || (additive ? 0 : null); // Additive NULL === 0 if (result != null) { - // Jitter is special, being the only non-percentage value (it is in fact degrees) - const modValue = name === 'jitter' ? this.getModValue(name) / 100 : this.getModValue(name) / 10000; + const modification = Modifications.modifications[name]; + if (!modification) { + throw 'Unknown modification ' + name; + } + // We store percentages as decimals, so to get them back we need to divide by 10000. Otherwise + // we divide by 100. Both ways we end up with a value with two decimal places + var modValue; + if (modification.type === 'percentage') { + modValue = this.getModValue(name) / 10000; + } else if (modification.type === 'numeric') { + modValue = this.getModValue(name) / 100; + } else { + modValue = this.getModValue(name); + } if (modValue) { if (additive) { result = result + modValue; @@ -74,7 +87,18 @@ export default class Module { result = result * (1 + modValue); } } + } else { + if (name === 'burst') { + // Burst is special, as if it can not exist but have a modification + const modValue = this.getModValue(name) / 100; + return modValue; + } else if (name === 'burstrof') { + // Burst rate of fire is special, as if it can not exist but have a modification + const modValue = this.getModValue(name) / 100; + return modValue; + } } + return result; } @@ -425,7 +449,7 @@ export default class Module { getDps() { // DPS is a synthetic value let damage = this.getDamage(); - let rpshot = this.getRoundsPerShot() || 1; + let rpshot = this.roundspershot || 1; let rof = this.getRoF() || 1; return damage * rpshot * rof; @@ -438,7 +462,7 @@ export default class Module { getEps() { // EPS is a synthetic value let distdraw = this.getDistDraw(); - let rpshot = this.getRoundsPerShot() || 1; + let rpshot = this.roundspershot || 1; let rof = this.getRoF() || 1; return distdraw * rpshot * rof; @@ -451,7 +475,7 @@ export default class Module { getHps() { // HPS is a synthetic value let heat = this.getThermalLoad(); - let rpshot = this.getRoundsPerShot() || 1; + let rpshot = this.roundspershot || 1; let rof = this.getRoF() || 1; return heat * rpshot * rof; @@ -509,6 +533,7 @@ export default class Module { const burst = this.getBurst() || 1; const burstRoF = this.getBurstRoF() || 1; const intRoF = this._getModifiedValue('rof'); + return burst / (((burst - 1)/burstRoF) + 1/intRoF); } diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 1a9a386e..3a1acd16 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -458,7 +458,7 @@ export default class Ship { } else if (name === 'shieldreinforcement') { m.setModValue(name, value); this.recalculateShieldCells(); - } else if (name === 'burst' || name === 'clip' || name === 'damage' || name === 'distdraw' || name === 'jitter' || name === 'piercing' || name === 'range' || name === 'reload' || name === 'rof' || name === 'thermload') { + } else if (name === 'burst' || name == 'burstrof' || name === 'clip' || name === 'damage' || name === 'distdraw' || name === 'jitter' || name === 'piercing' || name === 'range' || name === 'reload' || name === 'rof' || name === 'thermload') { m.setModValue(name, value); this.recalculateDps(); this.recalculateHps(); diff --git a/src/app/utils/CompanionApiUtils.js b/src/app/utils/CompanionApiUtils.js index c11783ab..91eccc54 100644 --- a/src/app/utils/CompanionApiUtils.js +++ b/src/app/utils/CompanionApiUtils.js @@ -279,21 +279,35 @@ function _addModifications(module, modifiers, blueprint, grade) { var special; for (const i in modifiers.modifiers) { - // Look up the modifiers to find what we need to do - const modifierActions = Modifications.modifierActions[modifiers.modifiers[i].name]; - const value = modifiers.modifiers[i].value; + // Some special modifications + if (modifiers.modifiers[i].name === 'mod_weapon_clip_size_override') { + // This is a numeric addition to the clip size, but we need to work it out in terms of being a percentage so + // that it works the same as other modifications + const origClip = module.clip || 1; + module.setModValue('clip', ((modifiers.modifiers[i].value - origClip) / origClip ) * 10000); + } else if (modifiers.modifiers[i].name === 'mod_weapon_burst_size') { + // This is an absolute number that acts as an override + module.setModValue('burst', modifiers.modifiers[i].value * 100); + } else if (modifiers.modifiers[i].name === 'mod_weapon_burst_rof') { + // For some reason this is a non-normalised percentage (i.e. 12.23% is 12.23 value rather than 0.1223 as everywhere else), so fix that here + module.setModValue('burstrof', modifiers.modifiers[i].value * 100); + } else { + // Look up the modifiers to find what we need to do + const modifierActions = Modifications.modifierActions[modifiers.modifiers[i].name]; + const value = modifiers.modifiers[i].value; - // Carry out the required changes - for (const action in modifierActions) { - if (isNaN(modifierActions[action])) { - module.setModValue(action, modifierActions[action]); - } else { - const actionValue = modifierActions[action] * value; - let mod = module.getModValue(action) / 10000; - if (!mod) { - mod = 0; + // Carry out the required changes + for (const action in modifierActions) { + if (isNaN(modifierActions[action])) { + module.setModValue(action, modifierActions[action]); + } else { + const actionValue = modifierActions[action] * value; + let mod = module.getModValue(action) / 10000; + if (!mod) { + mod = 0; + } + module.setModValue(action, ((1 + mod) * (1 + actionValue) - 1) * 10000); } - module.setModValue(action, ((1 + mod) * (1 + actionValue) - 1) * 10000); } }