diff --git a/servers/home/watcher.ts b/servers/home/watcher.ts index 0d9b0b0..c3b7e1d 100644 --- a/servers/home/watcher.ts +++ b/servers/home/watcher.ts @@ -16,11 +16,19 @@ export async function main(ns: NS) { levels = levels.filter(level => level > hackingLevel) do { - if (Math.min(...levels) <= hackingLevel || checkForNewPrograms(ns, state)) { + let restart = false + if (Math.min(...levels) <= hackingLevel) { ns.tprint(`Hacking level increased past ${Math.min(...levels)}}, is now ${hackingLevel}`) ns.tprint(`Remaining levels to hack: ${levels}`) // remove the level from the list, so we don't try to hack it again levels = levels.filter(level => level > hackingLevel) + restart = true + } + if (checkForNewPrograms(ns, state)) { + ns.tprint(`New programs found: ${state.filter(program => program.exists).map(program => program.program)}`) + restart = true + } + if (restart) { ns.run("killall.js") await ns.sleep(1000) // 1 second ns.run("hackallservers.js")