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 oCorpStatus = JSON.parse(ns.read("CorpStatus.txt")) || { nStep: 0 };
|
||||||
let nStep = oCorpStatus.nStep;
|
let nStep = oCorpStatus.nStep;
|
||||||
|
let nListenPID = 0;
|
||||||
|
let oCorpData = {};
|
||||||
|
let oDivisionData = {};
|
||||||
|
let oOfficeData = {}
|
||||||
ns.tprint(oCorpStatus);
|
ns.tprint(oCorpStatus);
|
||||||
while (nStep < 200) {
|
while (nStep < 199) {
|
||||||
|
|
||||||
nStep = oCorpStatus.nStep;
|
nStep = oCorpStatus.nStep;
|
||||||
ns.tprint(nStep);
|
ns.tprint(nStep);
|
||||||
|
nListenPID = ns.run("/corp/GetCorpData.js");
|
||||||
|
await ns.nextPortWrite(nListenPID);
|
||||||
|
oCorpData = ns.readPort(nListenPID);
|
||||||
switch (nStep) {
|
switch (nStep) {
|
||||||
case 0:
|
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;
|
oCorpStatus.nStep = 10;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
for (let sCity of aCitites) {
|
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;
|
oCorpStatus.nStep = 20;
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
let nTargetSize = 4;
|
let nTargetSize = 4;
|
||||||
for (let sCity of aCitites) {
|
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;
|
oCorpStatus.nStep = 200;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"nStep":0}
|
{"nStep":200}
|
||||||
4
Ramses/home/corp/GetCorpData.js
Normal file
4
Ramses/home/corp/GetCorpData.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/** @param {NS} ns */
|
||||||
|
export async function main(ns) {
|
||||||
|
ns.writePort(ns.pid,ns.corporation.getCorporation())
|
||||||
|
}
|
||||||
4
Ramses/home/corp/GetDivisionsData.js
Normal file
4
Ramses/home/corp/GetDivisionsData.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/** @param {NS} ns */
|
||||||
|
export async function main(ns) {
|
||||||
|
ns.writePort(ns.pid,ns.corporation.getDivision(ns.args[0]))
|
||||||
|
}
|
||||||
5
Ramses/home/corp/GetOfficeData.js
Normal file
5
Ramses/home/corp/GetOfficeData.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/** @param {NS} ns */
|
||||||
|
export async function main(ns) {
|
||||||
|
let [sDivName, sCity] = ns.args;
|
||||||
|
ns.writePort(ns.pid, ns.corporation.getOffice(sDivName, sCity))
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/** @param {NS} ns */
|
/** @param {NS} ns */
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
let [sDivName, sCity, nTargetSize] = ns.args;
|
let [sDivName, sCity, nTargetSize, nCurrentSize] = ns.args;
|
||||||
let nCurrentSize = ns.corporation.getOffice(sDivName, sCity).size;
|
|
||||||
if (nCurrentSize < nTargetSize) {
|
if (nCurrentSize < nTargetSize) {
|
||||||
ns.corporation.upgradeOfficeSize(sDivName, sCity, nTargetSize - nCurrentSize);
|
ns.corporation.upgradeOfficeSize(sDivName, sCity, nTargetSize - nCurrentSize);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user