Corrected calculations of modification values

This commit is contained in:
yevhenii.chubar
2020-12-29 17:47:10 +02:00
parent cf50537e3d
commit 49c827b2c8

View File

@@ -1,7 +1,8 @@
import * as ModuleUtils from './ModuleUtils'; import * as ModuleUtils from './ModuleUtils';
import { Modifications } from 'coriolis-data/dist'; import { Modifications } from 'coriolis-data/dist';
import React from 'react'; 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 * 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 * @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) { 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) { if ((!raw) && this.blueprint && this.blueprint.special) {
// This module has a special effect, see if we need to alter our returned value // 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 // this special effect modifies our returned value
const modification = Modifications.modifications[name]; const modification = Modifications.modifications[name];
const multiplier = modification.type === 'percentage' ? 10000 : 100; 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 // Apply resistance modding mechanisms to special effects subsequently
result = result + modifierActions[name] * (1 - (this[name] + result / multiplier)) * 100; result = result + modifierActions[name] * (1 - (this[name] + result / multiplier)) * 100;
} else if (modification.method === 'additive') { } else if (modification.method === 'additive') {
@@ -59,7 +60,7 @@ export default class Module {
} else if (modification.method === 'overwrite') { } else if (modification.method === 'overwrite') {
result = modifierActions[name]; result = modifierActions[name];
} else { } else {
result = (((1 + result / multiplier) * (1 + modifierActions[name])) - 1) * multiplier; result = result + modifierActions[name] * multiplier;
} }
} }
} }