You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
925 B
TypeScript
43 lines
925 B
TypeScript
import { NS } from "@ns";
|
|
import { printStatus } from "/lib/status";
|
|
|
|
const phaseScripts = [
|
|
'/tasks/01-discovery.js',
|
|
'/tasks/02-breaching.js',
|
|
'/tasks/03-targeting.js',
|
|
'/tasks/04-propogation.js',
|
|
]
|
|
|
|
const numPhases = phaseScripts.length
|
|
let currentPhase = 0
|
|
let pid = -1
|
|
|
|
export async function main(ns : NS) : Promise<void> {
|
|
ns.disableLog('ALL')
|
|
ns.tail()
|
|
ns.resizeTail(600, 200)
|
|
|
|
while (true) {
|
|
// Print status
|
|
ns.clearLog()
|
|
ns.print("currentPhase: " + phaseScripts[currentPhase])
|
|
printStatus(ns)
|
|
|
|
// If current phase is still running, delay and continue
|
|
if (ns.isRunning(pid)) {
|
|
await ns.sleep(100)
|
|
continue
|
|
}
|
|
|
|
// Advance to next phase
|
|
currentPhase = (currentPhase + 1) % numPhases
|
|
pid = ns.run(phaseScripts[currentPhase])
|
|
|
|
// In case of error
|
|
if (!pid) {
|
|
ns.print("Error starting " + phaseScripts[currentPhase])
|
|
break
|
|
}
|
|
}
|
|
}
|