-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools_manager.js
51 lines (43 loc) · 1.25 KB
/
tools_manager.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
/** @param {NS} ns **/
export default class {
constructor(ns, messenger) {
this.ns = ns;
this.messenger = messenger;
this.tools = ns.singularity.getDarkwebPrograms();
this.haveTor = this.ns.singularity.purchaseTor();
}
get canCheckTools() {
if (!this.haveTor) {
this.haveTor = this.ns.singularity.purchaseTor();
}
return this.haveTor
}
get missingTools() {
let missingTools = []
if (this.haveTor) {
for (let tool of this.tools) {
if (!this.ns.fileExists(tool, "home")) {
missingTools.push(tool)
}
}
} else {
this.haveTor = this.ns.singularity.purchaseTor();
}
return missingTools
}
get nextMostExpensiveToolCost() {
return this.missingTools
.map(tool => this.ns.singularity.getDarkwebProgramCost(tool))
.sort
.first
}
sufficientCashForNextTool(currentBalance) {
return currentBalance > nextMostExpensiveToolCost
}
buyAllAffordableTools() {
this.missingTools.map(tool => this.ns.singularity.purchaseProgram(tool))
}
buyTool() {
this.ns.singularity
}
}