mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
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:
parent
118118db83
commit
0e64359814
34
index.html
34
index.html
@ -502,6 +502,11 @@
|
||||
<h1> Factions </h1>
|
||||
<p> Lists all factions you have joined </p>
|
||||
<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>
|
||||
|
||||
<!-- Single Faction info (when you select a faction from the Factions menu) -->
|
||||
@ -928,7 +933,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type ="range" max="100" min="20"
|
||||
<input type="range" max="100" min="20"
|
||||
oninput="document.getElementById('settingsNSLogRangeValLabel').innerHTML = this.value;
|
||||
Settings.MaxLogCapacity=this.value;"
|
||||
step="1" name="settingsNSLogRangeVal" id="settingsNSLogRangeVal" value="50">
|
||||
@ -946,7 +951,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type ="range" max="100" min="20"
|
||||
<input type="range" max="100" min="20"
|
||||
oninput="document.getElementById('settingsNSPortRangeValLabel').innerHTML = this.value;
|
||||
Settings.MaxPortCapacity=this.value;"
|
||||
step="1" name="settingsNSPortRangeVal" id="settingsNSPortRangeVal" value="50">
|
||||
@ -954,6 +959,31 @@
|
||||
<em id="settingsNSPortRangeValLabel" style="font-style: normal;"></em>
|
||||
</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 -->
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
|
@ -61,9 +61,7 @@ CONSTANTS = {
|
||||
ScriptHasRootAccessRamCost: 0.05,
|
||||
ScriptGetHostnameRamCost: 0.05,
|
||||
ScriptGetHackingLevelRamCost: 0.05,
|
||||
ScriptGetServerMoneyRamCost: 0.1,
|
||||
ScriptGetServerSecurityRamCost: 0.1,
|
||||
ScriptGetServerReqdHackRamCost: 0.1,
|
||||
ScriptGetServerCost: 0.1,
|
||||
ScriptFileExistsRamCost: 0.1,
|
||||
ScriptIsRunningRamCost: 0.1,
|
||||
ScriptOperatorRamCost: 0.01,
|
||||
@ -86,6 +84,8 @@ CONSTANTS = {
|
||||
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
|
||||
|
||||
PurchasedServerLimit: 25,
|
||||
|
||||
//Augmentation Constants
|
||||
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
|
||||
@ -678,7 +678,18 @@ CONSTANTS = {
|
||||
"World Stock Exchange account and TIX API Access<br>",
|
||||
|
||||
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 getServerRam() Netscript function()<br>" +
|
||||
"-Added getLevelUpgradeCost(n), getRamUpgradeCost(), getCoreUpgradeCost() functions for Netscript Hacknet Node API<br>" +
|
||||
|
@ -6,11 +6,11 @@ checkIfConnectedToDarkweb = function() {
|
||||
if (!isValidIPAddress(darkwebIp)) {return;}
|
||||
if (darkwebIp == Player.getCurrentServer().ip) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Handler for dark web commands. The terminal's executeCommand() function will pass
|
||||
@ -41,9 +41,39 @@ executeDarkwebTerminalCommand = function(commandArray) {
|
||||
listAllDarkwebItems = function() {
|
||||
for (var item in DarkWebItems) {
|
||||
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) {
|
||||
@ -52,7 +82,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -62,7 +92,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -72,7 +102,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -82,7 +112,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -92,7 +122,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -102,7 +132,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -112,7 +142,7 @@ buyDarkwebItem = function(itemName) {
|
||||
if (price > 0 && Player.money >= price) {
|
||||
Player.loseMoney(price);
|
||||
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.");
|
||||
} else {
|
||||
post("Not enough money to purchase " + itemName);
|
||||
@ -133,7 +163,7 @@ parseDarkwebItemPrice = function(itemDesc) {
|
||||
//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;}
|
||||
@ -151,4 +181,4 @@ DarkWebItems = {
|
||||
SQLInjectProgram: Programs.SQLInjectProgram + " - $250,000,000 - Opens up SQL Ports",
|
||||
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",
|
||||
}
|
||||
}
|
||||
|
@ -630,7 +630,12 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
}
|
||||
|
||||
inviteToFaction = function(faction) {
|
||||
factionInvitationBoxCreate(faction);
|
||||
if (Settings.SuppressFactionInvites) {
|
||||
faction.alreadyInvited = true;
|
||||
Player.factionInvitations.push(faction.name);
|
||||
} else {
|
||||
factionInvitationBoxCreate(faction);
|
||||
}
|
||||
}
|
||||
|
||||
joinFaction = function(faction) {
|
||||
|
@ -20,13 +20,15 @@ Reviver.constructors.Message = Message;
|
||||
function sendMessage(msg) {
|
||||
console.log("sending message: " + msg.filename);
|
||||
msg.recvd = true;
|
||||
showMessage(msg);
|
||||
if (!Settings.SuppressMessages) {
|
||||
showMessage(msg);
|
||||
}
|
||||
addMessageToServer(msg, "home");
|
||||
}
|
||||
|
||||
function showMessage(msg) {
|
||||
var txt = "Message received from unknown sender: <br><br>" +
|
||||
"<i>" + msg.msg + "</i><br><br>" +
|
||||
var txt = "Message received from unknown sender: <br><br>" +
|
||||
"<i>" + msg.msg + "</i><br><br>" +
|
||||
"This message was saved as " + msg.filename + " onto your home computer.";
|
||||
dialogBoxCreate(txt);
|
||||
}
|
||||
@ -53,7 +55,7 @@ function checkForMessagesToSend() {
|
||||
var nitesecTest = Messages[MessageFilenames.NiteSecTest];
|
||||
var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
|
||||
var redpill = Messages[MessageFilenames.RedPill];
|
||||
|
||||
|
||||
if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) {
|
||||
sendMessage(jumper0);
|
||||
} else if (jumper1 && !jumper1.recvd && Player.hacking_skill >= 40) {
|
||||
@ -100,61 +102,61 @@ MessageFilenames = {
|
||||
function initMessages() {
|
||||
//Reset
|
||||
Messages = {};
|
||||
|
||||
|
||||
//jump3R Messages
|
||||
AddToAllMessages(new Message(MessageFilenames.Jumper0,
|
||||
"I know you can sense it. I know you're searching for it. " +
|
||||
"It's why you spend night after " +
|
||||
"night at your computer. <br><br>It's real, I've seen it. And I can " +
|
||||
"I know you can sense it. I know you're searching for it. " +
|
||||
"It's why you spend night after " +
|
||||
"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"));
|
||||
AddToAllMessages(new Message(MessageFilenames.Jumper1,
|
||||
"Soon you will be contacted by a hacking group known as CyberSec. " +
|
||||
"They can help you with your search. <br><br>" +
|
||||
"You should join them, garner their favor, and " +
|
||||
"exploit them for their Augmentations. But do not trust them. " +
|
||||
"They are not what they seem. No one is.<br><br>" +
|
||||
"You should join them, garner their favor, and " +
|
||||
"exploit them for their Augmentations. But do not trust them. " +
|
||||
"They are not what they seem. No one is.<br><br>" +
|
||||
"-jump3R"));
|
||||
AddToAllMessages(new Message(MessageFilenames.Jumper2,
|
||||
"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 " +
|
||||
"morals will get you killed. <br><br>Watch out for a hacking group known as NiteSec." +
|
||||
"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 " +
|
||||
"morals will get you killed. <br><br>Watch out for a hacking group known as NiteSec." +
|
||||
"<br><br>-jump3R"));
|
||||
AddToAllMessages(new Message(MessageFilenames.Jumper3,
|
||||
"You must learn to walk before you can run. And you must " +
|
||||
"run before you can fly. Look for the black hand. <br><br>" +
|
||||
"You must learn to walk before you can run. And you must " +
|
||||
"run before you can fly. Look for the black hand. <br><br>" +
|
||||
"I.I.I.I <br><br>-jump3R"));
|
||||
AddToAllMessages(new Message(MessageFilenames.Jumper4,
|
||||
"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>" +
|
||||
"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>" +
|
||||
"-jump3R"));
|
||||
AddToAllMessages(new Message(MessageFilenames.Jumper5,
|
||||
"Build your wings and fly<br><br>-jump3R<br><br> " +
|
||||
"The fl1ght.exe program was added to your home computer"));
|
||||
|
||||
|
||||
//Messages from hacking factions
|
||||
AddToAllMessages(new Message(MessageFilenames.CyberSecTest,
|
||||
"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 " +
|
||||
"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>" +
|
||||
"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>" +
|
||||
"-CyberSec"));
|
||||
AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
|
||||
"People say that the corrupted governments and corporations rule the world. " +
|
||||
"Yes, maybe they do. But do you know who everyone really fears? People " +
|
||||
"People say that the corrupted governments and corporations rule the world. " +
|
||||
"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 " +
|
||||
"and ideas with bullets. <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." +
|
||||
"and ideas with bullets. <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." +
|
||||
"<br><br>-NiteSec"));
|
||||
AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
|
||||
"We know what you are doing. We know what drives you. We know " +
|
||||
"what you are looking for. <br><br> " +
|
||||
"We can help you find the answers.<br><br>" +
|
||||
"We know what you are doing. We know what drives you. We know " +
|
||||
"what you are looking for. <br><br> " +
|
||||
"We can help you find the answers.<br><br>" +
|
||||
"run4theh111z"));
|
||||
|
||||
|
||||
AddToAllMessages(new Message(MessageFilenames.RedPill,
|
||||
"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" +
|
||||
")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" +
|
||||
"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" +
|
||||
"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" +
|
||||
")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" +
|
||||
"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" +
|
||||
"DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)"));
|
||||
}
|
||||
}
|
||||
|
@ -131,6 +131,14 @@ function evaluate(exp, workerScript) {
|
||||
reject(e);
|
||||
});
|
||||
break;
|
||||
case "UnaryExpression":
|
||||
var p = evalUnary(exp, workerScript, resolve, reject);
|
||||
p.then(function(res) {
|
||||
resolve(res);
|
||||
}).catch(function(e) {
|
||||
reject(e);
|
||||
});
|
||||
break;
|
||||
case "AssignmentExpression":
|
||||
var p = evalAssignment(exp, workerScript);
|
||||
p.then(function(res) {
|
||||
@ -210,58 +218,6 @@ function evaluate(exp, workerScript) {
|
||||
}); // 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){
|
||||
return new Promise(function(resolve, reject) {
|
||||
var expLeftPromise = evaluate(exp.left, workerScript);
|
||||
@ -329,17 +285,24 @@ function evalBinary(exp, workerScript){
|
||||
}
|
||||
|
||||
function evalUnary(exp, workerScript){
|
||||
var env = workerScript.env;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var expLeftPromise = evaluate(exp.left, workerScript);
|
||||
expLeftPromise.then(function(expLeft) {
|
||||
switch(exp.operator){
|
||||
case "++":
|
||||
break
|
||||
case "--":
|
||||
break;
|
||||
if (env.stopFlag) {return reject(workerScript);}
|
||||
var p = evaluate(exp.argument, workerScript);
|
||||
p.then(function(res) {
|
||||
if (exp.operator == "!") {
|
||||
resolve(!res);
|
||||
} else if (exp.operator == "-") {
|
||||
if (isNaN(res)) {
|
||||
resolve(res);
|
||||
} else {
|
||||
resolve(-1 * res);
|
||||
}
|
||||
} else {
|
||||
reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator));
|
||||
}
|
||||
}, function(e) {
|
||||
reject(e);
|
||||
}).catch(function(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) {
|
||||
var env = workerScript.env;
|
||||
|
||||
@ -791,7 +647,7 @@ function scriptCalculateExpGain(server) {
|
||||
if (server.baseDifficulty == null) {
|
||||
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
|
||||
|
@ -654,6 +654,12 @@ function NetscriptFunctions(workerScript) {
|
||||
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);
|
||||
if (isNaN(ram) || !powerOfTwo(ram)) {
|
||||
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));
|
||||
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) {
|
||||
if (isNaN(n)) {return 0;}
|
||||
return Math.round(n);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Worker code, contains Netscript scripts that are actually running */
|
||||
|
||||
//TODO Tested For and while and generic call statements. Have not tested if statements
|
||||
/* Worker code, contains Netscript scripts that are actually running */
|
||||
|
||||
//TODO Tested For and while and generic call statements. Have not tested if statements
|
||||
|
||||
/* Actual Worker Code */
|
||||
function WorkerScript(runningScriptObj) {
|
||||
@ -53,7 +53,7 @@ function runScriptsLoop() {
|
||||
workerScripts[i].env.stopFlag = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
workerScripts[i].running = true;
|
||||
var p = evaluate(ast, workerScripts[i]);
|
||||
//Once the code finishes (either resolved or rejected, doesnt matter), set its
|
||||
@ -79,9 +79,9 @@ function runScriptsLoop() {
|
||||
var serverIp = errorTextArray[1];
|
||||
var scriptName = errorTextArray[2];
|
||||
var errorMsg = errorTextArray[3];
|
||||
|
||||
dialogBoxCreate("Script runtime error: <br>Server Ip: " + serverIp +
|
||||
"<br>Script name: " + scriptName +
|
||||
|
||||
dialogBoxCreate("Script runtime error: <br>Server Ip: " + serverIp +
|
||||
"<br>Script name: " + scriptName +
|
||||
"<br>Args:" + printArray(w.args) + "<br>" + errorMsg);
|
||||
w.scriptRef.log("Script crashed with runtime error");
|
||||
} else {
|
||||
@ -89,7 +89,7 @@ function runScriptsLoop() {
|
||||
}
|
||||
w.running = false;
|
||||
w.env.stopFlag = true;
|
||||
|
||||
|
||||
} else if (isScriptErrorMessage(w)) {
|
||||
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");
|
||||
@ -100,13 +100,13 @@ function runScriptsLoop() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Delete any scripts that finished or have been killed. Loop backwards bc removing
|
||||
//items fucks up the indexing
|
||||
for (var i = workerScripts.length - 1; i >= 0; i--) {
|
||||
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
|
||||
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 name = workerScripts[i].name;
|
||||
for (var j = 0; j < AllServers[ip].runningScripts.length; j++) {
|
||||
@ -116,18 +116,18 @@ function runScriptsLoop() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Free RAM
|
||||
AllServers[ip].ramUsed -= workerScripts[i].ramUsage;
|
||||
|
||||
|
||||
//Delete script from Active Scripts
|
||||
deleteActiveScriptsItem(workerScripts[i]);
|
||||
|
||||
|
||||
//Delete script from workerScripts
|
||||
workerScripts.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setTimeout(runScriptsLoop, 10000);
|
||||
}
|
||||
|
||||
@ -145,10 +145,10 @@ function killWorkerScript(runningScriptObj, serverIp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Queues a script to be run
|
||||
//Queues a script to be run
|
||||
function addWorkerScript(runningScriptObj, server) {
|
||||
var filename = runningScriptObj.filename;
|
||||
|
||||
|
||||
//Update server's ram usage
|
||||
var threads = 1;
|
||||
if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
|
||||
@ -156,18 +156,18 @@ function addWorkerScript(runningScriptObj, server) {
|
||||
} else {
|
||||
runningScriptObj.threads = 1;
|
||||
}
|
||||
var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
|
||||
var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
|
||||
* Math.pow(CONSTANTS.MultithreadingRAMCost, threads-1);
|
||||
server.ramUsed += ramUsage;
|
||||
|
||||
|
||||
//Create the WorkerScript
|
||||
var s = new WorkerScript(runningScriptObj);
|
||||
s.serverIp = server.ip;
|
||||
s.ramUsage = ramUsage;
|
||||
|
||||
|
||||
//Add the WorkerScript to the Active Scripts list
|
||||
addActiveScriptsItem(s);
|
||||
|
||||
|
||||
//Add the WorkerScript
|
||||
workerScripts.push(s);
|
||||
return;
|
||||
@ -181,4 +181,4 @@ function updateOnlineScriptTimes(numCycles = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
runScriptsLoop();
|
||||
runScriptsLoop();
|
||||
|
518
src/Player.js
518
src/Player.js
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ function prestigeAugmentation() {
|
||||
Player.lifetime_agility += Player.agility;
|
||||
Player.total_charisma += Player.charisma;
|
||||
Player.lifetime_charisma += Player.charisma;
|
||||
|
||||
|
||||
//Crime statistics
|
||||
Player.numTimesShopliftedTotal += Player.numTimesShoplifted;
|
||||
Player.numTimesShopliftedLifetime += Player.numTimesShoplifted;
|
||||
@ -41,52 +41,53 @@ function prestigeAugmentation() {
|
||||
Player.numTimesHeistTotal += Player.numTimesHeist;
|
||||
Player.numTimesHeistLifetime += Player.numTimesHeist;
|
||||
Player.numTimesHeist = 0;
|
||||
|
||||
|
||||
Player.karma = 0;
|
||||
|
||||
|
||||
//Reset stats
|
||||
Player.hacking_skill = 1;
|
||||
|
||||
|
||||
Player.strength = 1;
|
||||
Player.defense = 1;
|
||||
Player.dexterity = 1;
|
||||
Player.agility = 1;
|
||||
|
||||
|
||||
Player.charisma = 1;
|
||||
|
||||
|
||||
Player.hacking_exp = 0;
|
||||
Player.strength_exp = 0;
|
||||
Player.defense_exp = 0;
|
||||
Player.dexterity_exp = 0;
|
||||
Player.agility_exp = 0;
|
||||
Player.charisma_exp = 0;
|
||||
|
||||
|
||||
Player.money = 1000;
|
||||
|
||||
|
||||
Player.city = Locations.Sector12;
|
||||
Player.location = "";
|
||||
|
||||
|
||||
Player.companyName = "";
|
||||
Player.companyPosition = "";
|
||||
|
||||
|
||||
Player.currentServer = "";
|
||||
Player.discoveredServers = [];
|
||||
Player.purchasedServers = [];
|
||||
|
||||
|
||||
Player.factions = [];
|
||||
|
||||
Player.factionInvitations = [];
|
||||
|
||||
Player.queuedAugmentations = [];
|
||||
|
||||
|
||||
Player.startAction = false;
|
||||
Player.actionTime = 0;
|
||||
|
||||
|
||||
Player.isWorking = false;
|
||||
Player.currentWorkFactionName = "";
|
||||
Player.currentWorkFactionDescription = "";
|
||||
this.createProgramName = "";
|
||||
this.className = "";
|
||||
this.crimeType = "";
|
||||
|
||||
|
||||
Player.workHackExpGainRate = 0;
|
||||
Player.workStrExpGainRate = 0;
|
||||
Player.workDefExpGainRate = 0;
|
||||
@ -95,7 +96,7 @@ function prestigeAugmentation() {
|
||||
Player.workChaExpGainRate = 0;
|
||||
Player.workRepGainRate = 0;
|
||||
Player.workMoneyGainRate = 0;
|
||||
|
||||
|
||||
Player.workHackExpGained = 0;
|
||||
Player.workStrExpGained = 0;
|
||||
Player.workDefExpGained = 0;
|
||||
@ -104,18 +105,18 @@ function prestigeAugmentation() {
|
||||
Player.workChaExpGained = 0;
|
||||
Player.workRepGained = 0;
|
||||
Player.workMoneyGained = 0;
|
||||
|
||||
|
||||
Player.timeWorked = 0;
|
||||
|
||||
|
||||
Player.lastUpdate = new Date().getTime();
|
||||
|
||||
|
||||
//Delete all Worker Scripts objects
|
||||
for (var i = 0; i < workerScripts.length; ++i) {
|
||||
deleteActiveScriptsItem(workerScripts[i]);
|
||||
workerScripts[i].env.stopFlag = true;
|
||||
}
|
||||
workerScripts.length = 0;
|
||||
|
||||
|
||||
var homeComp = Player.getHomeComputer();
|
||||
//Delete all servers except home computer
|
||||
for (var member in AllServers) {
|
||||
@ -127,7 +128,7 @@ function prestigeAugmentation() {
|
||||
delete SpecialServerIps[member];
|
||||
}
|
||||
SpecialServersIps = null;
|
||||
|
||||
|
||||
//Reset home computer (only the programs) and add to AllServers
|
||||
homeComp.programs.length = 0;
|
||||
homeComp.runningScripts = [];
|
||||
@ -136,12 +137,12 @@ function prestigeAugmentation() {
|
||||
homeComp.isOnline = true;
|
||||
homeComp.ramUsed = 0;
|
||||
homeComp.programs.push(Programs.NukeProgram);
|
||||
if (augmentationExists(AugmentationNames.Neurolink) &&
|
||||
if (augmentationExists(AugmentationNames.Neurolink) &&
|
||||
Augmentations[AugmentationNames.Neurolink].owned) {
|
||||
homeComp.programs.push(Programs.FTPCrackProgram);
|
||||
homeComp.programs.push(Programs.RelaySMTPProgram);
|
||||
}
|
||||
if (augmentationExists(AugmentationNames.CashRoot) &&
|
||||
}
|
||||
if (augmentationExists(AugmentationNames.CashRoot) &&
|
||||
Augmentations[AugmentationNames.CashRoot].owned) {
|
||||
Player.money = 1000000;
|
||||
homeComp.programs.push(Programs.BruteSSHProgram);
|
||||
@ -149,57 +150,57 @@ function prestigeAugmentation() {
|
||||
Player.currentServer = homeComp.ip;
|
||||
Player.homeComputer = homeComp.ip;
|
||||
AddToAllServers(homeComp);
|
||||
|
||||
|
||||
//Re-create foreign servers
|
||||
SpecialServerIps = new SpecialServerIpsMap(); //Must be done before initForeignServers()
|
||||
initForeignServers();
|
||||
|
||||
|
||||
//Darkweb is purchase-able
|
||||
document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button");
|
||||
|
||||
|
||||
//Reset statistics of all scripts on home computer
|
||||
for (var i = 0; i < homeComp.scripts.length; ++i) {
|
||||
var s = homeComp.scripts[i];
|
||||
}
|
||||
//Delete messages on home computer
|
||||
homeComp.messages.length = 0;
|
||||
|
||||
|
||||
//Delete Hacknet Nodes
|
||||
Player.hacknetNodes.length = 0;
|
||||
Player.totalHacknetNodeProduction = 0;
|
||||
|
||||
|
||||
//Gain favor for Companies
|
||||
for (var member in Companies) {
|
||||
if (Companies.hasOwnProperty(member)) {
|
||||
Companies[member].gainFavor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Gain favor for factions
|
||||
for (var member in Factions) {
|
||||
if (Factions.hasOwnProperty(member)) {
|
||||
Factions[member].gainFavor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Stop a Terminal action if there is onerror
|
||||
if (Engine._actionInProgress) {
|
||||
Engine._actionInProgress = false;
|
||||
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
|
||||
initAugmentations();
|
||||
initCompanies();
|
||||
|
||||
|
||||
//Clear terminal
|
||||
$("#terminal tr:not(:last)").remove();
|
||||
postNetburnerText();
|
||||
|
||||
|
||||
//Messages
|
||||
initMessages();
|
||||
|
||||
|
||||
//Reset Stock market
|
||||
if (Player.hasWseAccount) {
|
||||
initStockMarket();
|
||||
@ -210,13 +211,13 @@ function prestigeAugmentation() {
|
||||
stockMarketList.removeChild(stockMarketList.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Player.playtimeSinceLastAug = 0;
|
||||
|
||||
|
||||
var mainMenu = document.getElementById("mainmenu-container");
|
||||
mainMenu.style.visibility = "visible";
|
||||
Engine.loadTerminalContent();
|
||||
|
||||
|
||||
//Red Pill
|
||||
if (augmentationExists(AugmentationNames.TheRedPill) &&
|
||||
Augmentations[AugmentationNames.TheRedPill].owned) {
|
||||
@ -227,4 +228,4 @@ function prestigeAugmentation() {
|
||||
DaedalusServer.serversOnNetwork.push(WorldDaemon.ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,8 @@ function calculateRamUsage(codeCopy) {
|
||||
var getServerSecurityCount = numOccurrences(codeCopy, "getServerSecurityLevel(");
|
||||
var getServerBaseSecurityCount = numOccurrences(codeCopy, "getServerBaseSecurityLevel(");
|
||||
var getServerReqdHackingCount = numOccurrences(codeCopy, "getServerRequiredHackingLevel(");
|
||||
var getServerNumPortsReqdCount = numOccurrences(codeCopy, "getServerNumPortsRequired(");
|
||||
var getServerRamCount = numOccurrences(codeCopy, "getServerRam(");
|
||||
var fileExistsCount = numOccurrences(codeCopy, "fileExists(");
|
||||
var isRunningCount = numOccurrences(codeCopy, "isRunning(");
|
||||
var numOperators = numNetscriptOperators(codeCopy);
|
||||
@ -185,7 +187,8 @@ function calculateRamUsage(codeCopy) {
|
||||
numOccurrences(codeCopy, "getStockPosition(");
|
||||
var scriptBuySellStockCount = numOccurrences(codeCopy, "buyStock(") +
|
||||
numOccurrences(codeCopy, "sellStock(");
|
||||
var scriptPurchaseServerCount = numOccurrences(codeCopy, "purchaseServer(");
|
||||
var scriptPurchaseServerCount = numOccurrences(codeCopy, "purchaseServer(") +
|
||||
numOccurrences(codeCopy, "deleteServer(");
|
||||
var scriptRoundCount = numOccurrences(codeCopy, "round(");
|
||||
var scriptWriteCount = numOccurrences(codeCopy, "write(");
|
||||
var scriptReadCount = numOccurrences(codeCopy, "read(");
|
||||
@ -210,11 +213,13 @@ function calculateRamUsage(codeCopy) {
|
||||
(hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) +
|
||||
(getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) +
|
||||
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
|
||||
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
|
||||
(getServerMaxMoneyCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
|
||||
(getServerSecurityCount * CONSTANTS.ScriptGetServerSecurityRamCost) +
|
||||
(getServerBaseSecurityCount * CONSTANTS.ScriptGetServerSecurityRamCost) +
|
||||
(getServerReqdHackingCount * CONSTANTS.ScriptGetServerReqdHackRamCost) +
|
||||
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(getServerMaxMoneyCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(getServerSecurityCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(getServerBaseSecurityCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(getServerReqdHackingCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(getServerNumPortsReqdCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(getServerRamCount * CONSTANTS.ScriptGetServerCost) +
|
||||
(fileExistsCount * CONSTANTS.ScriptFileExistsRamCost) +
|
||||
(isRunningCount * CONSTANTS.ScriptIsRunningRamCost) +
|
||||
(numOperators * CONSTANTS.ScriptOperatorRamCost) +
|
||||
|
@ -8,7 +8,15 @@ purchaseServer = function(ram, cost) {
|
||||
dialogBoxCreate("You don't have enough money to purchase this server!");
|
||||
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 hostname = document.getElementById("purchase-server-box-input").value;
|
||||
hostname = hostname.replace(/\s\s+/g, '');
|
||||
@ -16,21 +24,21 @@ purchaseServer = function(ram, cost) {
|
||||
dialogBoxCreate("You must enter a hostname for your new server!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Create server
|
||||
newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram);
|
||||
AddToAllServers(newServ);
|
||||
|
||||
|
||||
//Add to Player's purchasedServers array
|
||||
Player.purchasedServers.push(newServ.ip);
|
||||
|
||||
|
||||
//Connect new server to home computer
|
||||
var homeComputer = Player.getHomeComputer();
|
||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
||||
|
||||
Player.loseMoney(cost);
|
||||
|
||||
|
||||
Player.loseMoney(cost);
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var homeComputer = Player.getHomeComputer();
|
||||
homeComputer.maxRam *= 2;
|
||||
|
||||
Player.loseMoney(cost);
|
||||
|
||||
|
||||
Player.loseMoney(cost);
|
||||
|
||||
dialogBoxCreate("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
/* Settings.js */
|
||||
Settings = {
|
||||
CodeInstructionRunTime: 100,
|
||||
suppressMessages: false,
|
||||
MaxLogCapacity: 50,
|
||||
MaxPortCapacity: 50,
|
||||
SuppressMessages: false,
|
||||
SuppressFactionInvites: false,
|
||||
}
|
||||
|
||||
function initSettings() {
|
||||
Settings.CodeInstructionRunTime = 100;
|
||||
Settings.suppressMessages = false;
|
||||
Settings.MaxLogCapacity = 50;
|
||||
Settings.MaxPortCapacity = 50;
|
||||
Settings.SuppressMessages = false;
|
||||
Settings.SuppressFactionInvites = false;
|
||||
}
|
||||
|
||||
function setSettingsLabels() {
|
||||
@ -20,4 +22,8 @@ function setSettingsLabels() {
|
||||
= Settings.MaxLogCapacity;
|
||||
document.getElementById("settingsNSPortRangeValLabel").innerHTML
|
||||
= 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 (!containsAllStrings(allPossibilities)) {return;}
|
||||
|
||||
command = command.toLowerCase();
|
||||
if (!command.startsWith("./")) {
|
||||
command = command.toLowerCase();
|
||||
}
|
||||
|
||||
//Remove all options in allPossibilities that do not match the current string
|
||||
//that we are attempting to autocomplete
|
||||
@ -243,6 +245,23 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
var currServ = Player.getCurrentServer();
|
||||
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
|
||||
if (index == -1) {
|
||||
return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "free",
|
||||
@ -447,7 +466,7 @@ var Terminal = {
|
||||
|
||||
//Allow usage of ./
|
||||
if (command.startsWith("./")) {
|
||||
command = command.slice(0, 2) + " " + command.slice(2);
|
||||
command = "run " + command.slice(2);
|
||||
}
|
||||
|
||||
//Only split the first space
|
||||
@ -895,7 +914,6 @@ var Terminal = {
|
||||
post("No such file exists");
|
||||
break;
|
||||
case "run":
|
||||
case "./":
|
||||
//Run a program or a script
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");
|
||||
|
@ -485,9 +485,8 @@ var Engine = {
|
||||
},
|
||||
|
||||
displayFactionsInfo: function() {
|
||||
//Clear the list of joined factions
|
||||
var factionsList = document.getElementById("factions-list");
|
||||
|
||||
//Clear the list
|
||||
while (factionsList.firstChild) {
|
||||
factionsList.removeChild(factionsList.firstChild);
|
||||
}
|
||||
@ -500,7 +499,6 @@ var Engine = {
|
||||
//Add the faction to the Factions page content
|
||||
var item = document.createElement("li");
|
||||
var aElem = document.createElement("a");
|
||||
aElem.setAttribute("href", "#");
|
||||
aElem.setAttribute("class", "a-link-button");
|
||||
aElem.innerHTML = factionName;
|
||||
aElem.addEventListener("click", function() {
|
||||
@ -509,10 +507,54 @@ var Engine = {
|
||||
return false;
|
||||
});
|
||||
item.appendChild(aElem);
|
||||
|
||||
factionsList.appendChild(item);
|
||||
}()); //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() {
|
||||
@ -693,7 +735,7 @@ var Engine = {
|
||||
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
||||
updateDisplays: 3, //Update displays such as Active Scripts display and character display
|
||||
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,
|
||||
messages: 150,
|
||||
stockTick: 30, //Update stock prices
|
||||
|
@ -23,20 +23,21 @@ factionInvitationSetMessage = function(msg) {
|
||||
factionInvitationBoxCreate = function(faction) {
|
||||
factionInvitationSetText("You have received a faction invitation from " + faction.name);
|
||||
//TODO Faction invitation message
|
||||
|
||||
|
||||
var newYesButton = clearEventListeners("faction-invitation-box-yes");
|
||||
newYesButton.addEventListener("click", function() {
|
||||
joinFaction(faction);
|
||||
factionInvitationBoxClose();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
var noButton = clearEventListeners("faction-invitation-box-no");
|
||||
noButton.addEventListener("click", function() {
|
||||
factionInvitationBoxClose();
|
||||
faction.alreadyInvited = true;
|
||||
Player.factionInvitations.push(faction.name);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
factionInvitationBoxOpen();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user