-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_server.js
44 lines (43 loc) · 1.95 KB
/
analyze_server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/** @param {NS} ns **/
export async function main(ns) {
const args = ns.flags([["help", false]]);
const server = ns.args[0];
if (args.help || !server) {
ns.tprint("This script does a more detailed analysis of a server.");
ns.tprint(`Usage: run ${ns.getScriptName()} SERVER`);
ns.tprint("Example:");
ns.tprint(`> run ${ns.getScriptName()} n00dles`);
return;
}
const s = ns.getServer(server);
const player = ns.getPlayer();
const maxRam = ns.getServerMaxRam(server);
const usedRam = ns.getServerUsedRam(server);
const money = ns.getServerMoneyAvailable(server);
const maxMoney = ns.getServerMaxMoney(server);
const minSec = ns.getServerMinSecurityLevel(server);
const sec = ns.getServerSecurityLevel(server);
ns.tprint(`
${server}:
RAM : ${usedRam} / ${maxRam} (${usedRam / maxRam * 100}%)
$ : ${ns.nFormat(money, "$0.000a")} / ${ns.nFormat(maxMoney, "$0.000a")} (${(money / maxMoney * 100).toFixed(2)}%)
security : ${minSec.toFixed(2)} / ${sec.toFixed(2)}
growth : ${ns.getServerGrowth(server)}
hack time : ${ns.tFormat(ns.getHackTime(server))}
hack time : ${ns.tFormat(ns.formulas.hacking.hackTime(s, player))}
grow time : ${ns.tFormat(ns.getGrowTime(server))}
grow time : ${ns.tFormat(ns.formulas.hacking.growTime(s, player))}
weaken time: ${ns.tFormat(ns.getWeakenTime(server))}
weaken time: ${ns.tFormat(ns.formulas.hacking.weakenTime(s, player))}
grow x2 : ${(ns.growthAnalyze(server, 2)).toFixed(2)} threads
grow x3 : ${(ns.growthAnalyze(server, 3)).toFixed(2)} threads
grow x4 : ${(ns.growthAnalyze(server, 4)).toFixed(2)} threads
hack 10% : ${(.10 / ns.hackAnalyze(server)).toFixed(2)} threads
hack 25% : ${(.25 / ns.hackAnalyze(server)).toFixed(2)} threads
hack 50% : ${(.50 / ns.hackAnalyze(server)).toFixed(2)} threads
hackChance : ${(ns.hackAnalyzeChance(server) * 100).toFixed(2)}%
`);
}
export function autocomplete(data, args) {
return data.servers;
}