From 49c827b2c8b9d5d61e9ab06bccdf7b0224cb52b0 Mon Sep 17 00:00:00 2001 From: "yevhenii.chubar" Date: Tue, 29 Dec 2020 17:47:10 +0200 Subject: [PATCH] Corrected calculations of modification values --- src/app/shipyard/Module.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index fc702603..6b90c6b1 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -1,7 +1,8 @@ import * as ModuleUtils from './ModuleUtils'; import { Modifications } from 'coriolis-data/dist'; import React from 'react'; -import { STATS_FORMATTING, SI_PREFIXES } from './StatsFormatting'; +import { SI_PREFIXES, STATS_FORMATTING } from './StatsFormatting'; +import { includes } from 'lodash'; /** * Module - active module in a ship's buildout @@ -41,8 +42,7 @@ export default class Module { * @return {object} The value of the modification. If it is a numeric value then it is returned as an integer value scaled so that 1.23% == 123 */ getModValue(name, raw) { - let baseVal = this[name]; - let result = this.mods && this.mods[name] ? this.mods[name] : null; + let result = this.mods && this.mods[name] ? this.mods[name] : null; if ((!raw) && this.blueprint && this.blueprint.special) { // This module has a special effect, see if we need to alter our returned value @@ -51,7 +51,8 @@ export default class Module { // this special effect modifies our returned value const modification = Modifications.modifications[name]; const multiplier = modification.type === 'percentage' ? 10000 : 100; - if (name === 'explres' || name === 'kinres' || name === 'thermres' || name === 'causres') { + + if (includes(['explres', 'kinres', 'thermres', 'causres'], name)) { // Apply resistance modding mechanisms to special effects subsequently result = result + modifierActions[name] * (1 - (this[name] + result / multiplier)) * 100; } else if (modification.method === 'additive') { @@ -59,7 +60,7 @@ export default class Module { } else if (modification.method === 'overwrite') { result = modifierActions[name]; } else { - result = (((1 + result / multiplier) * (1 + modifierActions[name])) - 1) * multiplier; + result = result + modifierActions[name] * multiplier; } } }