From 6712d340fb663742c1533b527fbad8fbf37e45b2 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Sun, 25 Jun 2017 18:39:17 -0500 Subject: [PATCH] Fixed bugs with new multiple Augmentations feature. Added getServerMaxMoney() netscript command --- css/menupages.css | 7 +++- css/styles.css | 1 + css/terminal.css | 5 +++ index.html | 36 +++++++++++------- src/Augmentations.js | 63 ++++++++++++++++++++++++++++---- src/Constants.js | 13 +++++-- src/Crimes.js | 4 +- src/Faction.js | 14 ++++++- src/NetscriptEvaluator.js | 20 ++++++++++ src/NetscriptFunctions.js | 10 ++--- src/Player.js | 3 ++ src/Prestige.js | 4 +- src/SaveObject.js | 12 ++++-- src/engine.js | 38 ++++++++++++++++++- utils/PurchaseAugmentationBox.js | 58 ++++++++++++++++++++++++++--- 15 files changed, 240 insertions(+), 48 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index 400d7a875..ae5ff9b14 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -511,13 +511,16 @@ div.faction-clear { overflow-y: scroll; } -#augmentations-list li { +#augmentations-list li, +#queued-augmentations-list li { width: 70%; background-color: #333; } #augmentations-list h2, -#augmentations-list p { +#augmentations-list p, +#queued-augmentations-list h2, +#queued-augmentations-list p { margin: 4px; color: var(--my-font-color); padding: 8px; diff --git a/css/styles.css b/css/styles.css index f773a83e9..f3b8d08d2 100644 --- a/css/styles.css +++ b/css/styles.css @@ -240,6 +240,7 @@ tr:focus { margin-right: 14px; background-color: transparent; z-index: 2; + width: auto; } /* Character Overview */ diff --git a/css/terminal.css b/css/terminal.css index 8a392f432..dd44c2cca 100644 --- a/css/terminal.css +++ b/css/terminal.css @@ -18,6 +18,11 @@ background-color: var(--my-background-color); } +/* +.posted { + width: 70%; +}*/ + #terminal-input { background-color: var(--my-background-color); color: var(--my-font-color); diff --git a/index.html b/index.html index 2dc38708a..d6369e6e2 100644 --- a/index.html +++ b/index.html @@ -548,10 +548,29 @@ - +
-

Augmentations

-

Lists all augmentations you have installed

+

Purchased Augmentations

+

+ Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them. +
WARNING: Purchasing an Augmentation resets most of your progress, including:

+ Stats/Skill levels and Experience
+ Money
+ Scripts on every computer but your home computer
+ Purchased servers
+ Hacknet Nodes
+ Faction/Company reputation

+ Purchasing an Augmentation lets you start over with the perks and benefits granted by all + of the Augmentations you have ever purchased. Also, you will keep any scripts and RAM upgrades + on your home computer (but you will lose all programs besides NUKE.exe). +

+

+ +
+ Install Augmentations +

+

Installed Augmentations

+

List of all augmentations that have been installed. You have gained the effects of these augmentations

@@ -703,17 +722,6 @@

-


WARNING: Purchasing an Augmentation resets most of your progress, including:

- Stats/Skill levels and Experience
- Money
- Scripts on every computer but your home computer
- Purchased servers
- Hacknet Nodes
- Faction/Company reputation

- Purchasing an Augmentation lets you start over with the perks and benefits granted by all - of the Augmentations you have ever purchased. Also, you will keep any scripts and RAM upgrades - on your home computer (but you will lose all programs besides NUKE.exe). -

Purchase Cancel diff --git a/src/Augmentations.js b/src/Augmentations.js index 6bd5b59f4..ba1fde4a4 100644 --- a/src/Augmentations.js +++ b/src/Augmentations.js @@ -2,6 +2,7 @@ function Augmentation(name) { this.name = name; this.info = ""; + this.owned = false; //Price and reputation base requirements (can change based on faction multipliers) this.baseRepRequirement = 0; @@ -152,6 +153,11 @@ AugmentationNames = { } initAugmentations = function() { + for (var name in Factions) { + if (Factions.hasOwnProperty(name)) { + Factions[name].augmentations = []; + } + } //Combat stat augmentations var HemoRecirculator = new Augmentation(AugmentationNames.HemoRecirculator); HemoRecirculator.setInfo("A heart implant that greatly increases the body's ability to effectively use and pump " + @@ -819,7 +825,7 @@ initAugmentations = function() { "for the Hacknet Node that provides better performance.

" + "This augmentation:
" + "Increases the amount of money produced by Hacknet Nodes by 15%
" + - "Decreases the cost of purchasing a Hacknet Node Core by 15%"); + "Decreases the cost of purchasing a Hacknet Node by 15%"); HacknetNodeCPUUpload.addToFactions(["Netburners"]); if (augmentationExists(AugmentationNames.HacknetNodeCPUUpload)) { delete Augmentations[AugmentationNames.HacknetNodeCPUUpload]; @@ -881,13 +887,16 @@ initAugmentations = function() { //Misc/Hybrid augmentations var NeuroFluxGovernor = new Augmentation(AugmentationNames.NeuroFluxGovernor); if (augmentationExists(AugmentationNames.NeuroFluxGovernor)) { - var oldAug = Augmentations[AugmentationNames.NeuroFluxGovernor]; - NeuroFluxGovernor.level = oldAug.level; + var nextLevel = getNextNeurofluxLevel(); + NeuroFluxGovernor.level = nextLevel - 1; mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level); NeuroFluxGovernor.setRequirements(500 * mult, 750000 * mult); delete Augmentations[AugmentationNames.NeuroFluxGovernor]; } else { - NeuroFluxGovernor.setRequirements(250, 500000); + var nextLevel = getNextNeurofluxLevel(); + NeuroFluxGovernor.level = nextLevel - 1; + mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level); + NeuroFluxGovernor.setRequirements(500 * mult, 750000 * mult); } NeuroFluxGovernor.setInfo("A device that is embedded in the back of the neck. The NeuroFlux Governor " + "monitors and regulates nervous impulses coming to and from the spinal column, " + @@ -1362,9 +1371,18 @@ initAugmentations = function() { delete Augmentations[AugmentationNames.SNA]; } AddToAugmentations(SNA); + + //Update costs based on how many have been purchased + var mult = Math.pow(1.5, Player.queuedAugmentations.length); + for (var name in Augmentations) { + if (Augmentations.hasOwnProperty(name)) { + Augmentations[name].baseCost *= mult; + } + } } applyAugmentation = function(aug, reapply=false) { + Augmentations[aug.name].owned = true; switch(aug.name) { //Combat stat augmentations case AugmentationNames.Targeting1: @@ -1634,7 +1652,13 @@ applyAugmentation = function(aug, reapply=false) { Player.work_money_mult *= 1.01; if (!reapply) { - ++aug.level; + Augmentations[aug.name].level = aug.level; + for (var i = 0; i < Player.augmentations.length; ++i) { + if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { + Player.augmentations[i].level = aug.level; + break; + } + } } break; case AugmentationNames.Neurotrainer1: //Low Level @@ -1834,7 +1858,7 @@ applyAugmentation = function(aug, reapply=false) { } if (aug.name == AugmentationNames.NeuroFluxGovernor) { - for (var i = 0; i > Player.augmentations.length; ++i) { + for (var i = 0; i < Player.augmentations.length; ++i) { if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { //Already have this aug, just upgrade the level return; @@ -1853,6 +1877,28 @@ function PlayerOwnedAugmentation(name) { this.level = 1; } +function installAugmentations() { + if (Player.queuedAugmentations.length == 0) { + dialogBoxCreate("You have not purchased any Augmentations to install!"); + return; + } + var augmentationList = ""; + for (var i = 0; i < Player.queuedAugmentations.length; ++i) { + var aug = Augmentations[Player.queuedAugmentations[i].name]; + if (aug == null) { + console.log("ERROR. Invalid augmentation"); + continue; + } + applyAugmentation(Player.queuedAugmentations[i]); + augmentationList += (aug.name + "
"); + } + Player.queuedAugmentations = []; + dialogBoxCreate("You slowly drift to sleep as scientists put you under in order " + + "to install the following Augmentations:
" + augmentationList + + "
You wake up in your home...you feel different..."); + prestigeAugmentation(); +} + PlayerObject.prototype.reapplyAllAugmentations = function() { console.log("Re-applying augmentations"); //Reset multipliers @@ -1901,17 +1947,18 @@ PlayerObject.prototype.reapplyAllAugmentations = function() { var augName = this.augmentations[i].name; var aug = Augmentations[augName]; + aug.owned = true; if (aug == null) { console.log("WARNING: Invalid augmentation name"); continue; } if (aug.name == AugmentationNames.NeuroFluxGovernor) { for (j = 0; j < aug.level; ++j) { - applyAugmentation(aug, true); + applyAugmentation(this.augmentations[i], true); } continue; } - applyAugmentation(aug, true); + applyAugmentation(this.augmentations[i], true); } } diff --git a/src/Constants.js b/src/Constants.js index 6bd6cf937..767bf28b5 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ CONSTANTS = { - Version: "0.22.1", + Version: "0.23.0.BETA", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -29,8 +29,8 @@ CONSTANTS = { HacknetNodeMaxCores: 16, /* Faction and Company favor */ - FactionReputationToFavor: 7500, - CompanyReputationToFavor: 5000, + FactionReputationToFavor: 6000, + CompanyReputationToFavor: 4500, /* Augmentation */ //NeuroFlux Governor cost multiplier as you level up @@ -655,6 +655,13 @@ CONSTANTS = { "RAM Upgrades on your home computer", Changelog: + "v0.23.0
" + + "-You can now purchase multiple Augmentations in a run. When you purchase an Augmentation you will lose money equal to the price " + + "and then the cost of purchasing another Augmentation during this run will be increased by 50%. You do not gain the benefits " + + "of your purchased Augmentations until you install them. This installation can be done through the 'Augmentation' tab. When " + + "you install your Augmentations, your game will reset like before.
" + + "-Reputation needed to gain a favor from faction decreased from 7500 to 6000
" + + "-Reputation needed to gain a favor from company decreased from 5000 to 4500
" + "v0.22.1
" + "-You no longer lose progress on creating programs when cancelling your work. Your progress will be saved and you will pick up " + "where you left off when you start working on it again
" + diff --git a/src/Crimes.js b/src/Crimes.js index c38ea1f39..9a96a5944 100644 --- a/src/Crimes.js +++ b/src/Crimes.js @@ -97,9 +97,9 @@ function determineCrimeChanceShoplift() { } function determineCrimeChanceMug() { - var chance = ((2 *Player.strength / CONSTANTS.MaxSkillLevel + + var chance = ((1.5 *Player.strength / CONSTANTS.MaxSkillLevel + 0.5 * Player.defense / CONSTANTS.MaxSkillLevel + - 2 * Player.dexterity / CONSTANTS.MaxSkillLevel + + 1.5 * Player.dexterity / CONSTANTS.MaxSkillLevel + 0.5 * Player.agility / CONSTANTS.MaxSkillLevel)) * 5; chance *= Player.crime_success_mult; return Math.min(chance, 1); diff --git a/src/Faction.js b/src/Faction.js index bc4bc0fff..4037335ad 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -972,6 +972,16 @@ displayFactionAugmentations = function(factionName) { for (var i = 0; i < faction.augmentations.length; ++i) { (function () { var aug = Augmentations[faction.augmentations[i]]; + if (aug == null) { + console.log("ERROR: Invalid Augmentation"); + return; + } + var owned = false; + for (var j = 0; j < Player.queuedAugmentations.length; ++j) { + if (Player.queuedAugmentations[j].name == aug.name) { + owned = true; + } + } var item = document.createElement("li"); var span = document.createElement("span"); var aDiv = document.createElement("div"); @@ -979,7 +989,7 @@ displayFactionAugmentations = function(factionName) { var pElem = document.createElement("p"); aElem.setAttribute("href", "#"); var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult; - if (aug.name != AugmentationNames.NeuroFluxGovernor && aug.owned) { + if (aug.name != AugmentationNames.NeuroFluxGovernor && (aug.owned || owned)) { aElem.setAttribute("class", "a-link-button-inactive"); pElem.innerHTML = "ALREADY OWNED"; } else if (faction.playerReputation >= req) { @@ -994,7 +1004,7 @@ displayFactionAugmentations = function(factionName) { pElem.style.display = "inline"; aElem.innerHTML = aug.name; if (aug.name == AugmentationNames.NeuroFluxGovernor) { - aElem.innerHTML += " - Level " + (aug.level + 1); + aElem.innerHTML += " - Level " + (getNextNeurofluxLevel()); } span.style.display = "inline-block" diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 23471931d..3c9453de9 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -530,6 +530,22 @@ function evaluate(exp, workerScript) { }, function(e) { reject(e); }); + } else if (exp.func.value == "getServerMaxMoney") { + if (exp.args.length != 1) { + return reject(makeRuntimeRejectMsg(workerScript, "getServerMaxMoney() call has incorrect number of arguments. Takes 1 argument")); + } + var ipPromise = evaluate(exp.args[0], workerScript); + ipPromise.then(function(ip) { + var server = getServer(ip); + if (server == null) { + workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); + return reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into getServerMaxMoney() command")); + } + workerScript.scriptRef.log("getServerMaxMoney() returned " + formatNumber(server.moneyMax, 0) + " for " + server.hostname); + resolve(server.moneyMax); + }, function(e) { + reject(e); + }); } else if (exp.func.value == "fileExists") { if (exp.args.length != 1 && exp.args.length != 2) { return reject(makeRuntimeRejectMsg(workerScript, "fileExists() call has incorrect number of arguments. Takes 1 or 2 arguments")); @@ -620,6 +636,10 @@ function evaluate(exp, workerScript) { displayHacknetNodesContent(); workerScript.scriptRef.log("Purchased new Hacknet Node with name: " + name); resolve(numOwned); + } else if (exp.func.value == "val") { + if (exp.args.length != 1) { + return reject(makeRuntimeRejectMsg(workerScript, "val() call has incorrect number of arguments. Takes 1 arguments")); + } } else { reject(makeRuntimeRejectMsg(workerScript, "Invalid function: " + exp.func.value)); } diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 6ca8cf04c..250e66bba 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -176,7 +176,7 @@ function netscriptHack(exp, workerScript) { workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")"); return Promise.resolve([server, hackingTime]); }).then(function([server, hackingTime]) { - console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")"); + //console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")"); return netscriptDelay(hackingTime* 1000).then(function() { if (env.stopFlag) {return Promise.reject(workerScript);} var hackChance = scriptCalculateHackingChance(server); @@ -201,7 +201,7 @@ function netscriptHack(exp, workerScript) { workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); Player.gainHackingExp(expGainedOnSuccess); workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; - console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); + //console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")"); server.fortify(CONSTANTS.ServerFortifyAmount * threads); return Promise.resolve(true); @@ -209,7 +209,7 @@ function netscriptHack(exp, workerScript) { //Player only gains 25% exp for failure? TODO Can change this later to balance Player.gainHackingExp(expGainedOnFailure); workerScript.scriptRef.onlineExpGained += expGainedOnFailure; - console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp"); + //console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp"); workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp (t=" + threads + ")"); return Promise.resolve(false); } @@ -245,7 +245,7 @@ function netscriptGrow(exp, workerScript) { } var growTime = scriptCalculateGrowTime(server); - console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds") + //console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds") workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds (t=" + threads + ")"); return Promise.resolve([server, growTime]); @@ -298,7 +298,7 @@ function netscriptWeaken(exp, workerScript) { } var weakenTime = scriptCalculateWeakenTime(server); - console.log("Executing weaken() on server " + server.hostname + " in " + formatNumber(weakenTime/1000, 3) + " seconds") + //console.log("Executing weaken() on server " + server.hostname + " in " + formatNumber(weakenTime/1000, 3) + " seconds") workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " + formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")"); diff --git a/src/Player.js b/src/Player.js index 97c34f031..70a1a77e9 100644 --- a/src/Player.js +++ b/src/Player.js @@ -4,6 +4,8 @@ function PlayerObject() { this.hacking_skill = 1; //Fighting + this.hp = 10; + this.max_hp = 10; this.strength = 1; //Damage dealt this.defense = 1; //Damage received this.dexterity = 1; //Accuracy @@ -86,6 +88,7 @@ function PlayerObject() { this.factions = []; //Names of all factions player has joined //Augmentations + this.queuedAugmentations = []; //Purchased but not installed, names only this.augmentations = []; //Names of all installed augmentations //Crime statistics (Total refers to this 'simulation'. Lifetime is forever) diff --git a/src/Prestige.js b/src/Prestige.js index ff33f2524..3d36e2bc2 100644 --- a/src/Prestige.js +++ b/src/Prestige.js @@ -75,6 +75,8 @@ function prestigeAugmentation() { Player.factions = []; + Player.queuedAugmentations = []; + Player.startAction = false; Player.actionTime = 0; @@ -187,7 +189,7 @@ function prestigeAugmentation() { } //Re-initialize things - This will update any changes - initFactions(); + initFactions(); //Factions must be initialized before augmentations initAugmentations(); initCompanies(); diff --git a/src/SaveObject.js b/src/SaveObject.js index 0e38841bb..c04847369 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -9,7 +9,6 @@ function BitburnerSaveObject() { this.CompaniesSave = ""; this.FactionsSave = ""; this.SpecialServerIpsSave = ""; - this.AugmentationsSave = ""; this.AliasesSave = ""; this.MessagesSave = ""; this.VersionSave = ""; @@ -35,11 +34,10 @@ BitburnerSaveObject.prototype.saveGame = function() { this.CompaniesSave = JSON.stringify(Companies); this.FactionsSave = JSON.stringify(Factions); this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps); - this.AugmentationsSave = JSON.stringify(Augmentations); + //this.AugmentationsSave = JSON.stringify(Augmentations); this.AliasesSave = JSON.stringify(Aliases); this.MessagesSave = JSON.stringify(Messages); this.VersionSave = JSON.stringify(CONSTANTS.Version); - var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this)))); window.localStorage.setItem("bitburnerSave", saveString); @@ -60,7 +58,7 @@ loadGame = function(saveObj) { Companies = JSON.parse(saveObj.CompaniesSave, Reviver); Factions = JSON.parse(saveObj.FactionsSave, Reviver); SpecialServerIps = JSON.parse(saveObj.SpecialServerIpsSave, Reviver); - Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); + if (saveObj.hasOwnProperty("AliasesSave")) { try { Aliases = JSON.parse(saveObj.AliasesSave, Reviver); @@ -97,6 +95,9 @@ loadGame = function(saveObj) { } } } + if (CONSTANTS.Version == "0.23.0.BETA") { + Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); + } createNewUpdateText(); } } catch(e) { @@ -167,6 +168,9 @@ loadImportedGame = function(saveObj, saveString) { } } } + if (CONSTANTS.Version == "0.23.0.BETA") { + Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); + } createNewUpdateText(); } } catch(e) { diff --git a/src/engine.js b/src/engine.js index a70cfb497..b9160ec53 100644 --- a/src/engine.js +++ b/src/engine.js @@ -369,6 +369,42 @@ var Engine = { }, displayAugmentationsContent: function() { + //Purchased/queued augmentations + var queuedAugmentationsList = document.getElementById("queued-augmentations-list"); + + while (queuedAugmentationsList.firstChild) { + queuedAugmentationsList.removeChild(queuedAugmentationsList.firstChild); + } + + for (var i = 0; i < Player.queuedAugmentations.length; ++i) { + var augName = Player.queuedAugmentations[i].name; + var aug = Augmentations[augName]; + + var item = document.createElement("li"); + var hElem = document.createElement("h2"); + var pElem = document.createElement("p"); + + item.setAttribute("class", "installed-augmentation"); + hElem.innerHTML = augName; + if (augName == AugmentationNames.NeuroFluxGovernor) { + hElem.innerHTML += " - Level " + (Player.queuedAugmentations[i].level); + } + pElem.innerHTML = aug.info; + + item.appendChild(hElem); + item.appendChild(pElem); + + queuedAugmentationsList.appendChild(item); + } + + //Install Augmentations button + var installButton = clearEventListeners("install-augmentations-button"); + installButton.addEventListener("click", function() { + installAugmentations(); + return false; + }); + + //Installed augmentations var augmentationsList = document.getElementById("augmentations-list"); while (augmentationsList.firstChild) { @@ -386,7 +422,7 @@ var Engine = { item.setAttribute("class", "installed-augmentation"); hElem.innerHTML = augName; if (augName == AugmentationNames.NeuroFluxGovernor) { - hElem.innerHTML += " - Level " + (aug.level); + hElem.innerHTML += " - Level " + (Player.augmentations[i].level); } pElem.innerHTML = aug.info; diff --git a/utils/PurchaseAugmentationBox.js b/utils/PurchaseAugmentationBox.js index e462520da..412ce413d 100644 --- a/utils/PurchaseAugmentationBox.js +++ b/utils/PurchaseAugmentationBox.js @@ -79,12 +79,36 @@ purchaseAugmentationBoxCreate = function(aug, fac) { Augmentations[AugmentationNames.BionicArms].owned == false) { dialogBoxCreate("You must first install the Bionic Arms augmentation before installing this upgrade"); } else if (Player.money >= (aug.baseCost * fac.augmentationPriceMult)) { - applyAugmentation(aug); - dialogBoxCreate("You slowly drift to sleep as " + fac.name + "'s scientists put you under " + - " in order to install the " + aug.name + " Augmentation.

" + - "You wake up in your home...you feel different..."); - - prestigeAugmentation(); + var queuedAugmentation = new PlayerOwnedAugmentation(aug.name); + if (aug.name == AugmentationNames.NeuroFluxGovernor) { + queuedAugmentation.level = getNextNeurofluxLevel(); + } + Player.queuedAugmentations.push(queuedAugmentation); + + Player.loseMoney((aug.baseCost * fac.augmentationPriceMult)); + dialogBoxCreate("You purchased " + aug.name + ". It's enhancements will not take " + + "effect until they are installed. To install your augmentations, go to the " + + "'Augmentations' tab on the left-hand navigation menu. Purchasing additional " + + "augmentations will now be more expensive."); + + //If you just purchased Neuroflux Governor, recalculate the cost + if (aug.name == AugmentationNames.NeuroFluxGovernor) { + var nextLevel = getNextNeurofluxLevel(); + --nextLevel; + var mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); + aug.setRequirements(500 * mult, 750000 * mult); + + for (var i = 0; i < Player.queuedAugmentations.length; ++i) { + aug.baseCost *= 1.5; + } + } + + + for (var name in Augmentations) { + if (Augmentations.hasOwnProperty(name) && name != AugmentationNames.NeuroFluxGovernor) { + Augmentations[name].baseCost *= 1.5; + } + } } else { dialogBoxCreate("You don't have enough money to purchase this Augmentation!"); } @@ -94,4 +118,26 @@ purchaseAugmentationBoxCreate = function(aug, fac) { }); purchaseAugmentationBoxOpen(); +} + +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("ERROR, Could not find NeuroFlux Governor aug"); + return 1; + } + } + var nextLevel = aug.level + 1; + for (var i = 0; i < Player.queuedAugmentations.length; ++i) { + if (Player.queuedAugmentations[i].name == AugmentationNames.NeuroFluxGovernor) { + ++nextLevel; + } + } + return nextLevel; } \ No newline at end of file