This commit is contained in:
2022-09-10 05:33:31 +02:00
commit cf66c47f41
9 changed files with 7910 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
/** @param {import(".").NS } ns */
export async function main(ns) {
ns.disableLog('ALL');
let costThreshold = ns.args.length > 0 ? ns.args[0] : 1;
let upgradeCount = ns.args.length > 1 ? ns.args[1] : 1;
await ns.sleep(10000);
while (true) {
let currentMoney = ns.getServerMoneyAvailable("home");
let nodePurchaseCost = ns.hacknet.getPurchaseNodeCost();
let nodeCount = ns.hacknet.numNodes();
if (nodePurchaseCost / Math.abs(currentMoney) < costThreshold) {
ns.hacknet.purchaseNode();
currentMoney = ns.getServerMoneyAvailable("home");
++nodeCount;
}
for (let index = 0; index < nodeCount; ++index) {
if (ns.hacknet.getLevelUpgradeCost(index, upgradeCount) / Math.abs(currentMoney) < costThreshold) {
ns.hacknet.upgradeLevel(index, upgradeCount);
currentMoney = ns.getServerMoneyAvailable("home");
}
if (ns.hacknet.getRamUpgradeCost(index, upgradeCount) / Math.abs(currentMoney) < costThreshold) {
ns.hacknet.upgradeRam(index, upgradeCount);
currentMoney = ns.getServerMoneyAvailable("home");
}
if (ns.hacknet.getCoreUpgradeCost(index, upgradeCount) / Math.abs(currentMoney) < costThreshold) {
ns.hacknet.upgradeCore(index, upgradeCount);
currentMoney = ns.getServerMoneyAvailable("home");
}
}
await ns.sleep(10);
}
}