Next round of corp-control done
This commit is contained in:
@@ -8,26 +8,44 @@ export async function main(ns) {
|
||||
};
|
||||
let oCorpStatus = JSON.parse(ns.read("CorpStatus.txt")) || { nStep: 0 };
|
||||
let nStep = oCorpStatus.nStep;
|
||||
let nListenPID = 0;
|
||||
let oCorpData = {};
|
||||
let oDivisionData = {};
|
||||
let oOfficeData = {}
|
||||
ns.tprint(oCorpStatus);
|
||||
while (nStep < 200) {
|
||||
|
||||
while (nStep < 199) {
|
||||
nStep = oCorpStatus.nStep;
|
||||
ns.tprint(nStep);
|
||||
nListenPID = ns.run("/corp/GetCorpData.js");
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
oCorpData = ns.readPort(nListenPID);
|
||||
switch (nStep) {
|
||||
case 0:
|
||||
await ns.nextPortWrite(ns.run("/corp/CorpStart.js", 1, sDivisionName, "Agriculture"))
|
||||
if (!oCorpData.divisions.length > 0) {
|
||||
nListenPID = ns.run("/corp/CorpStart.js", 1, sDivisionName, "Agriculture");
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
};
|
||||
oCorpStatus.nStep = 10;
|
||||
break;
|
||||
case 10:
|
||||
for (let sCity of aCitites) {
|
||||
if (sCity !== "Sector-12") await ns.nextPortWrite(ns.run("/corp/CorpExpandCity.js", 1, sDivisionName, sCity))
|
||||
nListenPID = ns.run("/corp/GetDivisionsData.js", 1, sDivisionName);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
oDivisionData = ns.readPort(nListenPID);
|
||||
if (sCity !== "Sector-12" && !oDivisionData.cities.includes(sCity)) {
|
||||
nListenPID = ns.run("/corp/CorpExpandCity.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
}
|
||||
}
|
||||
oCorpStatus.nStep = 20;
|
||||
break;
|
||||
case 20:
|
||||
let nTargetSize = 4;
|
||||
for (let sCity of aCitites) {
|
||||
await ns.nextPortWrite(ns.run("/corp/UpgradeOffice.js", 1, sDivisionName, sCity, nTargetSize))
|
||||
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
oOfficeData = ns.readPort(nListenPID);
|
||||
await ns.nextPortWrite(ns.run("/corp/UpgradeOffice.js", 1, sDivisionName, sCity, nTargetSize, oOfficeData.size))
|
||||
}
|
||||
oCorpStatus.nStep = 200;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user