-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinker.js
71 lines (60 loc) · 2 KB
/
tinker.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/** @param {NS} ns **/
export async function main(ns) {
const target = ns.args[0];
displayServerGrowth(ns, target);
displayServerSecurityLevel(ns, target);
displayServerMinSecurityLevel(ns, target);
displayHackAnalyze(ns, target);
displayGrowAnalyze(ns, target);
displayWeakenAnalyze(ns, target);
displayServerAvailableMoney(ns, target);
displayServerMaxMoney(ns, target);
displayServerMaxRam(ns, target);
ns.tprint("Child Server: ", ns.scan(target));
}
/**@param {NS} ns */
function displayHackAnalyze(ns, target) {
ns.tprint("Hack Time: " + round(ns.getHackTime(target) / 1000) + " seconds");
ns.tprint("Hack Stolen Amount: " + round(ns.hackAnalyze(target) * 100) + "%");
ns.tprint(
"Hack Success Chance: " + round(ns.hackAnalyzeChance(target) * 100) + "%"
);
}
/**@param {NS} ns */
function displayGrowAnalyze(ns, target) {
ns.tprint("Grow Time: " + round(ns.getGrowTime(target) / 1000) + " seconds");
}
/**@param {NS} ns */
function displayWeakenAnalyze(ns, target) {
ns.tprint(
"Weaken Time: " + round(ns.getWeakenTime(target) / 1000) + " seconds"
);
}
/**@param {NS} ns */
function displayServerSecurityLevel(ns, target) {
ns.tprint("Security Level: " + ns.getServerSecurityLevel(target));
}
/**@param {NS} ns */
function displayServerMinSecurityLevel(ns, target) {
ns.tprint("Min Security Level: " + ns.getServerMinSecurityLevel(target));
}
/**@param {NS} ns */
function displayServerAvailableMoney(ns, target) {
ns.tprint("Available Money: " + ns.getServerMoneyAvailable(target));
}
/**@param {NS} ns */
function displayServerMaxMoney(ns, target) {
ns.tprint("Max Money: " + ns.getServerMaxMoney(target));
}
/**@param {NS} ns */
function displayServerMaxRam(ns, target) {
ns.tprint("Max Ram: " + ns.getServerMaxRam(target));
}
/**@param {NS} ns */
function displayServerGrowth(ns, target) {
ns.tprint("Growth: " + ns.getServerGrowth(target));
}
function round(num) {
var m = Number((Math.abs(num) * 100).toPrecision(15));
return (Math.round(m) / 100) * Math.sign(num);
}