Bitburner-Scripts/servers/home/watcher.ts

20 lines
613 B
TypeScript
Raw Normal View History

2023-11-03 21:53:07 -03:00
import { recursiveHackingRequired } from "./utils"
2023-11-03 18:42:37 -03:00
export async function main(ns: NS) {
2023-11-03 21:53:07 -03:00
let levels = recursiveHackingRequired(ns)
let hackingLevel: number
do {
2023-11-03 18:42:37 -03:00
hackingLevel = ns.getHackingLevel()
2023-11-03 21:53:07 -03:00
if (levels.includes(hackingLevel)) {
// remove the level from the list, so we don't try to hack it again
levels.splice(levels.indexOf(hackingLevel), 1)
ns.tprint(`Hacking level increased to ${hackingLevel}`)
2023-11-03 21:56:55 -03:00
ns.run("killall.js")
2023-11-03 18:42:37 -03:00
await ns.sleep(1000) // 1 second
2023-11-03 21:56:55 -03:00
ns.run("hackallservers.js")
2023-11-03 18:42:37 -03:00
}
// Wait 1 second before checking again
await ns.sleep(1000)
2023-11-03 21:53:07 -03:00
} while (hackingLevel < 9999)
2023-11-03 18:42:37 -03:00
}