Merge pull request #627 from jeneg/calculations-fix

Corrected calculations of modification values
This commit is contained in:
Felix Linker
2021-01-27 20:16:29 +01:00
committed by GitHub

View File

@@ -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,7 +42,6 @@ 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;
if ((!raw) && this.blueprint && this.blueprint.special) {
@@ -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;
}
}
}