time to get some sleep, graph is in stylishGraph.js and the crime monitor is in test3.js

This commit is contained in:
2024-10-19 04:06:22 +02:00
parent e4bf947531
commit 6189db539a
19 changed files with 465 additions and 590 deletions

View File

@@ -1,5 +1,6 @@
/** @param {NS} ns */
export async function main(ns) {
ns.tail();
let aCitites = ["Sector-12", "Aevum", "Volhaven", "Chongqing", "New Tokyo", "Ishima"];
let sCorpName = "RM Enterprises";
let sDivisionName = "Agri-Ram";
@@ -30,14 +31,34 @@ export async function main(ns) {
if (!ns.readPort(nListenPID)) { ns.tprint("Error! Couldn't start Corporation!"); return };
ns.tprint(oCorpStatus);
while (nStep < 199) {
await ns.corporation.nextUpdate();
if (nStep > 40) {
for (let sCity of aCitites) {
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oOfficeData = ns.readPort(nListenPID);
if (oOfficeData.avgEnergy < 99.5) {
nListenPID = ns.run("/corp/BuyTea.js", 1, sDivisionName, sCity);
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
}
if (oOfficeData.avgMorale < 99.5) {
nListenPID = ns.run("/corp/ThrowParty.js", 1, sDivisionName, sCity, 500000);
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
}
// InsertSmartSupplyHere
}
};
nStep = oCorpStatus.nStep;
ns.tprint(nStep);
nListenPID = ns.run("/corp/GetCorpData.js");
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oCorpData = ns.readPort(nListenPID);
switch (nStep) {
case 0:
nListenPID = ns.run("/corp/GetCorpData.js");
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oCorpData = ns.readPort(nListenPID);
if (!oCorpData.divisions.length > 0) {
nListenPID = ns.run("/corp/CorpStart.js", 1, sDivisionName, "Agriculture");
await ns.nextPortWrite(nListenPID);
@@ -57,17 +78,23 @@ export async function main(ns) {
await ns.sleep(1);
}
}
oCorpStatus.nStep = 15;
break;
case 15:
nListenPID = ns.run("/corp/BuyWarehouseAPI.js");
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oCorpStatus.nStep = 20;
break;
case 20:
nListenPID = ns.run("/corp/HasUnlock.js", 1, "Smart Supply");
/*nListenPID = ns.run("/corp/HasUnlock.js", 1, "Smart Supply");
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
bUnlockStatus = ns.readPort(nListenPID);
if (!bUnlockStatus) {
await ns.nextPortWrite(ns.run("/corp/BuyUnlock.js", 1, "Smart Supply"));
await ns.sleep(1);
}
}*/
for (let sCity of aCitites) {
nListenPID = ns.run("/corp/GetWarehouseData.js", 1, sDivisionName, sCity);
await ns.nextPortWrite(nListenPID);
@@ -77,10 +104,7 @@ export async function main(ns) {
await ns.nextPortWrite(ns.run("/corp/PurchaseWarehouses.js", 1, sDivisionName, sCity));
await ns.sleep(1);
}
await ns.nextPortWrite(ns.run("/corp/SetSmartSupply.js", 1, sDivisionName, sCity));
await ns.sleep(1);
};
oCorpStatus.nStep = 30;
break;
case 30:
@@ -101,13 +125,49 @@ export async function main(ns) {
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oOfficeData = ns.readPort(nListenPID);
nListenPID = ns.run("/corp/HireWorkers.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData), JSON.stringify({ nWorkerNumbers: [1, 1, 1, 1, 0, 0] }));
nListenPID = ns.run("/corp/HireWorkers.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData));
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
}
oCorpStatus.nStep = 50;
oCorpStatus.nStep = 45;
break;
case 50:
case 45:
nListenPID = ns.run("/corp/GetDivisionsData.js", 1, sDivisionName);
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oDivisionData = ns.readPort(nListenPID);
if (!oDivisionData.researchPoints > 55) { continue } else {
for (let sCity of aCitites) {
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
oOfficeData = ns.readPort(nListenPID);
nListenPID = ns.run("/corp/SetWorkerOnPosition.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData), JSON.stringify({ nWorkerNumbers: [1, 1, 1, 1, 0, 0] }));
await ns.nextPortWrite(nListenPID);
await ns.sleep(1);
}
oCorpStatus.nStep = 70;
}
break;
case 70:
break;
case 80:
break;
case 90:
break;
case 100:
break;
default:
break;
}
ns.write("CorpStatus.txt", JSON.stringify(oCorpStatus), "w")
await ns.sleep(1)
}
}
/*
case 50:
let aCurrentGoods = [
{ "sMaterialName": "Food", "yAmount": "MAX", "yPrice": "MP-5" },
{ "sMaterialName": "Plants", "yAmount": "MAX", "yPrice": "MP-5" }
@@ -150,19 +210,5 @@ export async function main(ns) {
}
oCorpStatus.nStep = 70;
break;
case 70:
oCorpStatus.nStep = 200;
break;
case 80:
break;
case 90:
break;
case 100:
break;
default:
break;
}
ns.write("CorpStatus.txt", JSON.stringify(oCorpStatus), "w")
await ns.sleep(1)
}
}
*/