apply module blueprint and special before setting value

Fixes #297
This commit is contained in:
willyb321
2018-06-17 08:24:24 +10:00
parent 737837eebd
commit 8ef0101a6e
2 changed files with 13 additions and 13 deletions

View File

@@ -72,7 +72,7 @@ export default class Module {
* Set a value for a given modification ID * Set a value for a given modification ID
* @param {Number} name The name of the modification * @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 {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) { setModValue(name, value, valueiswithspecial) {
if (!this.mods) { if (!this.mods) {

View File

@@ -252,6 +252,16 @@ function _addModifications(module, modifiers, blueprint, grade, specialModificat
if (specialModifications) { if (specialModifications) {
special = Modifications.specials[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) { for (const i in modifiers) {
// Some special modifications // Some special modifications
// Look up the modifiers to find what we need to do // 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) { if (modifiers[i].Label.search('Resistance') >= 0) {
value = (modifiers[i].Value * 100) - (modifiers[i].OriginalValue * 100); value = (modifiers[i].Value * 100) - (modifiers[i].OriginalValue * 100);
} }
// Carry out the required changes // Carry out the required changes
for (const action in modifierActions) { for (const action in modifierActions) {
if (isNaN(modifierActions[action])) { if (isNaN(modifierActions[action])) {
module.setModValue(action, modifierActions[action]); module.setModValue(action, modifierActions[action]);
} else { } 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;
}
}
} }