Improve watcher slightly
This commit is contained in:
parent
12d9165162
commit
f52af72140
@ -2,17 +2,21 @@ import { recursiveHackingRequired } from "./utils"
|
||||
|
||||
export async function main(ns: NS) {
|
||||
let levels = recursiveHackingRequired(ns)
|
||||
let hackingLevel: number
|
||||
let hackingLevel = ns.getHackingLevel()
|
||||
// Remove levels that are already hacked
|
||||
levels = levels.filter(level => level > hackingLevel)
|
||||
|
||||
do {
|
||||
hackingLevel = ns.getHackingLevel()
|
||||
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}`)
|
||||
ns.tprint(`Remaining levels to hack: ${levels}`)
|
||||
ns.run("killall.js")
|
||||
await ns.sleep(1000) // 1 second
|
||||
ns.run("hackallservers.js")
|
||||
}
|
||||
hackingLevel = ns.getHackingLevel()
|
||||
// Wait 1 second before checking again
|
||||
await ns.sleep(1000)
|
||||
} while (hackingLevel <= Math.max(...levels))
|
||||
|
Loading…
Reference in New Issue
Block a user