-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathprograms.js
More file actions
51 lines (47 loc) · 1.17 KB
/
programs.js
File metadata and controls
51 lines (47 loc) · 1.17 KB
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
import { LogMessage } from 'utils.js'
/** @param {NS} ns */
export async function main(ns) {
BuyPrograms(ns);
}
export function BuyPrograms(ns) {
// Buy TOR
if (!ns.getPlayer().tor) {
ns.print('WARN: TOR router not found.');
if (ns.getPlayer().money < 200000) {
ns.print('WARN: Not enough money to purchase TOR router, postponing purchase.');
}
else {
if (ns.singularity.purchaseTor()) {
ns.tprint('INFO: Succesfully bought TOR router.');
LogMessage(ns, 'INFO: Succesfully bought TOR router.');
}
else {
ns.print('ERROR: Something went wrong buying the TOR router.');
return;
}
}
}
const PROGRAMS = [
'BruteSSH.exe',
'FTPCrack.exe',
'relaySMTP.exe',
'SQLInject.exe',
'HTTPWorm.exe'
];
for (const program of PROGRAMS) {
// Buy BruteSSH.exe
if (!ns.fileExists(program)) {
ns.print('INFO: Checking if we can buy ' + program + '.');
if (ns.singularity.purchaseProgram(program)) {
ns.tprint('SUCCESS: Purchased ' + program);
LogMessage(ns, 'SUCCESS: Purchased ' + program);
}
else {
if (ns.singularity.getCurrentWork() == null) {
ns.singularity.createProgram(program, false);
return;
}
}
}
}
}