scan() now takes in 1 argument representing the server to scan

This commit is contained in:
Daniel Xie 2017-06-29 09:16:32 -05:00
parent d63f17fa8d
commit f18b8d58fa
2 changed files with 26 additions and 14 deletions

@ -1,5 +1,5 @@
CONSTANTS = { CONSTANTS = {
Version: "0.23.0", Version: "0.23.1",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -94,6 +94,9 @@ CONSTANTS = {
//Infiltration constants //Infiltration constants
InfiltrationBribeBaseAmount: 100000, //Amount per clearance level InfiltrationBribeBaseAmount: 100000, //Amount per clearance level
HospitalCostPerHp: 25000,
MillisecondsPer20Hours: 72000000, MillisecondsPer20Hours: 72000000,
GameCyclesPer20Hours: 72000000 / 200, GameCyclesPer20Hours: 72000000 / 200,
@ -857,6 +860,8 @@ CONSTANTS = {
"-You can now see what an Augmentation does and its price even while its locked<br><br>", "-You can now see what an Augmentation does and its price even while its locked<br><br>",
LatestUpdate: LatestUpdate:
"v0.23.1<br>" +
"-scan() Netscript function now takes a single argument representing the server from which to scan. <br><br>" +
"v0.23.0<br>" + "v0.23.0<br>" +
"-You can now purchase multiple Augmentations in a run. When you purchase an Augmentation you will lose money equal to the price " + "-You can now purchase multiple Augmentations in a run. When you purchase an Augmentation you will lose money equal to the price " +
"and then the cost of purchasing another Augmentation during this run will be increased by 75%. You do not gain the benefits " + "and then the cost of purchasing another Augmentation during this run will be increased by 75%. You do not gain the benefits " +

@ -204,20 +204,27 @@ function evaluate(exp, workerScript) {
}); });
} else if (exp.func.value == "scan") { } else if (exp.func.value == "scan") {
if (exp.args.length != 0) { if (exp.args.length != 1) {
return reject(makeRuntimeRejectMsg(workerScript, "scan() call has incorrect number of arguments. Takes 0 arguments")); return reject(makeRuntimeRejectMsg(workerScript, "scan() call has incorrect number of arguments. Takes 1 argument"));
} }
var currServ = getServer(workerScript.serverIp);
if (currServ == null) { var ipPromise = evaluate(exp.args[0], workerScript);
return reject(makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer")); ipPromise.then(function(ip) {
} var server = getServer(ip);
var res = []; if (server == null) {
for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { workerScript.scriptRef.log("scan() failed. Invalid IP or hostname passed in: " + ip);
var thisServ = getServer(currServ.serversOnNetwork[i]); return reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into scan() command"));;
if (thisServ == null) {continue;} }
res.push({type:"str", value: thisServ.hostname}); var res = [];
} for (var i = 0; i < server.serversOnNetwork.length; ++i) {
resolve(res); var thisServ = getServer(server.serversOnNetwork[i]);
if (thisServ == null) {continue;}
res.push({type:"str", value: thisServ.hostname});
}
resolve(res);
}, function(e) {
reject(e);
});
} else if (exp.func.value == "nuke") { } else if (exp.func.value == "nuke") {
var p = netscriptRunProgram(exp, workerScript, Programs.NukeProgram); var p = netscriptRunProgram(exp, workerScript, Programs.NukeProgram);
p.then(function(res) { p.then(function(res) {