diff --git a/css/styles.css b/css/styles.css
index 399ed28b0..6a0d0fb16 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -225,6 +225,7 @@ tr:focus {
/* Character Overview */
#character-overview-container {
+ display: none;
position: fixed; /* Stay in place */
right: 0;
top: 0;
diff --git a/src/Augmentations.js b/src/Augmentations.js
index 9c0eb54dd..678e3aa06 100644
--- a/src/Augmentations.js
+++ b/src/Augmentations.js
@@ -1307,8 +1307,8 @@ initAugmentations = function() {
"the user's organic arms.
" +
"This augmentation increases the user's strength and dexterity by 50%");
BionicArms.setRequirements(25000, 45000000);
- BionicArms.addTofactions(["Tetrads"]);
- if (augmetationExists(AugmentationNames.BionicArms)) {
+ BionicArms.addToFactions(["Tetrads"]);
+ if (augmentationExists(AugmentationNames.BionicArms)) {
BionicArms.owned = Augmentations[AugmentationNames.BionicArms].owned;
delete Augmentations[AugmentationNames.BionicArms];
}
diff --git a/src/Constants.js b/src/Constants.js
index 80044a920..a22bffda6 100644
--- a/src/Constants.js
+++ b/src/Constants.js
@@ -1,5 +1,5 @@
CONSTANTS = {
- Version: "0.10",
+ Version: "0.11",
//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
diff --git a/src/HacknetNode.js b/src/HacknetNode.js
index ddc3f15f4..b8758045f 100644
--- a/src/HacknetNode.js
+++ b/src/HacknetNode.js
@@ -415,9 +415,11 @@ updateHacknetNodeDomElement = function(nodeObj) {
}
processAllHacknetNodeEarnings = function(numCycles) {
+ var total = 0;
for (var i = 0; i < Player.hacknetNodes.length; ++i) {
- processSingleHacknetNodeEarnings(numCycles, Player.hacknetNodes[i]);
+ total += processSingleHacknetNodeEarnings(numCycles, Player.hacknetNodes[i]);
}
+ return total;
}
processSingleHacknetNodeEarnings = function(numCycles, nodeObj) {
@@ -428,4 +430,14 @@ processSingleHacknetNodeEarnings = function(numCycles, nodeObj) {
nodeObj.totalMoneyGenerated += totalEarnings;
nodeObj.onlineTimeSeconds += (numCycles * (Engine._idleSpeed / 1000));
Player.gainMoney(totalEarnings);
+ return totalEarnings;
+}
+
+getHacknetNode = function(name) {
+ for (var i = 0; i < Player.hacknetNodes.length; ++i) {
+ if (Player.hacknetNodes[i].name == name) {
+ return player.hacknetNodes[i];
+ }
+ }
+ return null;
}
\ No newline at end of file
diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js
index 12c11e081..7e7a617ee 100644
--- a/src/NetscriptEvaluator.js
+++ b/src/NetscriptEvaluator.js
@@ -690,6 +690,7 @@ function evaluate(exp, workerScript) {
} else if (exp.func.value == "getServerMoneyAvailable") {
if (exp.args.length != 1) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|getServerMoneyAvailable() call has incorrect number of arguments. Takes 1 arguments");
+ return;
}
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
@@ -706,6 +707,69 @@ function evaluate(exp, workerScript) {
}, function(e) {
reject(e);
});
+ } else if (exp.func.value == "purchaseHacknetNode") {
+ if (exp.args.length != 0) {
+ reject("|"+workerScript.serverIp+"|"+workerScript.name+"|purchaseHacknetNode() call has incorrect number of arguments. Takes 0 arguments");
+ return;
+ }
+ setTimeout(function() {
+ var cost = getCostOfNextHacknetNode();
+ if (isNaN(cost)) {
+ reject("|"+workerScript.serverIp+"|"+workerScript.name+"|Could not calculate cost in purchaseHacknetNode(). This is a bug please report to game dev");
+ return;
+ }
+ if (cost > Player.money) {
+ workerScript.scriptRef.log("Could not afford to purchase new Hacknet Node");
+ resolve(-1);
+ }
+
+ //Auto generate a name for the node for now...TODO
+ var numOwned = Player.hacknetNodes.length;
+ var name = "hacknet-node-" + numOwned;
+ var node = new HacknetNode(name);
+ node.updateMoneyGainRate();
+
+ Player.loseMoney(cost);
+ Player.hacknetNodes.push(node);
+ workerScript.scriptRef.log("Purchased new Hacknet Node with name: " + name);
+ resolve(numOwned);
+ }, CONSTANTS.CodeInstructionRunTime);
+ } else if (exp.func.value == "upgradeHacknetNode") {
+ if (exp.args.length != 1) {
+ reject("|"+workerScript.serverIp+"|"+workerScript.name+"|upgradeHacknetNode() call has incorrect number of arguments. Takes 1 argument");
+ return;
+ }
+ var namePromise = evaluate(exp.args[0], workerScript);
+ namePromise.then(function(name) {
+ var node = getHacknetNode(name);
+ if (node == null) {
+ reject("|"+workerScript.serverIp+"|"+workerScript.name+"|Invalid Hacknet Node name passed into upgradeHacknetNode()");
+ return;
+ }
+ var cost = node.calculateLevelUpgradeCost(1);
+ if (isNaN(cost)) {
+ reject("|"+workerScript.serverIp+"|"+workerScript.name+"|Could not calculate cost in upgradeHacknetNode(). This is a bug please report to game dev");
+ return;
+ }
+ if (cost > Player.money) {
+ workerScript.scriptRef.log("Could not afford to upgrade Hacknet Node: " + name);
+ resolve(false);
+ return;
+ }
+ if (node.level >= CONSTANTS.HacknetNodeMaxLevel) {
+ workerScript.scriptRef.log("Hacknet Node " + name + " already at max level");
+ node.level = CONSTANTS.HacknetNodeMaxLevel;
+ resolve(false);
+ return;
+ }
+ Player.loseMoney(cost);
+ node.level += 1;
+ node.updateMoneyGainRate();
+ workerScript.scriptRef.log("Hacknet node " + name + " upgraded to level " + node.level + "!");
+ resolve(true);
+ }, function(e) {
+ reject(e);
+ });
}
}, CONSTANTS.CodeInstructionRunTime);
});
diff --git a/src/Script.js b/src/Script.js
index a2448d834..d34463a9c 100644
--- a/src/Script.js
+++ b/src/Script.js
@@ -239,6 +239,7 @@ Reviver.constructors.Script = Script;
//into worker scripts so that they will start running
loadAllRunningScripts = function() {
var count = 0;
+ var total = 0;
for (var property in AllServers) {
if (AllServers.hasOwnProperty(property)) {
var server = AllServers[property];
@@ -254,10 +255,11 @@ loadAllRunningScripts = function() {
addWorkerScript(script, server);
//Offline production
- scriptCalculateOfflineProduction(script);
+ total += scriptCalculateOfflineProduction(script);
}
}
}
+ return total;
console.log("Loaded " + count.toString() + " running scripts");
}
@@ -305,7 +307,7 @@ scriptCalculateOfflineProduction = function(script) {
script.offlineMoneyMade += totalOfflineProduction;
script.offlineRunningTime += timePassed;
script.offlineExpGained += expGain;
-
+ return totalOfflineProduction;
//DEBUG
var serverName = AllServers[script.server].hostname;
console.log(script.filename + " from server " + serverName + " generated $" + totalOfflineProduction + " TOTAL while offline");
diff --git a/src/engine.js b/src/engine.js
index 628ea4b7a..ada971d6c 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -736,7 +736,7 @@ var Engine = {
/* Process offline progress */
processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts
- loadAllRunningScripts(); //This also takes care of offline production for those scripts
+ var offlineProductionFromScripts = loadAllRunningScripts(); //This also takes care of offline production for those scripts
if (Player.isWorking) {
console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
if (Player.workType == CONSTANTS.WorkTypeFaction) {
@@ -755,7 +755,7 @@ var Engine = {
}
//Hacknet Nodes offline progress
- processAllHacknetNodeEarnings(numCyclesOffline);
+ var offlineProductionFromHacknetNodes = processAllHacknetNodeEarnings(numCyclesOffline);
//Passive faction rep gain offline
processPassiveFactionRepGain(numCyclesOffline);
@@ -767,6 +767,9 @@ var Engine = {
Player.lastUpdate = Engine._lastUpdate;
Engine.start(); //Run main game loop and Scripts loop
+ dialogBoxCreate("While you were offline, your scripts generated $" +
+ formatNumber(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
+ formatNumber(offlineProductionFromHacknetNodes, 2));
} else {
//No save found, start new game
console.log("Initializing new game");
@@ -1046,6 +1049,18 @@ var Engine = {
Engine.loadWorkInProgressContent();
}
+ //character overview screen
+ document.getElementById("character-overview-container").style.display = "block";
+
+ //Remove classes from links (they might be set from tutorial)
+ document.getElementById("terminal-menu-link").removeAttribute("class");
+ document.getElementById("character-menu-link").removeAttribute("class");
+ document.getElementById("create-script-menu-link").removeAttribute("class");
+ document.getElementById("active-scripts-menu-link").removeAttribute("class");
+ document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
+ document.getElementById("world-menu-link").removeAttribute("class");
+ document.getElementById("tutorial-menu-link").removeAttribute("class");
+
//DEBUG
document.getElementById("debug-delete-scripts-link").addEventListener("click", function() {
Player.getHomeComputer().runningScripts = [];