/** @param {NS} ns */ export async function main(ns) { const programs = [ "BruteSSH.exe", "FTPCrack.exe", "relaySMTP.exe", "HTTPWorm.exe", "SQLInject.exe", "ServerProfiler.exe", "DeepscanV1.exe", "DeepscanV2.exe", "AutoLink.exe", "Formulas.exe", ] // attempt to buy tor every second while (!ns.singularity.purchaseTor()) { await ns.sleep(1000) } // build a list to track which program we have in our possession let programsPurchased = new Array(programs.length) for (let i = 0; i < programs.length; i++) { programsPurchased[i] = ns.ls("home").includes(programs[i]) } // attempt to buy the programs every seconds do { await ns.sleep(1000) for (let i = 0; i < programs.length; i++) { if (!programsPurchased[i]) { const purchaseResult = ns.singularity.purchaseProgram(programs[i]) if (purchaseResult) { ns.tprintf("auto-tor: purchased %s", programs[i]) } else { // purchase the programs in the order listed // if we are unable to buy a program, break and retry later break } programsPurchased[i] = purchaseResult } } } while (!programsPurchased.reduce((x, y) => x && y, true)) ns.tprint("auto-tor: complete") }