mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 11:10:58 +02:00
streamline programs
This commit is contained in:
+49
-93
@@ -432,7 +432,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
if (!Player.hasProgram(Programs.NukeProgram)) {
|
||||
if (!Player.hasProgram(Programs.NukeProgram.name)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the NUKE.exe virus!");
|
||||
}
|
||||
if (server.openPortCount < server.numOpenPortsRequired) {
|
||||
@@ -467,7 +467,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
if (!Player.hasProgram(Programs.BruteSSHProgram)) {
|
||||
if (!Player.hasProgram(Programs.BruteSSHProgram.name)) {
|
||||
workerScript.scriptRef.log("You do not have the BruteSSH.exe program!");
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the BruteSSH.exe program!");
|
||||
}
|
||||
@@ -501,7 +501,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
if (!Player.hasProgram(Programs.FTPCrackProgram)) {
|
||||
if (!Player.hasProgram(Programs.FTPCrackProgram.name)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the FTPCrack.exe program!");
|
||||
}
|
||||
if (!server.ftpPortOpen) {
|
||||
@@ -534,7 +534,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
if (!Player.hasProgram(Programs.RelaySMTPProgram)) {
|
||||
if (!Player.hasProgram(Programs.RelaySMTPProgram.name)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the relaySMTP.exe program!");
|
||||
}
|
||||
if (!server.smtpPortOpen) {
|
||||
@@ -567,7 +567,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
if (!Player.hasProgram(Programs.HTTPWormProgram)) {
|
||||
if (!Player.hasProgram(Programs.HTTPWormProgram.name)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the HTTPWorm.exe program!");
|
||||
}
|
||||
if (!server.httpPortOpen) {
|
||||
@@ -600,7 +600,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
if (!Player.hasProgram(Programs.SQLInjectProgram)) {
|
||||
if (!Player.hasProgram(Programs.SQLInjectProgram.name)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the SQLInject.exe program!");
|
||||
}
|
||||
if (!server.sqlPortOpen) {
|
||||
@@ -2566,11 +2566,11 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
|
||||
switch(programName.toLowerCase()) {
|
||||
case Programs.BruteSSHProgram.toLowerCase():
|
||||
case Programs.BruteSSHProgram.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);
|
||||
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -2579,11 +2579,11 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Programs.FTPCrackProgram.toLowerCase():
|
||||
case Programs.FTPCrackProgram.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);
|
||||
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -2592,11 +2592,11 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Programs.RelaySMTPProgram.toLowerCase():
|
||||
case Programs.RelaySMTPProgram.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);
|
||||
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -2605,11 +2605,11 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Programs.HTTPWormProgram.toLowerCase():
|
||||
case Programs.HTTPWormProgram.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);
|
||||
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -2618,11 +2618,11 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Programs.SQLInjectProgram.toLowerCase():
|
||||
case Programs.SQLInjectProgram.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);
|
||||
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -2631,11 +2631,11 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Programs.DeepscanV1.toLowerCase():
|
||||
case Programs.DeepscanV1.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.DeepscanV1);
|
||||
Player.getHomeComputer().programs.push(Programs.DeepscanV1.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -2644,11 +2644,11 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Programs.DeepscanV2.toLowerCase():
|
||||
case Programs.DeepscanV2.name.toLowerCase():
|
||||
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.DeepscanV2);
|
||||
Player.getHomeComputer().programs.push(Programs.DeepscanV2.name);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
@@ -3251,12 +3251,12 @@ function NetscriptFunctions(workerScript) {
|
||||
return ramCost;
|
||||
}
|
||||
}
|
||||
if (Player.bitNodeN != 4) {
|
||||
/*if (Player.bitNodeN != 4) {
|
||||
if (!(hasSingularitySF && singularitySFLvl >= 3)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (inMission) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because you are in the middle of a mission.");
|
||||
return;
|
||||
@@ -3268,78 +3268,34 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
}
|
||||
|
||||
switch(name.toLowerCase()) {
|
||||
case Programs.NukeProgram.toLowerCase():
|
||||
Player.startCreateProgramWork(Programs.NukeProgram, CONSTANTS.MillisecondsPerFiveMinutes, 1);
|
||||
break;
|
||||
case Programs.BruteSSHProgram.toLowerCase():
|
||||
if (Player.hacking_skill < 50) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.BruteSSHProgram, CONSTANTS.MillisecondsPerFiveMinutes * 2, 50);
|
||||
break;
|
||||
case Programs.FTPCrackProgram.toLowerCase():
|
||||
if (Player.hacking_skill < 100) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.FTPCrackProgram, CONSTANTS.MillisecondsPerHalfHour, 100);
|
||||
break;
|
||||
case Programs.RelaySMTPProgram.toLowerCase():
|
||||
if (Player.hacking_skill < 250) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.RelaySMTPProgram, CONSTANTS.MillisecondsPer2Hours, 250);
|
||||
break;
|
||||
case Programs.HTTPWormProgram.toLowerCase():
|
||||
if (Player.hacking_skill < 500) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.HTTPWormProgram, CONSTANTS.MillisecondsPer4Hours, 500);
|
||||
break;
|
||||
case Programs.SQLInjectProgram.toLowerCase():
|
||||
if (Player.hacking_skill < 750) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.SQLInjectProgram, CONSTANTS.MillisecondsPer8Hours, 750);
|
||||
break;
|
||||
case Programs.DeepscanV1.toLowerCase():
|
||||
if (Player.hacking_skill < 75) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.DeepscanV1, CONSTANTS.MillisecondsPerQuarterHour, 75);
|
||||
break;
|
||||
case Programs.DeepscanV2.toLowerCase():
|
||||
if (Player.hacking_skill < 400) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.DeepscanV2, CONSTANTS.MillisecondsPer2Hours, 400);
|
||||
break;
|
||||
case Programs.ServerProfiler.toLowerCase():
|
||||
if (Player.hacking_skill < 75) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.ServerProfiler, CONSTANTS.MillisecondsPerHalfHour, 75);
|
||||
break;
|
||||
case Programs.AutoLink.toLowerCase():
|
||||
if (Player.hacking_skill < 25) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)");
|
||||
return false;
|
||||
}
|
||||
Player.startCreateProgramWork(Programs.AutoLink, CONSTANTS.MillisecondsPerQuarterHour, 25);
|
||||
break;
|
||||
default:
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
|
||||
return false;
|
||||
name = name.toLowerCase();
|
||||
|
||||
let p = null;
|
||||
for (const key in Programs) {
|
||||
if(Programs[key].name.toLowerCase() == name) {
|
||||
p = Programs[key];
|
||||
}
|
||||
}
|
||||
|
||||
if(p == null) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Player.hasProgram(p.name)) {
|
||||
workerScript.scriptRef.log('ERROR: createProgram() failed because you already have the ' + p.name + ' program');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!p.create.req()) {
|
||||
workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create " + p.name + " (level " + p.create.level + " req)");
|
||||
return false
|
||||
}
|
||||
|
||||
Player.startCreateProgramWork(p.name, p.create.time, p.create.level);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
|
||||
workerScript.scriptRef.log("Began creating program: " + name);
|
||||
}
|
||||
workerScript.scriptRef.log("Began creating program: " + name);
|
||||
return true;
|
||||
},
|
||||
commitCrime : function(crime) {
|
||||
|
||||
Reference in New Issue
Block a user