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 = {
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
//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
InfiltrationBribeBaseAmount: 100000, //Amount per clearance level
HospitalCostPerHp: 25000,
MillisecondsPer20Hours: 72000000,
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>",
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>" +
"-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 " +

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