From 8ef0101a6e98f561098b8dabe0dd35d874b7a9fb Mon Sep 17 00:00:00 2001 From: willyb321 Date: Sun, 17 Jun 2018 08:24:24 +1000 Subject: [PATCH] apply module blueprint and special before setting value Fixes #297 --- src/app/shipyard/Module.js | 2 +- src/app/utils/JournalUtils.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index c5cde25d..193f37d2 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -72,7 +72,7 @@ export default class Module { * Set a value for a given modification ID * @param {Number} name The name of the modification * @param {object} value The value of the modification. If it is a numeric value then it should be an integer scaled so that -2.34% == -234 - * @param {bool} valueiswithspecial true if the value includes the special effect (when coming from a UI component) + * @param {Boolean} valueiswithspecial true if the value includes the special effect (when coming from a UI component) */ setModValue(name, value, valueiswithspecial) { if (!this.mods) { diff --git a/src/app/utils/JournalUtils.js b/src/app/utils/JournalUtils.js index 94c1b6be..cbfd7e45 100644 --- a/src/app/utils/JournalUtils.js +++ b/src/app/utils/JournalUtils.js @@ -252,6 +252,16 @@ function _addModifications(module, modifiers, blueprint, grade, specialModificat if (specialModifications) { special = Modifications.specials[specialModifications]; } + // Add the blueprint definition, grade and special + if (blueprint) { + module.blueprint = getBlueprint(blueprint, module); + if (grade) { + module.blueprint.grade = Number(grade); + } + if (special) { + module.blueprint.special = special; + } + } for (const i in modifiers) { // Some special modifications // Look up the modifiers to find what we need to do @@ -268,24 +278,14 @@ function _addModifications(module, modifiers, blueprint, grade, specialModificat if (modifiers[i].Label.search('Resistance') >= 0) { value = (modifiers[i].Value * 100) - (modifiers[i].OriginalValue * 100); } + // Carry out the required changes for (const action in modifierActions) { if (isNaN(modifierActions[action])) { module.setModValue(action, modifierActions[action]); } else { - module.setModValue(action, value); + module.setModValue(action, value, true); } } } - - // Add the blueprint definition, grade and special - if (blueprint) { - module.blueprint = getBlueprint(blueprint, module); - if (grade) { - module.blueprint.grade = Number(grade); - } - if (special) { - module.blueprint.special = special; - } - } }