From 19b861c4f73db80d87a1e3c295e823dff1a31189 Mon Sep 17 00:00:00 2001 From: danielyxie Date: Fri, 8 Sep 2017 14:16:48 -0500 Subject: [PATCH] Fixed bug with purchasing NeuroFlux using purchaseAugmentation() Singularity fn --- dist/bundle.js | 25 ++++++++++++++++--------- src/NetscriptFunctions.js | 28 ++++++++++++++++++---------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 6ca4f3623..54ea8cce9 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -36506,16 +36506,23 @@ function NetscriptFunctions(workerScript) { return false; } - for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { - if (__WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].queuedAugmentations[j].name === aug.name) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); - return false; - } + var isNeuroflux = false; + if (aug.name === __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { + isNeuroflux = true; } - for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].augmentations.length; ++j) { - if (__WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].augmentations[j].name === aug.name) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); - return false; + + if (!isNeuroflux) { + for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { + if (__WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].queuedAugmentations[j].name === aug.name) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); + return false; + } + } + for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].augmentations.length; ++j) { + if (__WEBPACK_IMPORTED_MODULE_10__Player_js__["a" /* Player */].augmentations[j].name === aug.name) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); + return false; + } } } diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index b66ac26b1..c3f0b21cf 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -1,5 +1,6 @@ import {Augmentations, Augmentation, - augmentationExists, installAugmentations} from "./Augmentations.js"; + augmentationExists, installAugmentations, + AugmentationNames} from "./Augmentations.js"; import {Companies, Company, CompanyPosition, CompanyPositions, companyExists} from "./Company.js"; import {CONSTANTS} from "./Constants.js"; @@ -1753,16 +1754,23 @@ function NetscriptFunctions(workerScript) { return false; } - for (var j = 0; j < Player.queuedAugmentations.length; ++j) { - if (Player.queuedAugmentations[j].name === aug.name) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); - return false; - } + var isNeuroflux = false; + if (aug.name === AugmentationNames.NeuroFluxGovernor) { + isNeuroflux = true; } - for (var j = 0; j < Player.augmentations.length; ++j) { - if (Player.augmentations[j].name === aug.name) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); - return false; + + if (!isNeuroflux) { + for (var j = 0; j < Player.queuedAugmentations.length; ++j) { + if (Player.queuedAugmentations[j].name === aug.name) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); + return false; + } + } + for (var j = 0; j < Player.augmentations.length; ++j) { + if (Player.augmentations[j].name === aug.name) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); + return false; + } } }