Lowered hacking exp gain. Added deleteServer(). Maximum of 25 purchaseable servers. Added autocompletion for ./ command. Oustanding faction invitations. Suppress Faction invites and messages

This commit is contained in:
danielyxie 2017-07-26 21:56:14 -05:00
parent 118118db83
commit 0e64359814
16 changed files with 644 additions and 575 deletions

@ -502,6 +502,11 @@
<h1> Factions </h1> <h1> Factions </h1>
<p> Lists all factions you have joined </p> <p> Lists all factions you have joined </p>
<ul class="factions-list" id="factions-list"></ul> <ul class="factions-list" id="factions-list"></ul>
<br><br>
<h1> Outstanding Faction Invitations </h1>
<p style="width:70%;"> Lists factions you have been invited to, as well as factions you have previously rejected.
You can accept these faction invitations at any times </p>
<ul class="factions-list" id="outstanding-faction-invitations-list"></ul>
</div> </div>
<!-- Single Faction info (when you select a faction from the Factions menu) --> <!-- Single Faction info (when you select a faction from the Factions menu) -->
@ -928,7 +933,7 @@
</span> </span>
</label> </label>
<input type ="range" max="100" min="20" <input type="range" max="100" min="20"
oninput="document.getElementById('settingsNSLogRangeValLabel').innerHTML = this.value; oninput="document.getElementById('settingsNSLogRangeValLabel').innerHTML = this.value;
Settings.MaxLogCapacity=this.value;" Settings.MaxLogCapacity=this.value;"
step="1" name="settingsNSLogRangeVal" id="settingsNSLogRangeVal" value="50"> step="1" name="settingsNSLogRangeVal" id="settingsNSLogRangeVal" value="50">
@ -946,7 +951,7 @@
</span> </span>
</label> </label>
<input type ="range" max="100" min="20" <input type="range" max="100" min="20"
oninput="document.getElementById('settingsNSPortRangeValLabel').innerHTML = this.value; oninput="document.getElementById('settingsNSPortRangeValLabel').innerHTML = this.value;
Settings.MaxPortCapacity=this.value;" Settings.MaxPortCapacity=this.value;"
step="1" name="settingsNSPortRangeVal" id="settingsNSPortRangeVal" value="50"> step="1" name="settingsNSPortRangeVal" id="settingsNSPortRangeVal" value="50">
@ -954,6 +959,31 @@
<em id="settingsNSPortRangeValLabel" style="font-style: normal;"></em> <em id="settingsNSPortRangeValLabel" style="font-style: normal;"></em>
</fieldset> </fieldset>
<!-- Suppress messages -->
<fieldset>
<label for="settingsSuppressMessages" class="tooltip">Suppress Messages:
<span class="tooltiptext">
If this is set, then any messages you receive will not appear as popups
on the screen. They will still get sent to your home computer as '.msg' files
and can be viewed with the 'cat' Terminal command.
</span>
</label>
<input type="checkbox" name="settingsSuppressMessages" id="settingsSuppressMessages"
onclick="Settings.SuppressMessages = this.checked;">
</fieldset>
<!-- Suppress faction invites -->
<fieldset>
<label for="settingsSuppressFactionInvites" class="tooltip">Suppress Faction Invites:
<span class="tooltiptext">
If this is set, then any faction invites you receive will not appear as popups
on the screen. Your outstanding faction invites can be viewed in the 'Factions' page.
</span>
</label>
<input type="checkbox" name="settingsSuppressFactionInvites" id="settingsSuppressFactionInvites"
onclick="Settings.SuppressFactionInvites = this.checked;">
</fieldset>
<!-- Donate button --> <!-- Donate button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="cmd" value="_s-xclick">

@ -61,9 +61,7 @@ CONSTANTS = {
ScriptHasRootAccessRamCost: 0.05, ScriptHasRootAccessRamCost: 0.05,
ScriptGetHostnameRamCost: 0.05, ScriptGetHostnameRamCost: 0.05,
ScriptGetHackingLevelRamCost: 0.05, ScriptGetHackingLevelRamCost: 0.05,
ScriptGetServerMoneyRamCost: 0.1, ScriptGetServerCost: 0.1,
ScriptGetServerSecurityRamCost: 0.1,
ScriptGetServerReqdHackRamCost: 0.1,
ScriptFileExistsRamCost: 0.1, ScriptFileExistsRamCost: 0.1,
ScriptIsRunningRamCost: 0.1, ScriptIsRunningRamCost: 0.1,
ScriptOperatorRamCost: 0.01, ScriptOperatorRamCost: 0.01,
@ -86,6 +84,8 @@ CONSTANTS = {
ServerFortifyAmount: 0.002, //Amount by which server's security increases when its hacked/grown ServerFortifyAmount: 0.002, //Amount by which server's security increases when its hacked/grown
ServerWeakenAmount: 0.05, //Amount by which server's security decreases when weakened ServerWeakenAmount: 0.05, //Amount by which server's security decreases when weakened
PurchasedServerLimit: 25,
//Augmentation Constants //Augmentation Constants
AugmentationCostMultiplier: 5, //Used for balancing costs without having to readjust every Augmentation cost AugmentationCostMultiplier: 5, //Used for balancing costs without having to readjust every Augmentation cost
AugmentationRepMultiplier: 2.5, //Used for balancing rep cost without having to readjust every value AugmentationRepMultiplier: 2.5, //Used for balancing rep cost without having to readjust every value
@ -678,7 +678,18 @@ CONSTANTS = {
"World Stock Exchange account and TIX API Access<br>", "World Stock Exchange account and TIX API Access<br>",
LatestUpdate: LatestUpdate:
"V0.26.1<br>" + "v0.26.2<br>" +
"-Significantly lowered hacking exp gain from hacking servers. The exp gain for higher-level servers was lowered more than " +
"that of low level servers. (~16% for lower level servers, up to ~25% for higher-level servers)<br>" +
"-Added deleteServer() Netscript function<br>" +
"-You can now purchase a maximum of 25 servers each run (Deleting a server will allow you to purchase a new one)<br>" +
"-Added autocompletion for './' Terminal command<br>" +
"-Darkweb prices now displayed properly using toLocaleString()<br>" +
"-Added NOT operator (!) and negation operator(-), so negative numbers should be functional now<br>" +
"-Rejected faction invitations will now show up as 'Outstanding Faction Invites' in the Factions page. These " +
"can be accepted at any point in the future<br>" +
"-Added a few more configurable game settings for suppressing messages and faction invitations<br>" +
"v0.26.1<br>" +
"-Added autocompletion for aliases<br>" + "-Added autocompletion for aliases<br>" +
"-Added getServerRam() Netscript function()<br>" + "-Added getServerRam() Netscript function()<br>" +
"-Added getLevelUpgradeCost(n), getRamUpgradeCost(), getCoreUpgradeCost() functions for Netscript Hacknet Node API<br>" + "-Added getLevelUpgradeCost(n), getRamUpgradeCost(), getCoreUpgradeCost() functions for Netscript Hacknet Node API<br>" +

@ -6,11 +6,11 @@ checkIfConnectedToDarkweb = function() {
if (!isValidIPAddress(darkwebIp)) {return;} if (!isValidIPAddress(darkwebIp)) {return;}
if (darkwebIp == Player.getCurrentServer().ip) { if (darkwebIp == Player.getCurrentServer().ip) {
post("You are now connected to the dark web. From the dark web you can purchase illegal items. " + post("You are now connected to the dark web. From the dark web you can purchase illegal items. " +
"Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " + "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
"to purchase an item"); "to purchase an item");
} }
} }
} }
//Handler for dark web commands. The terminal's executeCommand() function will pass //Handler for dark web commands. The terminal's executeCommand() function will pass
@ -41,9 +41,39 @@ executeDarkwebTerminalCommand = function(commandArray) {
listAllDarkwebItems = function() { listAllDarkwebItems = function() {
for (var item in DarkWebItems) { for (var item in DarkWebItems) {
if (DarkWebItems.hasOwnProperty(item)) { if (DarkWebItems.hasOwnProperty(item)) {
post(DarkWebItems[item]); var item = DarkWebItems[item];
//Convert string using toLocaleString
var split = item.split(" - ");
if (split.length == 3 && split[1].charAt(0) == '$') {
split[1] = split[1].slice(1);
split[1] = split[1].replace(/,/g, '');
var price = parseFloat(split[1]);
if (isNaN(price)) {
post(item);
return;
}
price = formatNumber(price, 0);
split[1] = "$" + price.toString();
post(split.join(" - "));
} else {
post(item);
}
} }
} }
var priceString = split[1];
//Check for errors
if (priceString.length == 0 || priceString.charAt(0) != '$') {
return -1;
}
//Remove dollar sign and commas
priceString = priceString.slice(1);
priceString = priceString.replace(/,/g, '');
//Convert string to numeric
var price = parseFloat(priceString);
if (isNaN(price)) {return -1;}
else {return price;}
} }
buyDarkwebItem = function(itemName) { buyDarkwebItem = function(itemName) {
@ -52,7 +82,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram); Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);
post("You have purchased the BruteSSH.exe program. The new program " + post("You have purchased the BruteSSH.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -62,7 +92,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram); Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);
post("You have purchased the FTPCrack.exe program. The new program " + post("You have purchased the FTPCrack.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -72,7 +102,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram); Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);
post("You have purchased the relaySMTP.exe program. The new program " + post("You have purchased the relaySMTP.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -82,7 +112,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram); Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);
post("You have purchased the HTTPWorm.exe program. The new program " + post("You have purchased the HTTPWorm.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -92,7 +122,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram); Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);
post("You have purchased the SQLInject.exe program. The new program " + post("You have purchased the SQLInject.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -102,7 +132,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV1); Player.getHomeComputer().programs.push(Programs.DeepscanV1);
post("You have purchased the DeepscanV1.exe program. The new program " + post("You have purchased the DeepscanV1.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -112,7 +142,7 @@ buyDarkwebItem = function(itemName) {
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV2); Player.getHomeComputer().programs.push(Programs.DeepscanV2);
post("You have purchased the DeepscanV2.exe program. The new program " + post("You have purchased the DeepscanV2.exe program. The new program " +
"can be found on your home computer."); "can be found on your home computer.");
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
@ -133,7 +163,7 @@ parseDarkwebItemPrice = function(itemDesc) {
//Remove dollar sign and commas //Remove dollar sign and commas
priceString = priceString.slice(1); priceString = priceString.slice(1);
priceString = priceString.replace(/,/g, ''); priceString = priceString.replace(/,/g, '');
//Convert string to numeric //Convert string to numeric
var price = parseFloat(priceString); var price = parseFloat(priceString);
if (isNaN(price)) {return -1;} if (isNaN(price)) {return -1;}
@ -151,4 +181,4 @@ DarkWebItems = {
SQLInjectProgram: Programs.SQLInjectProgram + " - $250,000,000 - Opens up SQL Ports", SQLInjectProgram: Programs.SQLInjectProgram + " - $250,000,000 - Opens up SQL Ports",
DeepScanV1Program: Programs.DeepscanV1 + " - $500,000 - Enables 'scan-analyze' with a depth up to 5", DeepScanV1Program: Programs.DeepscanV1 + " - $500,000 - Enables 'scan-analyze' with a depth up to 5",
DeepScanV2Program: Programs.DeepscanV2 + " - $25,000,000 - Enables 'scan-analyze' with a depth up to 10", DeepScanV2Program: Programs.DeepscanV2 + " - $25,000,000 - Enables 'scan-analyze' with a depth up to 10",
} }

@ -630,7 +630,12 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
} }
inviteToFaction = function(faction) { inviteToFaction = function(faction) {
factionInvitationBoxCreate(faction); if (Settings.SuppressFactionInvites) {
faction.alreadyInvited = true;
Player.factionInvitations.push(faction.name);
} else {
factionInvitationBoxCreate(faction);
}
} }
joinFaction = function(faction) { joinFaction = function(faction) {

@ -20,13 +20,15 @@ Reviver.constructors.Message = Message;
function sendMessage(msg) { function sendMessage(msg) {
console.log("sending message: " + msg.filename); console.log("sending message: " + msg.filename);
msg.recvd = true; msg.recvd = true;
showMessage(msg); if (!Settings.SuppressMessages) {
showMessage(msg);
}
addMessageToServer(msg, "home"); addMessageToServer(msg, "home");
} }
function showMessage(msg) { function showMessage(msg) {
var txt = "Message received from unknown sender: <br><br>" + var txt = "Message received from unknown sender: <br><br>" +
"<i>" + msg.msg + "</i><br><br>" + "<i>" + msg.msg + "</i><br><br>" +
"This message was saved as " + msg.filename + " onto your home computer."; "This message was saved as " + msg.filename + " onto your home computer.";
dialogBoxCreate(txt); dialogBoxCreate(txt);
} }
@ -53,7 +55,7 @@ function checkForMessagesToSend() {
var nitesecTest = Messages[MessageFilenames.NiteSecTest]; var nitesecTest = Messages[MessageFilenames.NiteSecTest];
var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest]; var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
var redpill = Messages[MessageFilenames.RedPill]; var redpill = Messages[MessageFilenames.RedPill];
if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) { if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) {
sendMessage(jumper0); sendMessage(jumper0);
} else if (jumper1 && !jumper1.recvd && Player.hacking_skill >= 40) { } else if (jumper1 && !jumper1.recvd && Player.hacking_skill >= 40) {
@ -100,61 +102,61 @@ MessageFilenames = {
function initMessages() { function initMessages() {
//Reset //Reset
Messages = {}; Messages = {};
//jump3R Messages //jump3R Messages
AddToAllMessages(new Message(MessageFilenames.Jumper0, AddToAllMessages(new Message(MessageFilenames.Jumper0,
"I know you can sense it. I know you're searching for it. " + "I know you can sense it. I know you're searching for it. " +
"It's why you spend night after " + "It's why you spend night after " +
"night at your computer. <br><br>It's real, I've seen it. And I can " + "night at your computer. <br><br>It's real, I've seen it. And I can " +
"help you find it. But not right now. You're not ready yet.<br><br>-jump3R")); "help you find it. But not right now. You're not ready yet.<br><br>-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper1, AddToAllMessages(new Message(MessageFilenames.Jumper1,
"Soon you will be contacted by a hacking group known as CyberSec. " + "Soon you will be contacted by a hacking group known as CyberSec. " +
"They can help you with your search. <br><br>" + "They can help you with your search. <br><br>" +
"You should join them, garner their favor, and " + "You should join them, garner their favor, and " +
"exploit them for their Augmentations. But do not trust them. " + "exploit them for their Augmentations. But do not trust them. " +
"They are not what they seem. No one is.<br><br>" + "They are not what they seem. No one is.<br><br>" +
"-jump3R")); "-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper2, AddToAllMessages(new Message(MessageFilenames.Jumper2,
"Do not try to save the world. There is no world to save. If " + "Do not try to save the world. There is no world to save. If " +
"you want to find the truth, worry only about yourself. Ethics and " + "you want to find the truth, worry only about yourself. Ethics and " +
"morals will get you killed. <br><br>Watch out for a hacking group known as NiteSec." + "morals will get you killed. <br><br>Watch out for a hacking group known as NiteSec." +
"<br><br>-jump3R")); "<br><br>-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper3, AddToAllMessages(new Message(MessageFilenames.Jumper3,
"You must learn to walk before you can run. And you must " + "You must learn to walk before you can run. And you must " +
"run before you can fly. Look for the black hand. <br><br>" + "run before you can fly. Look for the black hand. <br><br>" +
"I.I.I.I <br><br>-jump3R")); "I.I.I.I <br><br>-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper4, AddToAllMessages(new Message(MessageFilenames.Jumper4,
"To find what you are searching for, you must understand the bits. " + "To find what you are searching for, you must understand the bits. " +
"The bits are all around us. The runners will help you.<br><br>" + "The bits are all around us. The runners will help you.<br><br>" +
"-jump3R")); "-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper5, AddToAllMessages(new Message(MessageFilenames.Jumper5,
"Build your wings and fly<br><br>-jump3R<br><br> " + "Build your wings and fly<br><br>-jump3R<br><br> " +
"The fl1ght.exe program was added to your home computer")); "The fl1ght.exe program was added to your home computer"));
//Messages from hacking factions //Messages from hacking factions
AddToAllMessages(new Message(MessageFilenames.CyberSecTest, AddToAllMessages(new Message(MessageFilenames.CyberSecTest,
"We've been watching you. Your skills are very impressive. But you're wasting " + "We've been watching you. Your skills are very impressive. But you're wasting " +
"your talents. If you join us, you can put your skills to good use and change " + "your talents. If you join us, you can put your skills to good use and change " +
"the world for the better. If you join us, we can unlock your full potential. <br><br>" + "the world for the better. If you join us, we can unlock your full potential. <br><br>" +
"But first, you must pass our test. Find and hack our server using the Terminal. <br><br>" + "But first, you must pass our test. Find and hack our server using the Terminal. <br><br>" +
"-CyberSec")); "-CyberSec"));
AddToAllMessages(new Message(MessageFilenames.NiteSecTest, AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
"People say that the corrupted governments and corporations rule the world. " + "People say that the corrupted governments and corporations rule the world. " +
"Yes, maybe they do. But do you know who everyone really fears? People " + "Yes, maybe they do. But do you know who everyone really fears? People " +
"like us. Because they can't hide from us. Because they can't fight shadows " + "like us. Because they can't hide from us. Because they can't fight shadows " +
"and ideas with bullets. <br><br>" + "and ideas with bullets. <br><br>" +
"Join us, and people will fear you, too. <br><br>" + "Join us, and people will fear you, too. <br><br>" +
"Find and hack our hidden server using the Terminal. Then, we will contact you again." + "Find and hack our hidden server using the Terminal. Then, we will contact you again." +
"<br><br>-NiteSec")); "<br><br>-NiteSec"));
AddToAllMessages(new Message(MessageFilenames.BitRunnersTest, AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
"We know what you are doing. We know what drives you. We know " + "We know what you are doing. We know what drives you. We know " +
"what you are looking for. <br><br> " + "what you are looking for. <br><br> " +
"We can help you find the answers.<br><br>" + "We can help you find the answers.<br><br>" +
"run4theh111z")); "run4theh111z"));
AddToAllMessages(new Message(MessageFilenames.RedPill, AddToAllMessages(new Message(MessageFilenames.RedPill,
"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" + "@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" +
")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" + ")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" +
"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" + "@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" +
"DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)")); "DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)"));
} }

@ -131,6 +131,14 @@ function evaluate(exp, workerScript) {
reject(e); reject(e);
}); });
break; break;
case "UnaryExpression":
var p = evalUnary(exp, workerScript, resolve, reject);
p.then(function(res) {
resolve(res);
}).catch(function(e) {
reject(e);
});
break;
case "AssignmentExpression": case "AssignmentExpression":
var p = evalAssignment(exp, workerScript); var p = evalAssignment(exp, workerScript);
p.then(function(res) { p.then(function(res) {
@ -210,58 +218,6 @@ function evaluate(exp, workerScript) {
}); // End Promise }); // End Promise
} }
/*
function evalFunction(exp, workerScript){
return new Promise(function(resolve, reject) {
if (exp.callee.type!="Identifier"){
reject(makeRuntimeRejectMsg(workerScript, "callee must be an Identifier"));
return;
}
switch(exp.callee.name){
case "print":
if (exp.arguments.length != 1) {
return reject(makeRuntimeRejectMsg(workerScript, "print() call has incorrect number of arguments. Takes 1 argument"));
}
var evaluatePromise = evaluate(exp.arguments[0], workerScript);
evaluatePromise.then(function(res) {
workerScript.scriptRef.log(res.toString());
resolve(true);
}).catch(function(e) {
reject(e);
});
break;
case "scan":
if (exp.arguments.length != 1) {
exp.arguments = [{value:Player.getCurrentServer().hostname,type:"Literal"}];
}
var ipPromise = evaluate(exp.arguments[0], workerScript);
ipPromise.then(function (ip) {
var server = getServer(ip);
if (server == null) {
workerScript.scriptRef.log('getServerOpenPortsCount() failed. Invalid IP or hostname passed in: ' + ip);
return reject(makeRuntimeRejectMsg(workerScript, 'Invalid IP or hostname passed into getServerOpenPortsCount() command'));
}
var out = [];
for (var i = 0; i < server.serversOnNetwork.length; i++) {
var entry = server.getServerOnNetwork(i).hostname;
if (entry == null) {
continue;
}
out.push(entry);
}
workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
resolve(out);
}).catch(function(e) {
reject(e);
});
break;
default:
reject(makeRuntimeRejectMsg(workerScript, "Invalid function: " + exp.callee));
}
});
}
*/
function evalBinary(exp, workerScript){ function evalBinary(exp, workerScript){
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var expLeftPromise = evaluate(exp.left, workerScript); var expLeftPromise = evaluate(exp.left, workerScript);
@ -329,17 +285,24 @@ function evalBinary(exp, workerScript){
} }
function evalUnary(exp, workerScript){ function evalUnary(exp, workerScript){
var env = workerScript.env;
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var expLeftPromise = evaluate(exp.left, workerScript); if (env.stopFlag) {return reject(workerScript);}
expLeftPromise.then(function(expLeft) { var p = evaluate(exp.argument, workerScript);
switch(exp.operator){ p.then(function(res) {
case "++": if (exp.operator == "!") {
break resolve(!res);
case "--": } else if (exp.operator == "-") {
break; if (isNaN(res)) {
resolve(res);
} else {
resolve(-1 * res);
}
} else {
reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator));
} }
}, function(e) { }).catch(function(e) {
reject(e); reject(e);
}); });
}); });
} }
@ -534,113 +497,6 @@ function evaluateWhile(exp, workerScript) {
}); });
} }
/*
function evaluateHacknetNode(exp, workerScript) {
console.log("here");
var env = workerScript.env;
return new Promise(function(resolve, reject) {
setTimeout(function() {
if (exp.index == null) {
if ((exp.op.type == "call" && exp.op.func.value == "length") ||
(exp.op.type == "var" && exp.op.value == "length")) {
resolve(Player.hacknetNodes.length);
workerScript.scriptRef.log("hacknetnodes.length returned " + Player.hacknetNodes.length);
return;
} else {
workerScript.scriptRef.log("Invalid/null index for hacknetnodes");
reject(makeRuntimeRejectMsg(workerScript, "Invalid/null index. hacknetnodes array must be accessed with an index"));
return;
}
}
var indexPromise = evaluate(exp.index.value, workerScript);
indexPromise.then(function(index) {
if (isNaN(index) || index >= Player.hacknetNodes.length || index < 0) {
workerScript.scriptRef.log("Invalid index value for hacknetnodes[]");
reject(makeRuntimeRejectMsg(workerScript, "Invalid index value for hacknetnodes[]."));
return;
}
var nodeObj = Player.hacknetNodes[index];
if (exp.op == null) {
reject(makeRuntimeRejectMsg(workerScript, "No operator or property called for hacknetnodes. Usage: hacknetnodes[i].property/operator"));
return;
} else if (exp.op.type == "var") {
//Get properties: level, ram, cores
switch(exp.op.value) {
case "level":
resolve(nodeObj.level);
break;
case "ram":
resolve(nodeObj.ram);
break;
case "cores":
resolve(nodeObj.numCores);
break;
default:
reject(makeRuntimeRejectMsg(workerScript, "Unrecognized property for Hacknet Node. Valid properties: ram, cores, level"));
break;
}
} else if (exp.op.type == "call") {
switch(exp.op.func.value) {
case "upgradeLevel":
if (exp.op.args.length == 1) {
var argPromise = evaluate(exp.op.args[0], workerScript);
argPromise.then(function(arg) {
if (isNaN(arg) || arg < 0) {
reject(makeRuntimeRejectMsg(workerScript, "Invalid argument passed into upgradeLevel()"));
return;
}
arg = Math.round(arg);
var res = nodeObj.purchaseLevelUpgrade(arg);
if (res) {
workerScript.scriptRef.log("Upgraded " + nodeObj.name + " " + arg + " times to level " + nodeObj.level);
}
resolve(res);
}, function(e) {
reject(e);
});
} else {
var res = nodeObj.purchaseLevelUpgrade(1);
if (res) {
workerScript.scriptRef.log("Upgraded " + nodeObj.name + " once to level " + nodeObj.level);
}
resolve(res);
}
break;
case "upgradeRam":
var res = nodeObj.purchaseRamUpgrade();
if (res) {
workerScript.scriptRef.log("Upgraded " + nodeObj.name + "'s RAM to " + nodeObj.ram + "GB");
}
resolve(res);
break;
case "upgradeCore":
var res = nodeObj.purchaseCoreUpgrade();
if (res) {
workerScript.scriptRef.log("Upgraded " + nodeObj.name + "'s number of cores to " + nodeObj.numCores);
}
resolve(res);
break;
default:
reject(makeRuntimeRejectMsg(workerScript, "Unrecognized function/operator for hacknet node. Valid functions: upgradeLevel(n), upgradeRam(), upgradeCore()"));
break;
}
} else {
reject(makeRuntimeRejectMsg(workerScript, "Unrecognized operation for hacknet node"));
return;
}
}, function(e) {
reject(e);
});
}, CONSTANTS.CodeInstructionRunTime);
}, function(e) {
reject(e);
});
}
*/
function evaluateProg(exp, workerScript, index) { function evaluateProg(exp, workerScript, index) {
var env = workerScript.env; var env = workerScript.env;
@ -791,7 +647,7 @@ function scriptCalculateExpGain(server) {
if (server.baseDifficulty == null) { if (server.baseDifficulty == null) {
server.baseDifficulty = server.hackDifficulty; server.baseDifficulty = server.hackDifficulty;
} }
return (server.baseDifficulty * Player.hacking_exp_mult * 0.4 + 2); return (server.baseDifficulty * Player.hacking_exp_mult * 0.3 + 2);
} }
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument //The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument

@ -654,6 +654,12 @@ function NetscriptFunctions(workerScript) {
return ""; return "";
} }
if (Player.purchasedServers.length >= CONSTANTS.PurchasedServerLimit) {
workerScript.scriptRef.log("Error: You have reached the maximum limit of " + CONSTANTS.PurchasedServerLimit +
" servers. You cannot purchase any more.");
return "";
}
ram = Math.round(ram); ram = Math.round(ram);
if (isNaN(ram) || !powerOfTwo(ram)) { if (isNaN(ram) || !powerOfTwo(ram)) {
workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2"); workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2");
@ -677,6 +683,56 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + formatNumber(cost, 2)); workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + formatNumber(cost, 2));
return newServ.hostname; return newServ.hostname;
}, },
deleteServer : function(hostname) {
var hostnameStr = String(hostname);
hostnameStr = hostnameStr.replace(/\s\s+/g, '');
var server = GetServerByHostname(hostnameStr);
if (server == null) {
workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed");
return false;
}
if (!server.purchasedByPlayer) {
workerScript.scriptRef.log("Error: Server " + server.hostname + " is not a purchased server. " +
"Cannot be deleted. deleteSErver failed");
return false;
}
var ip = server.ip;
//Delete from all servers
delete AllServers[ip];
//Delete from player's purchasedServers array
var found = false;
for (var i = 0; i < Player.purchasedServers.length; ++i) {
if (ip == Player.purchasedServers[i]) {
found = true;
Player.purchasedServers.splice(i, 1);
break;
}
}
if (!found) {
workerScript.scriptRef.log("Error: Could not identify server " + server.hostname +
"as a purchased server. This is likely a bug please contact game dev");
return false;
}
//Delete from home computer
found = false;
var homeComputer = Player.getHomeComputer();
for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {
if (ip == homeComputer.serversOnNetwork[i]) {
homeComputer.serversOnNetwork.splice(i, 1);
workerScript.scriptRef.log("Deleted server " + hostnameStr);
return true;
}
}
//Wasn't found on home computer
workerScript.scriptRef.log("Error: Could not find server " + server.hostname +
"as a purchased server. This is likely a bug please contact game dev");
return false;
},
round : function(n) { round : function(n) {
if (isNaN(n)) {return 0;} if (isNaN(n)) {return 0;}
return Math.round(n); return Math.round(n);

@ -1,6 +1,6 @@
/* Worker code, contains Netscript scripts that are actually running */ /* Worker code, contains Netscript scripts that are actually running */
//TODO Tested For and while and generic call statements. Have not tested if statements //TODO Tested For and while and generic call statements. Have not tested if statements
/* Actual Worker Code */ /* Actual Worker Code */
function WorkerScript(runningScriptObj) { function WorkerScript(runningScriptObj) {
@ -53,7 +53,7 @@ function runScriptsLoop() {
workerScripts[i].env.stopFlag = true; workerScripts[i].env.stopFlag = true;
continue; continue;
} }
workerScripts[i].running = true; workerScripts[i].running = true;
var p = evaluate(ast, workerScripts[i]); var p = evaluate(ast, workerScripts[i]);
//Once the code finishes (either resolved or rejected, doesnt matter), set its //Once the code finishes (either resolved or rejected, doesnt matter), set its
@ -79,9 +79,9 @@ function runScriptsLoop() {
var serverIp = errorTextArray[1]; var serverIp = errorTextArray[1];
var scriptName = errorTextArray[2]; var scriptName = errorTextArray[2];
var errorMsg = errorTextArray[3]; var errorMsg = errorTextArray[3];
dialogBoxCreate("Script runtime error: <br>Server Ip: " + serverIp + dialogBoxCreate("Script runtime error: <br>Server Ip: " + serverIp +
"<br>Script name: " + scriptName + "<br>Script name: " + scriptName +
"<br>Args:" + printArray(w.args) + "<br>" + errorMsg); "<br>Args:" + printArray(w.args) + "<br>" + errorMsg);
w.scriptRef.log("Script crashed with runtime error"); w.scriptRef.log("Script crashed with runtime error");
} else { } else {
@ -89,7 +89,7 @@ function runScriptsLoop() {
} }
w.running = false; w.running = false;
w.env.stopFlag = true; w.env.stopFlag = true;
} else if (isScriptErrorMessage(w)) { } else if (isScriptErrorMessage(w)) {
dialogBoxCreate("Script runtime unknown error. This is a bug please contact game developer"); dialogBoxCreate("Script runtime unknown error. This is a bug please contact game developer");
console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN"); console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN");
@ -100,13 +100,13 @@ function runScriptsLoop() {
}); });
} }
} }
//Delete any scripts that finished or have been killed. Loop backwards bc removing //Delete any scripts that finished or have been killed. Loop backwards bc removing
//items fucks up the indexing //items fucks up the indexing
for (var i = workerScripts.length - 1; i >= 0; i--) { for (var i = workerScripts.length - 1; i >= 0; i--) {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) { if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
console.log("Deleting script: " + workerScripts[i].name); console.log("Deleting script: " + workerScripts[i].name);
//Delete script from the runningScripts array on its host serverIp //Delete script from the runningScripts array on its host serverIp
var ip = workerScripts[i].serverIp; var ip = workerScripts[i].serverIp;
var name = workerScripts[i].name; var name = workerScripts[i].name;
for (var j = 0; j < AllServers[ip].runningScripts.length; j++) { for (var j = 0; j < AllServers[ip].runningScripts.length; j++) {
@ -116,18 +116,18 @@ function runScriptsLoop() {
break; break;
} }
} }
//Free RAM //Free RAM
AllServers[ip].ramUsed -= workerScripts[i].ramUsage; AllServers[ip].ramUsed -= workerScripts[i].ramUsage;
//Delete script from Active Scripts //Delete script from Active Scripts
deleteActiveScriptsItem(workerScripts[i]); deleteActiveScriptsItem(workerScripts[i]);
//Delete script from workerScripts //Delete script from workerScripts
workerScripts.splice(i, 1); workerScripts.splice(i, 1);
} }
} }
setTimeout(runScriptsLoop, 10000); setTimeout(runScriptsLoop, 10000);
} }
@ -145,10 +145,10 @@ function killWorkerScript(runningScriptObj, serverIp) {
return false; return false;
} }
//Queues a script to be run //Queues a script to be run
function addWorkerScript(runningScriptObj, server) { function addWorkerScript(runningScriptObj, server) {
var filename = runningScriptObj.filename; var filename = runningScriptObj.filename;
//Update server's ram usage //Update server's ram usage
var threads = 1; var threads = 1;
if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) { if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
@ -156,18 +156,18 @@ function addWorkerScript(runningScriptObj, server) {
} else { } else {
runningScriptObj.threads = 1; runningScriptObj.threads = 1;
} }
var ramUsage = runningScriptObj.scriptRef.ramUsage * threads var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
* Math.pow(CONSTANTS.MultithreadingRAMCost, threads-1); * Math.pow(CONSTANTS.MultithreadingRAMCost, threads-1);
server.ramUsed += ramUsage; server.ramUsed += ramUsage;
//Create the WorkerScript //Create the WorkerScript
var s = new WorkerScript(runningScriptObj); var s = new WorkerScript(runningScriptObj);
s.serverIp = server.ip; s.serverIp = server.ip;
s.ramUsage = ramUsage; s.ramUsage = ramUsage;
//Add the WorkerScript to the Active Scripts list //Add the WorkerScript to the Active Scripts list
addActiveScriptsItem(s); addActiveScriptsItem(s);
//Add the WorkerScript //Add the WorkerScript
workerScripts.push(s); workerScripts.push(s);
return; return;
@ -181,4 +181,4 @@ function updateOnlineScriptTimes(numCycles = 1) {
} }
} }
runScriptsLoop(); runScriptsLoop();

File diff suppressed because it is too large Load Diff

@ -15,7 +15,7 @@ function prestigeAugmentation() {
Player.lifetime_agility += Player.agility; Player.lifetime_agility += Player.agility;
Player.total_charisma += Player.charisma; Player.total_charisma += Player.charisma;
Player.lifetime_charisma += Player.charisma; Player.lifetime_charisma += Player.charisma;
//Crime statistics //Crime statistics
Player.numTimesShopliftedTotal += Player.numTimesShoplifted; Player.numTimesShopliftedTotal += Player.numTimesShoplifted;
Player.numTimesShopliftedLifetime += Player.numTimesShoplifted; Player.numTimesShopliftedLifetime += Player.numTimesShoplifted;
@ -41,52 +41,53 @@ function prestigeAugmentation() {
Player.numTimesHeistTotal += Player.numTimesHeist; Player.numTimesHeistTotal += Player.numTimesHeist;
Player.numTimesHeistLifetime += Player.numTimesHeist; Player.numTimesHeistLifetime += Player.numTimesHeist;
Player.numTimesHeist = 0; Player.numTimesHeist = 0;
Player.karma = 0; Player.karma = 0;
//Reset stats //Reset stats
Player.hacking_skill = 1; Player.hacking_skill = 1;
Player.strength = 1; Player.strength = 1;
Player.defense = 1; Player.defense = 1;
Player.dexterity = 1; Player.dexterity = 1;
Player.agility = 1; Player.agility = 1;
Player.charisma = 1; Player.charisma = 1;
Player.hacking_exp = 0; Player.hacking_exp = 0;
Player.strength_exp = 0; Player.strength_exp = 0;
Player.defense_exp = 0; Player.defense_exp = 0;
Player.dexterity_exp = 0; Player.dexterity_exp = 0;
Player.agility_exp = 0; Player.agility_exp = 0;
Player.charisma_exp = 0; Player.charisma_exp = 0;
Player.money = 1000; Player.money = 1000;
Player.city = Locations.Sector12; Player.city = Locations.Sector12;
Player.location = ""; Player.location = "";
Player.companyName = ""; Player.companyName = "";
Player.companyPosition = ""; Player.companyPosition = "";
Player.currentServer = ""; Player.currentServer = "";
Player.discoveredServers = []; Player.discoveredServers = [];
Player.purchasedServers = []; Player.purchasedServers = [];
Player.factions = []; Player.factions = [];
Player.factionInvitations = [];
Player.queuedAugmentations = []; Player.queuedAugmentations = [];
Player.startAction = false; Player.startAction = false;
Player.actionTime = 0; Player.actionTime = 0;
Player.isWorking = false; Player.isWorking = false;
Player.currentWorkFactionName = ""; Player.currentWorkFactionName = "";
Player.currentWorkFactionDescription = ""; Player.currentWorkFactionDescription = "";
this.createProgramName = ""; this.createProgramName = "";
this.className = ""; this.className = "";
this.crimeType = ""; this.crimeType = "";
Player.workHackExpGainRate = 0; Player.workHackExpGainRate = 0;
Player.workStrExpGainRate = 0; Player.workStrExpGainRate = 0;
Player.workDefExpGainRate = 0; Player.workDefExpGainRate = 0;
@ -95,7 +96,7 @@ function prestigeAugmentation() {
Player.workChaExpGainRate = 0; Player.workChaExpGainRate = 0;
Player.workRepGainRate = 0; Player.workRepGainRate = 0;
Player.workMoneyGainRate = 0; Player.workMoneyGainRate = 0;
Player.workHackExpGained = 0; Player.workHackExpGained = 0;
Player.workStrExpGained = 0; Player.workStrExpGained = 0;
Player.workDefExpGained = 0; Player.workDefExpGained = 0;
@ -104,18 +105,18 @@ function prestigeAugmentation() {
Player.workChaExpGained = 0; Player.workChaExpGained = 0;
Player.workRepGained = 0; Player.workRepGained = 0;
Player.workMoneyGained = 0; Player.workMoneyGained = 0;
Player.timeWorked = 0; Player.timeWorked = 0;
Player.lastUpdate = new Date().getTime(); Player.lastUpdate = new Date().getTime();
//Delete all Worker Scripts objects //Delete all Worker Scripts objects
for (var i = 0; i < workerScripts.length; ++i) { for (var i = 0; i < workerScripts.length; ++i) {
deleteActiveScriptsItem(workerScripts[i]); deleteActiveScriptsItem(workerScripts[i]);
workerScripts[i].env.stopFlag = true; workerScripts[i].env.stopFlag = true;
} }
workerScripts.length = 0; workerScripts.length = 0;
var homeComp = Player.getHomeComputer(); var homeComp = Player.getHomeComputer();
//Delete all servers except home computer //Delete all servers except home computer
for (var member in AllServers) { for (var member in AllServers) {
@ -127,7 +128,7 @@ function prestigeAugmentation() {
delete SpecialServerIps[member]; delete SpecialServerIps[member];
} }
SpecialServersIps = null; SpecialServersIps = null;
//Reset home computer (only the programs) and add to AllServers //Reset home computer (only the programs) and add to AllServers
homeComp.programs.length = 0; homeComp.programs.length = 0;
homeComp.runningScripts = []; homeComp.runningScripts = [];
@ -136,12 +137,12 @@ function prestigeAugmentation() {
homeComp.isOnline = true; homeComp.isOnline = true;
homeComp.ramUsed = 0; homeComp.ramUsed = 0;
homeComp.programs.push(Programs.NukeProgram); homeComp.programs.push(Programs.NukeProgram);
if (augmentationExists(AugmentationNames.Neurolink) && if (augmentationExists(AugmentationNames.Neurolink) &&
Augmentations[AugmentationNames.Neurolink].owned) { Augmentations[AugmentationNames.Neurolink].owned) {
homeComp.programs.push(Programs.FTPCrackProgram); homeComp.programs.push(Programs.FTPCrackProgram);
homeComp.programs.push(Programs.RelaySMTPProgram); homeComp.programs.push(Programs.RelaySMTPProgram);
} }
if (augmentationExists(AugmentationNames.CashRoot) && if (augmentationExists(AugmentationNames.CashRoot) &&
Augmentations[AugmentationNames.CashRoot].owned) { Augmentations[AugmentationNames.CashRoot].owned) {
Player.money = 1000000; Player.money = 1000000;
homeComp.programs.push(Programs.BruteSSHProgram); homeComp.programs.push(Programs.BruteSSHProgram);
@ -149,57 +150,57 @@ function prestigeAugmentation() {
Player.currentServer = homeComp.ip; Player.currentServer = homeComp.ip;
Player.homeComputer = homeComp.ip; Player.homeComputer = homeComp.ip;
AddToAllServers(homeComp); AddToAllServers(homeComp);
//Re-create foreign servers //Re-create foreign servers
SpecialServerIps = new SpecialServerIpsMap(); //Must be done before initForeignServers() SpecialServerIps = new SpecialServerIpsMap(); //Must be done before initForeignServers()
initForeignServers(); initForeignServers();
//Darkweb is purchase-able //Darkweb is purchase-able
document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button"); document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button");
//Reset statistics of all scripts on home computer //Reset statistics of all scripts on home computer
for (var i = 0; i < homeComp.scripts.length; ++i) { for (var i = 0; i < homeComp.scripts.length; ++i) {
var s = homeComp.scripts[i]; var s = homeComp.scripts[i];
} }
//Delete messages on home computer //Delete messages on home computer
homeComp.messages.length = 0; homeComp.messages.length = 0;
//Delete Hacknet Nodes //Delete Hacknet Nodes
Player.hacknetNodes.length = 0; Player.hacknetNodes.length = 0;
Player.totalHacknetNodeProduction = 0; Player.totalHacknetNodeProduction = 0;
//Gain favor for Companies //Gain favor for Companies
for (var member in Companies) { for (var member in Companies) {
if (Companies.hasOwnProperty(member)) { if (Companies.hasOwnProperty(member)) {
Companies[member].gainFavor(); Companies[member].gainFavor();
} }
} }
//Gain favor for factions //Gain favor for factions
for (var member in Factions) { for (var member in Factions) {
if (Factions.hasOwnProperty(member)) { if (Factions.hasOwnProperty(member)) {
Factions[member].gainFavor(); Factions[member].gainFavor();
} }
} }
//Stop a Terminal action if there is onerror //Stop a Terminal action if there is onerror
if (Engine._actionInProgress) { if (Engine._actionInProgress) {
Engine._actionInProgress = false; Engine._actionInProgress = false;
Terminal.finishAction(true); Terminal.finishAction(true);
} }
//Re-initialize things - This will update any changes //Re-initialize things - This will update any changes
initFactions(); //Factions must be initialized before augmentations initFactions(); //Factions must be initialized before augmentations
initAugmentations(); initAugmentations();
initCompanies(); initCompanies();
//Clear terminal //Clear terminal
$("#terminal tr:not(:last)").remove(); $("#terminal tr:not(:last)").remove();
postNetburnerText(); postNetburnerText();
//Messages //Messages
initMessages(); initMessages();
//Reset Stock market //Reset Stock market
if (Player.hasWseAccount) { if (Player.hasWseAccount) {
initStockMarket(); initStockMarket();
@ -210,13 +211,13 @@ function prestigeAugmentation() {
stockMarketList.removeChild(stockMarketList.firstChild); stockMarketList.removeChild(stockMarketList.firstChild);
} }
} }
Player.playtimeSinceLastAug = 0; Player.playtimeSinceLastAug = 0;
var mainMenu = document.getElementById("mainmenu-container"); var mainMenu = document.getElementById("mainmenu-container");
mainMenu.style.visibility = "visible"; mainMenu.style.visibility = "visible";
Engine.loadTerminalContent(); Engine.loadTerminalContent();
//Red Pill //Red Pill
if (augmentationExists(AugmentationNames.TheRedPill) && if (augmentationExists(AugmentationNames.TheRedPill) &&
Augmentations[AugmentationNames.TheRedPill].owned) { Augmentations[AugmentationNames.TheRedPill].owned) {
@ -227,4 +228,4 @@ function prestigeAugmentation() {
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip); DaedalusServer.serversOnNetwork.push(WorldDaemon.ip);
} }
} }
} }

@ -173,6 +173,8 @@ function calculateRamUsage(codeCopy) {
var getServerSecurityCount = numOccurrences(codeCopy, "getServerSecurityLevel("); var getServerSecurityCount = numOccurrences(codeCopy, "getServerSecurityLevel(");
var getServerBaseSecurityCount = numOccurrences(codeCopy, "getServerBaseSecurityLevel("); var getServerBaseSecurityCount = numOccurrences(codeCopy, "getServerBaseSecurityLevel(");
var getServerReqdHackingCount = numOccurrences(codeCopy, "getServerRequiredHackingLevel("); var getServerReqdHackingCount = numOccurrences(codeCopy, "getServerRequiredHackingLevel(");
var getServerNumPortsReqdCount = numOccurrences(codeCopy, "getServerNumPortsRequired(");
var getServerRamCount = numOccurrences(codeCopy, "getServerRam(");
var fileExistsCount = numOccurrences(codeCopy, "fileExists("); var fileExistsCount = numOccurrences(codeCopy, "fileExists(");
var isRunningCount = numOccurrences(codeCopy, "isRunning("); var isRunningCount = numOccurrences(codeCopy, "isRunning(");
var numOperators = numNetscriptOperators(codeCopy); var numOperators = numNetscriptOperators(codeCopy);
@ -185,7 +187,8 @@ function calculateRamUsage(codeCopy) {
numOccurrences(codeCopy, "getStockPosition("); numOccurrences(codeCopy, "getStockPosition(");
var scriptBuySellStockCount = numOccurrences(codeCopy, "buyStock(") + var scriptBuySellStockCount = numOccurrences(codeCopy, "buyStock(") +
numOccurrences(codeCopy, "sellStock("); numOccurrences(codeCopy, "sellStock(");
var scriptPurchaseServerCount = numOccurrences(codeCopy, "purchaseServer("); var scriptPurchaseServerCount = numOccurrences(codeCopy, "purchaseServer(") +
numOccurrences(codeCopy, "deleteServer(");
var scriptRoundCount = numOccurrences(codeCopy, "round("); var scriptRoundCount = numOccurrences(codeCopy, "round(");
var scriptWriteCount = numOccurrences(codeCopy, "write("); var scriptWriteCount = numOccurrences(codeCopy, "write(");
var scriptReadCount = numOccurrences(codeCopy, "read("); var scriptReadCount = numOccurrences(codeCopy, "read(");
@ -210,11 +213,13 @@ function calculateRamUsage(codeCopy) {
(hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) + (hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) +
(getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) + (getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) +
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) + (getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) + (getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerCost) +
(getServerMaxMoneyCount * CONSTANTS.ScriptGetServerMoneyRamCost) + (getServerMaxMoneyCount * CONSTANTS.ScriptGetServerCost) +
(getServerSecurityCount * CONSTANTS.ScriptGetServerSecurityRamCost) + (getServerSecurityCount * CONSTANTS.ScriptGetServerCost) +
(getServerBaseSecurityCount * CONSTANTS.ScriptGetServerSecurityRamCost) + (getServerBaseSecurityCount * CONSTANTS.ScriptGetServerCost) +
(getServerReqdHackingCount * CONSTANTS.ScriptGetServerReqdHackRamCost) + (getServerReqdHackingCount * CONSTANTS.ScriptGetServerCost) +
(getServerNumPortsReqdCount * CONSTANTS.ScriptGetServerCost) +
(getServerRamCount * CONSTANTS.ScriptGetServerCost) +
(fileExistsCount * CONSTANTS.ScriptFileExistsRamCost) + (fileExistsCount * CONSTANTS.ScriptFileExistsRamCost) +
(isRunningCount * CONSTANTS.ScriptIsRunningRamCost) + (isRunningCount * CONSTANTS.ScriptIsRunningRamCost) +
(numOperators * CONSTANTS.ScriptOperatorRamCost) + (numOperators * CONSTANTS.ScriptOperatorRamCost) +

@ -8,7 +8,15 @@ purchaseServer = function(ram, cost) {
dialogBoxCreate("You don't have enough money to purchase this server!"); dialogBoxCreate("You don't have enough money to purchase this server!");
return; return;
} }
//Maximum of 30 servers
if (Player.purchasedServers.length >= CONSTANTS.PurchasedServerLimit) {
dialogBoxCreate("You have reached the maximum limit of " + CONSTANTS.PurchasedServerLimit + " servers. " +
"You cannot purchase any more. You can " +
"delete some of your purchased servers using the deleteServer() Netscript function in a script");
return;
}
var newServ = new Server(); var newServ = new Server();
var hostname = document.getElementById("purchase-server-box-input").value; var hostname = document.getElementById("purchase-server-box-input").value;
hostname = hostname.replace(/\s\s+/g, ''); hostname = hostname.replace(/\s\s+/g, '');
@ -16,21 +24,21 @@ purchaseServer = function(ram, cost) {
dialogBoxCreate("You must enter a hostname for your new server!"); dialogBoxCreate("You must enter a hostname for your new server!");
return; return;
} }
//Create server //Create server
newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram); newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram);
AddToAllServers(newServ); AddToAllServers(newServ);
//Add to Player's purchasedServers array //Add to Player's purchasedServers array
Player.purchasedServers.push(newServ.ip); Player.purchasedServers.push(newServ.ip);
//Connect new server to home computer //Connect new server to home computer
var homeComputer = Player.getHomeComputer(); var homeComputer = Player.getHomeComputer();
homeComputer.serversOnNetwork.push(newServ.ip); homeComputer.serversOnNetwork.push(newServ.ip);
newServ.serversOnNetwork.push(homeComputer.ip); newServ.serversOnNetwork.push(homeComputer.ip);
Player.loseMoney(cost); Player.loseMoney(cost);
dialogBoxCreate("Server successfully purchased with hostname " + hostname); dialogBoxCreate("Server successfully purchased with hostname " + hostname);
} }
@ -40,11 +48,11 @@ purchaseRamForHomeComputer = function(cost) {
dialogBoxCreate("You do not have enough money to purchase additional RAM for your home computer"); dialogBoxCreate("You do not have enough money to purchase additional RAM for your home computer");
return; return;
} }
var homeComputer = Player.getHomeComputer(); var homeComputer = Player.getHomeComputer();
homeComputer.maxRam *= 2; homeComputer.maxRam *= 2;
Player.loseMoney(cost); Player.loseMoney(cost);
dialogBoxCreate("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM."); dialogBoxCreate("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
} }

@ -1,16 +1,18 @@
/* Settings.js */ /* Settings.js */
Settings = { Settings = {
CodeInstructionRunTime: 100, CodeInstructionRunTime: 100,
suppressMessages: false,
MaxLogCapacity: 50, MaxLogCapacity: 50,
MaxPortCapacity: 50, MaxPortCapacity: 50,
SuppressMessages: false,
SuppressFactionInvites: false,
} }
function initSettings() { function initSettings() {
Settings.CodeInstructionRunTime = 100; Settings.CodeInstructionRunTime = 100;
Settings.suppressMessages = false;
Settings.MaxLogCapacity = 50; Settings.MaxLogCapacity = 50;
Settings.MaxPortCapacity = 50; Settings.MaxPortCapacity = 50;
Settings.SuppressMessages = false;
Settings.SuppressFactionInvites = false;
} }
function setSettingsLabels() { function setSettingsLabels() {
@ -20,4 +22,8 @@ function setSettingsLabels() {
= Settings.MaxLogCapacity; = Settings.MaxLogCapacity;
document.getElementById("settingsNSPortRangeValLabel").innerHTML document.getElementById("settingsNSPortRangeValLabel").innerHTML
= Settings.MaxPortCapacity; = Settings.MaxPortCapacity;
document.getElementById("settingsSuppressMessages").checked
= Settings.SuppressMessages;
document.getElementById("settingsSuppressFactionInvites").checked
= Settings.SuppressFactionInvites;
} }

@ -175,7 +175,9 @@ function tabCompletion(command, arg, allPossibilities, index=0) {
if (!(allPossibilities.constructor === Array)) {return;} if (!(allPossibilities.constructor === Array)) {return;}
if (!containsAllStrings(allPossibilities)) {return;} if (!containsAllStrings(allPossibilities)) {return;}
command = command.toLowerCase(); if (!command.startsWith("./")) {
command = command.toLowerCase();
}
//Remove all options in allPossibilities that do not match the current string //Remove all options in allPossibilities that do not match the current string
//that we are attempting to autocomplete //that we are attempting to autocomplete
@ -243,6 +245,23 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
var currServ = Player.getCurrentServer(); var currServ = Player.getCurrentServer();
input = input.toLowerCase(); input = input.toLowerCase();
//If the command starts with './' and the index == -1, then the user
//has input ./partialexecutablename so autocomplete the script or program
//Put './' in front of each script/executable
if (input.startsWith("./") && index == -1) {
//All programs and scripts
for (var i = 0; i < currServ.scripts.length; ++i) {
allPos.push("./" + currServ.scripts[i].filename);
}
//Programs are on home computer
var homeComputer = Player.getHomeComputer();
for(var i = 0; i < homeComputer.programs.length; ++i) {
allPos.push("./" + homeComputer.programs[i]);
}
return allPos;
}
//Autocomplete the command //Autocomplete the command
if (index == -1) { if (index == -1) {
return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "free", return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "free",
@ -447,7 +466,7 @@ var Terminal = {
//Allow usage of ./ //Allow usage of ./
if (command.startsWith("./")) { if (command.startsWith("./")) {
command = command.slice(0, 2) + " " + command.slice(2); command = "run " + command.slice(2);
} }
//Only split the first space //Only split the first space
@ -895,7 +914,6 @@ var Terminal = {
post("No such file exists"); post("No such file exists");
break; break;
case "run": case "run":
case "./":
//Run a program or a script //Run a program or a script
if (commandArray.length != 2) { if (commandArray.length != 2) {
post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]..."); post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");

@ -485,9 +485,8 @@ var Engine = {
}, },
displayFactionsInfo: function() { displayFactionsInfo: function() {
//Clear the list of joined factions
var factionsList = document.getElementById("factions-list"); var factionsList = document.getElementById("factions-list");
//Clear the list
while (factionsList.firstChild) { while (factionsList.firstChild) {
factionsList.removeChild(factionsList.firstChild); factionsList.removeChild(factionsList.firstChild);
} }
@ -500,7 +499,6 @@ var Engine = {
//Add the faction to the Factions page content //Add the faction to the Factions page content
var item = document.createElement("li"); var item = document.createElement("li");
var aElem = document.createElement("a"); var aElem = document.createElement("a");
aElem.setAttribute("href", "#");
aElem.setAttribute("class", "a-link-button"); aElem.setAttribute("class", "a-link-button");
aElem.innerHTML = factionName; aElem.innerHTML = factionName;
aElem.addEventListener("click", function() { aElem.addEventListener("click", function() {
@ -509,10 +507,54 @@ var Engine = {
return false; return false;
}); });
item.appendChild(aElem); item.appendChild(aElem);
factionsList.appendChild(item); factionsList.appendChild(item);
}()); //Immediate invocation }()); //Immediate invocation
} }
//Clear the list of invitations
var invitationsList = document.getElementById("outstanding-faction-invitations-list");
while (invitationsList.firstChild) {
invitationsList.removeChild(invitationsList.firstChild);
}
//Add a link to accept for each faction you have invitiations for
for (var i = 0; i < Player.factionInvitations.length; ++i) {
(function () {
var factionName = Player.factionInvitations[i];
var item = document.createElement("li");
var pElem = document.createElement("p");
pElem.innerText = factionName;
pElem.style.display = "inline";
pElem.style.margin = "4px";
pElem.style.padding = "4px";
var aElem = document.createElement("a");
aElem.innerText = "Accept Faction Invitation";
aElem.setAttribute("class", "a-link-button");
aElem.style.display = "inline";
aElem.style.margin = "4px";
aElem.style.padding = "4px";
aElem.addEventListener("click", function() {
joinFaction(Factions[factionName]);
for (var i = 0; i < Player.factionInvitations.length; ++i) {
if (Player.factionInvitations[i] == factionName) {
Player.factionInvitations.splice(i, 1);
break;
}
}
Engine.displayFactionsInfo();
return false;
});
item.appendChild(pElem);
item.appendChild(aElem);
item.style.margin = "6px";
item.style.padding = "6px";
invitationsList.appendChild(item);
}());
}
}, },
displayAugmentationsContent: function() { displayAugmentationsContent: function() {
@ -693,7 +735,7 @@ var Engine = {
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
updateDisplays: 3, //Update displays such as Active Scripts display and character display updateDisplays: 3, //Update displays such as Active Scripts display and character display
createProgramNotifications: 10, //Checks whether any programs can be created and notifies createProgramNotifications: 10, //Checks whether any programs can be created and notifies
checkFactionInvitations: 100, //Check whether you qualify for any faction invitations every 5 minutes checkFactionInvitations: 100, //Check whether you qualify for any faction invitations
passiveFactionGrowth: 600, passiveFactionGrowth: 600,
messages: 150, messages: 150,
stockTick: 30, //Update stock prices stockTick: 30, //Update stock prices

@ -23,20 +23,21 @@ factionInvitationSetMessage = function(msg) {
factionInvitationBoxCreate = function(faction) { factionInvitationBoxCreate = function(faction) {
factionInvitationSetText("You have received a faction invitation from " + faction.name); factionInvitationSetText("You have received a faction invitation from " + faction.name);
//TODO Faction invitation message //TODO Faction invitation message
var newYesButton = clearEventListeners("faction-invitation-box-yes"); var newYesButton = clearEventListeners("faction-invitation-box-yes");
newYesButton.addEventListener("click", function() { newYesButton.addEventListener("click", function() {
joinFaction(faction); joinFaction(faction);
factionInvitationBoxClose(); factionInvitationBoxClose();
return false; return false;
}); });
var noButton = clearEventListeners("faction-invitation-box-no"); var noButton = clearEventListeners("faction-invitation-box-no");
noButton.addEventListener("click", function() { noButton.addEventListener("click", function() {
factionInvitationBoxClose(); factionInvitationBoxClose();
faction.alreadyInvited = true; faction.alreadyInvited = true;
Player.factionInvitations.push(faction.name);
return false; return false;
}); });
factionInvitationBoxOpen(); factionInvitationBoxOpen();
} }