Fixed NeuroFlux Governor Augmentation level calculation bug

This commit is contained in:
danielyxie 2018-10-15 19:08:35 -05:00
parent bd66ecf469
commit 0bcca84ecd
4 changed files with 35 additions and 21 deletions

@ -1029,9 +1029,25 @@ function initAugmentations() {
"This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation " +
"increases ALL of the player's multipliers by 1%."
});
var nextLevel = getNextNeurofluxLevel();
NeuroFluxGovernor.level = nextLevel - 1;
mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level);
// Set the Augmentation's level to the currently-installed level
let currLevel = 0;
for (let i = 0; i < Player.augmentations.length; ++i) {
if (Player.augmentations[i].name === AugmentationNames.NeuroFluxGovernor) {
currLevel = Player.augmentations[i].level;
}
}
NeuroFluxGovernor.level = currLevel;
// To set the price/rep req of the NeuroFlux, we have to take into account NeuroFlux
// levels that are purchased but not yet installed
let nextLevel = currLevel;
for (let i = 0; i < Player.queuedAugmentations.length; ++i) {
if (Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor) {
++nextLevel;
}
}
mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel);
NeuroFluxGovernor.baseRepRequirement = 500 * mult * CONSTANTS.AugmentationRepMultiplier * BitNodeMultipliers.AugmentationRepCost;
NeuroFluxGovernor.baseCost = 750e3 * mult * CONSTANTS.AugmentationCostMultiplier * BitNodeMultipliers.AugmentationMoneyCost;
if (augmentationExists(AugmentationNames.NeuroFluxGovernor)) {
@ -2380,7 +2396,7 @@ function applyAugmentation(aug, reapply=false) {
return;
}
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
if (aug.name === AugmentationNames.NeuroFluxGovernor) {
for (var i = 0; i < Player.augmentations.length; ++i) {
if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
//Already have this aug, just upgrade the level

@ -510,6 +510,7 @@ let CONSTANTS = {
* b1t_flum3.exe now takes significantly less time to create
* Bug Fix: Fixed a bug that sometimes caused a blank black screen when destroying/resetting/switching BitNodes
* Bug Fix: Netscript calls that throw errors will now no longer cause the 'concurrent calls' error if they are caught in the script. i.e. try/catch should now work properly in scripts
* Bug Fix: Fixed a bug where sometimes the NeuroFlux Governor Augmentation level would be incorrectly calculated when the game was loaded
`
}

@ -734,27 +734,24 @@ function purchaseAugmentation(aug, fac, sing=false) {
}
function getNextNeurofluxLevel() {
var aug = Augmentations[AugmentationNames.NeuroFluxGovernor];
if (aug == null) {
for (var i = 0; i < Player.augmentations.length; ++i) {
if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
aug = Player.augmentations[i];
}
}
if (aug == null) {
console.log("WARNING: Could not find NeuroFlux Governor aug. This is OK if " +
"it happens during the loading/initialization of the game, but probably " +
"indicates something seriously wrong at other times");
return 1;
// Get current Neuroflux level based on Player's augmentations
let currLevel = 0;
for (var i = 0; i < Player.augmentations.length; ++i) {
if (Player.augmentations[i].name === AugmentationNames.NeuroFluxGovernor) {
currLevel = Player.augmentations[i].level;
}
}
var nextLevel = aug.level + 1;
// Player doesn't have Neuroflux yet, so next level is 1
if (currLevel === 0) { return 1; }
// Account for purchased but uninstalled Augmentations
for (var i = 0; i < Player.queuedAugmentations.length; ++i) {
if (Player.queuedAugmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
++nextLevel;
++currLevel;
}
}
return nextLevel;
return currLevel + 1;
}
function processPassiveFactionRepGain(numCycles) {

@ -1912,10 +1912,10 @@ PlayerObject.prototype.reapplyAllAugmentations = function(resetMultipliers=true)
this.augmentations[i].name = "Hacknet Node NIC Architecture Neural-Upload";
}
var augName = this.augmentations[i].name;
const augName = this.augmentations[i].name;
var aug = Augmentations[augName];
if (aug == null) {
console.log("WARNING: Invalid augmentation name");
console.log(`WARNING: Invalid augmentation name in Player.reapplyAllAugmentations(). Aug ${augName} will be skipped`);
continue;
}
aug.owned = true;