initial
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user