Corp Cleanup
This commit is contained in:
@@ -30,14 +30,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);
|
||||
@@ -60,14 +80,14 @@ export async function main(ns) {
|
||||
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 +97,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 +118,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 +203,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)
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user