fixed my corp stuff
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/** @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";
|
||||
@@ -17,14 +16,16 @@ export async function main(ns) {
|
||||
let oWarehouseData = {};
|
||||
let bUnlockStatus = false;
|
||||
let nTargetSize = 0;
|
||||
let oNewOfficeData = {};
|
||||
let oWorkerNumbers = {};
|
||||
nListenPID = ns.run("/corp/HasCorp.js");
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
let bCorpExists = ns.readPort(nListenPID);
|
||||
if (!bCorpExists) {
|
||||
nListenPID = ns.run("/corp/CreateCorp.js", 1, sCorpName);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
}
|
||||
if (!ns.readPort(nListenPID)) { ns.tprint("Error! Couldn't start Corporation!"); return };
|
||||
ns.tprint(oCorpStatus);
|
||||
@@ -33,14 +34,14 @@ export async function main(ns) {
|
||||
ns.tprint(nStep);
|
||||
nListenPID = ns.run("/corp/GetCorpData.js");
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
oCorpData = ns.readPort(nListenPID);
|
||||
switch (nStep) {
|
||||
case 0:
|
||||
if (!oCorpData.divisions.length > 0) {
|
||||
nListenPID = ns.run("/corp/CorpStart.js", 1, sDivisionName, "Agriculture");
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
};
|
||||
oCorpStatus.nStep = 10;
|
||||
break;
|
||||
@@ -48,12 +49,12 @@ export async function main(ns) {
|
||||
for (let sCity of aCitites) {
|
||||
nListenPID = ns.run("/corp/GetDivisionsData.js", 1, sDivisionName);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
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);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
}
|
||||
}
|
||||
oCorpStatus.nStep = 20;
|
||||
@@ -61,23 +62,23 @@ export async function main(ns) {
|
||||
case 20:
|
||||
nListenPID = ns.run("/corp/HasUnlock.js", 1, "Smart Supply");
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
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)
|
||||
await ns.sleep(1);
|
||||
}
|
||||
for (let sCity of aCitites) {
|
||||
nListenPID = ns.run("/corp/GetWarehouseData.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
oWarehouseData = ns.readPort(nListenPID);
|
||||
if (!oWarehouseData) {
|
||||
await ns.nextPortWrite(ns.run("/corp/PurchaseWarehouses.js", 1, sDivisionName, sCity));
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
}
|
||||
await ns.nextPortWrite(ns.run("/corp/SetSmartSupply.js", 1, sDivisionName, sCity));
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
};
|
||||
|
||||
oCorpStatus.nStep = 30;
|
||||
@@ -87,10 +88,10 @@ export async function main(ns) {
|
||||
for (let sCity of aCitites) {
|
||||
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
oOfficeData = ns.readPort(nListenPID);
|
||||
await ns.nextPortWrite(ns.run("/corp/UpgradeOffice.js", 1, sDivisionName, sCity, nTargetSize, oOfficeData.size))
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
}
|
||||
oCorpStatus.nStep = 40;
|
||||
break;
|
||||
@@ -98,11 +99,11 @@ export async function main(ns) {
|
||||
for (let sCity of aCitites) {
|
||||
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
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), JSON.stringify({ nWorkerNumbers: [1, 1, 1, 1, 0, 0] }));
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
await ns.sleep(1);
|
||||
}
|
||||
oCorpStatus.nStep = 50;
|
||||
break;
|
||||
@@ -113,37 +114,43 @@ export async function main(ns) {
|
||||
]
|
||||
for (let sCity of aCitites) {
|
||||
aCurrentGoods.forEach(async (entry) => {
|
||||
|
||||
nListenPID = ns.run("/corp/SetSalePrices.js", 1, sDivisionName, sCity, JSON.stringify(entry));
|
||||
nListenPID = ns.run("/corp/SetMaterialLimit.js", 1, sDivisionName, sCity, JSON.stringify(entry));
|
||||
|
||||
ns.tprint(sCity, entry)
|
||||
})
|
||||
}
|
||||
oCorpStatus.nStep = 60;
|
||||
break;
|
||||
case 60:
|
||||
nTargetSize = 12;
|
||||
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);
|
||||
await ns.nextPortWrite(ns.run("/corp/UpgradeOffice.js", 1, sDivisionName, sCity, nTargetSize, oOfficeData.size))
|
||||
await ns.sleep(1)
|
||||
nTargetSize = sCity === "Sector-12" ? 12 : 4;
|
||||
oWorkerNumbers = sCity === "Sector-12" ? { nWorkerNumbers: [2, 2, 2, 2, 2, 2] } : { nWorkerNumbers: [1, 1, 1, 1, 0, 0] }
|
||||
let running = true;
|
||||
while (running) {
|
||||
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1);
|
||||
oOfficeData = ns.readPort(nListenPID);
|
||||
await ns.nextPortWrite(ns.run("/corp/UpgradeOffice.js", 1, sDivisionName, sCity, nTargetSize, oOfficeData.size));
|
||||
await ns.sleep(1);
|
||||
nListenPID = ns.run("/corp/GetOfficeData.js", 1, sDivisionName, sCity);
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1);
|
||||
oNewOfficeData = ns.readPort(nListenPID);
|
||||
if (oNewOfficeData.size < nTargetSize) {
|
||||
await ns.sleep(10000);
|
||||
ns.tprint("Waiting for money");
|
||||
continue;
|
||||
} else {
|
||||
nListenPID = ns.run("/corp/HireWorkers.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData), JSON.stringify(oWorkerNumbers));
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
oCorpStatus.nStep = 70;
|
||||
break;
|
||||
case 70:
|
||||
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/HireWorkers.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData), JSON.stringify({nWorkerNumbers: [2, 2, 2, 2, 2, 2]}));
|
||||
await ns.nextPortWrite(nListenPID);
|
||||
await ns.sleep(1)
|
||||
}
|
||||
oCorpStatus.nStep = 200;
|
||||
break;
|
||||
case 80:
|
||||
|
||||
Reference in New Issue
Block a user