-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathshouldInstall.js
56 lines (47 loc) · 2.55 KB
/
shouldInstall.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
import { GetSitRep } from 'sitrep.js'
import { LogMessage } from 'utils.js'
/** @param {NS} ns */
export async function main(ns) {
let shouldInstall = false;
let sitrep = GetSitRep(ns);
let firstCycle = ns.singularity.getOwnedAugmentations().length < 3;
let nonNFGaugs = sitrep?.suggestedAugs?.filter(a => !a.name.startsWith('NeuroFlux')) ?? [];
let suggestedAugs = sitrep?.suggestedAugs ?? [];
let time = ns.getPlayer().playtimeSinceLastAug;
let hours = Math.floor(time / 1000 / 60 / 60);
//ns.tprint('hours: ' + hours);
//ns.tprint('suggestedAugs.length: ' + suggestedAugs.length);
if ((firstCycle && nonNFGaugs.length >= Math.max(8 - hours, 4)) || (!firstCycle && suggestedAugs.length >= 15 - hours)) {
LogMessage(ns, 'INFO: Install trigger activated! Augmentation count is looking sexy. firstCycle=' + firstCycle + ' suggestedAugs.length=' + suggestedAugs.length + ' nonNFGaugs.length=' + nonNFGaugs.length);
ns.tprint('INFO: Install trigger activated! Augmentation count is looking sexy. firstCycle=' + firstCycle + ' suggestedAugs.length=' + suggestedAugs.length + ' nonNFGaugs.length=' + nonNFGaugs.length);
shouldInstall = true;
}
let count = ns.singularity.getOwnedAugmentations(true).length - ns.singularity.getOwnedAugmentations().length;
if (count > 0 && sitrep.suggestedAugs?.length === 0) {
LogMessage(ns, 'INFO: Install trigger activated! We have ' + count + 'queued augs and nothing more we can buy.');
ns.tprint('INFO: Install trigger activated! We have ' + count + 'queued augs and nothing more we can buy.');
shouldInstall = true;
}
if (!ns.singularity.getOwnedAugmentations().includes('The Red Pill')) {
//ns.tprint('Red pill check');
if (ns.singularity.getOwnedAugmentations(true).includes('The Red Pill')) {
ns.tprint('Red pill is in queue lets go!');
LogMessage(ns, 'INFO: Install trigger activated! We have The Red Pill queued.');
ns.tprint('INFO: Install trigger activated! We have The Red Pill queued.');
shouldInstall = true;
}
if (sitrep.suggestedAugs != undefined && sitrep.suggestedAugs.some(s => s.name == 'The Red Pill')) {
LogMessage(ns, 'INFO: Install trigger activated! We have the reputation for The Red Pill.');
ns.tprint('INFO: Install trigger activated! We have the reputation for The Red Pill.');
shouldInstall = true;
}
// for (let aug of sitrep.suggestedAugs) {
// if (aug.name == 'The Red Pill')
// ns.tprint('Red pill is available!?!');
// //ns.tprint(aug);
// }
}
sitrep = GetSitRep(ns);
sitrep.shouldInstall = shouldInstall;
ns.write('sitrep.txt', JSON.stringify(sitrep), 'w');
}