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)
|
2023-11-04 16:48:17 -03:00
|
|
|
let hackingLevel = ns.getHackingLevel()
|
|
|
|
// Remove levels that are already hacked
|
|
|
|
levels = levels.filter(level => level > hackingLevel)
|
|
|
|
|
2023-11-03 21:53:07 -03:00
|
|
|
do {
|
|
|
|
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-04 16:48:17 -03:00
|
|
|
ns.tprint(`Remaining levels to hack: ${levels}`)
|
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
|
|
|
}
|
2023-11-04 16:48:17 -03:00
|
|
|
hackingLevel = ns.getHackingLevel()
|
2023-11-03 18:42:37 -03:00
|
|
|
// Wait 1 second before checking again
|
|
|
|
await ns.sleep(1000)
|
2023-11-03 22:55:07 -03:00
|
|
|
} while (hackingLevel <= Math.max(...levels))
|
2023-11-03 18:42:37 -03:00
|
|
|
}
|