Compare commits

..

No commits in common. "92ad2da7b758d5925abd962c6026c158bea8cb17" and "677f23ea8d3e3fdba5da176b2ad15ba3708af304" have entirely different histories.

3 changed files with 7 additions and 32 deletions

View File

@ -1,13 +1,10 @@
import { recursiveHackingRequired, recursiveScan } from "./utils"
import { recursiveScan } from "./utils"
export async function main(ns: NS){
switch (ns.args[0]) {
case "getServers":
getServers(ns);
break;
case "getHackingLevels":
getHackingLevels(ns);
break;
default:
ns.tprint("Invalid program name");
break;
@ -16,6 +13,3 @@ export async function main(ns: NS){
function getServers(ns: NS) {
ns.tprint(recursiveScan(ns));
}
function getHackingLevels(ns: NS) {
ns.tprint(recursiveHackingRequired(ns))
}

View File

@ -28,21 +28,6 @@ export function recursiveScan(ns: NS) {
return allServers
}
/**
* Recursively scans all servers connected to the current server for the set of all levels that hackable servers require
* @param ns
* @returns A set of every hacking level required to hack a new server
*/
export function recursiveHackingRequired(ns: NS) {
let servers = recursiveScan(ns)
let levels: number[] = []
for (let server of servers) {
levels.push(ns.getServerRequiredHackingLevel(server))
}
// remove duplicates
return [...new Set(levels)]
}
/**
* Removes files passed in from all servers
* @param ns Global NS object

View File

@ -1,20 +1,16 @@
import { recursiveHackingRequired } from "./utils"
export async function main(ns: NS) {
ns.run('hackallservers.js')
let levels = recursiveHackingRequired(ns)
let hackingLevel: number
do {
let hackingLevel = ns.getHackingLevel()
while (hackingLevel < 9999) {
let oldHackingLevel = hackingLevel
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}`)
if (oldHackingLevel !== hackingLevel) {
ns.tprint(`Hacking level increased from ${oldHackingLevel} to ${hackingLevel}`)
ns.run('killall.js')
await ns.sleep(1000) // 1 second
ns.run('hackallservers.js')
}
// Wait 1 second before checking again
await ns.sleep(1000)
} while (hackingLevel < 9999)
}
}