diff --git a/src/mainHack.ns b/src/mainHack.ns index bd7dea0..8f25bbb 100644 --- a/src/mainHack.ns +++ b/src/mainHack.ns @@ -91,12 +91,12 @@ function weakenCyclesForHack(hackCycles) { async function getHackableServers(ns, servers) { const playerDetails = getPlayerDetails(ns) - const hackableServers = Object.keys(servers) + const vulnerableServers = Object.keys(servers) .filter((hostname) => ns.serverExists(hostname)) .filter((hostname) => servers[hostname].ports <= playerDetails.portHacks || ns.hasRootAccess(hostname)) .filter((hostname) => servers[hostname].ram >= 2) - for (const hostname of hackableServers) { + for (const hostname of vulnerableServers) { if (hostname === 'home') continue; if (!ns.hasRootAccess(hostname)) { hackPrograms.forEach((hackProgram) => { @@ -111,8 +111,8 @@ async function getHackableServers(ns, servers) { } - hackableServers.sort((a, b) => servers[a].ram - servers[b].ram) - return hackableServers + vulnerableServers.sort((a, b) => servers[a].ram - servers[b].ram) + return vulnerableServers } function findTargetServer(ns, serversList, servers, serverExtraData) { @@ -172,13 +172,13 @@ export async function main(ns) { } serverMap.servers.home.ram = Math.max(0, serverMap.servers.home.ram - settings.homeRamReserved) - const hackableServers = await getHackableServers(ns, serverMap.servers) + const vulnerableServers = await getHackableServers(ns, serverMap.servers) - const targetServers = findTargetServer(ns, hackableServers, serverMap.servers, serverExtraData) + const targetServers = findTargetServer(ns, vulnerableServers, serverMap.servers, serverExtraData) const bestTarget = targetServers.shift() - const hackTime = ns.getHackTime(bestTarget) * 1000 - const growTime = ns.getGrowTime(bestTarget) * 1000 - const weakenTime = ns.getWeakenTime(bestTarget) * 1000 + const hackTime = ns.getHackTime(bestTarget) + const growTime = ns.getGrowTime(bestTarget) + const weakenTime = ns.getWeakenTime(bestTarget) const growDelay = Math.max(0, weakenTime - growTime - 15 * 1000) const hackDelay = Math.max(0, growTime + growDelay - hackTime - 15 * 1000) @@ -199,8 +199,8 @@ export async function main(ns) { let growCycles = 0 let weakenCycles = 0 - for (let i = 0; i < hackableServers.length; i++) { - const server = serverMap.servers[hackableServers[i]] + for (let i = 0; i < vulnerableServers.length; i++) { + const server = serverMap.servers[vulnerableServers[i]] hackCycles += Math.floor(server.ram / 1.7) growCycles += Math.floor(server.ram / 1.75) } @@ -239,8 +239,8 @@ export async function main(ns) { }` ) - for (let i = 0; i < hackableServers.length; i++) { - const server = serverMap.servers[hackableServers[i]] + for (let i = 0; i < vulnerableServers.length; i++) { + const server = serverMap.servers[vulnerableServers[i]] let cyclesFittable = Math.max(0, Math.floor(server.ram / 1.75)) const cyclesToRun = Math.max(0, Math.min(cyclesFittable, growCycles)) @@ -261,8 +261,8 @@ export async function main(ns) { ns.tprint(`[${localeHHMMSS()}] Cycles ratio: ${growCycles} grow cycles; ${weakenCycles} weaken cycles`) - for (let i = 0; i < hackableServers.length; i++) { - const server = serverMap.servers[hackableServers[i]] + for (let i = 0; i < vulnerableServers.length; i++) { + const server = serverMap.servers[vulnerableServers[i]] let cyclesFittable = Math.max(0, Math.floor(server.ram / 1.75)) const cyclesToRun = Math.max(0, Math.min(cyclesFittable, growCycles)) @@ -300,8 +300,8 @@ export async function main(ns) { ns.tprint(`[${localeHHMMSS()}] Cycles ratio: ${hackCycles} hack cycles; ${growCycles} grow cycles; ${weakenCycles} weaken cycles`) - for (let i = 0; i < hackableServers.length; i++) { - const server = serverMap.servers[hackableServers[i]] + for (let i = 0; i < vulnerableServers.length; i++) { + const server = serverMap.servers[vulnerableServers[i]] let cyclesFittable = Math.max(0, Math.floor(server.ram / 1.7)) const cyclesToRun = Math.max(0, Math.min(cyclesFittable, hackCycles))