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] }));
|
||||
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) {
|
||||
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)
|
||||
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.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:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
let [sCorpName] = ns.args;
|
||||
ns.corporation.createCorporation(sCorpName,true)
|
||||
ns.writePort(ns.pid, true);
|
||||
ns.writePort(ns.pid, ns.corporation.createCorporation(sCorpName,false));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.writePort(ns.pid,ns.corporation.getCorporation())
|
||||
ns.writePort(ns.pid, ns.corporation.getCorporation());
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
let [sDivName, sCity, oCurrentOffice] = ns.args;
|
||||
oCurrentOffice = JSON.parse(oCurrentOffice)
|
||||
if (oCurrentOffice.numEmployees < oCurrentOffice.size) {
|
||||
(oCurrentOffice.employeeJobs.Operations < 1) ? ns.corporation.hireEmployee(sDivName, sCity, "Operations") : "";
|
||||
(oCurrentOffice.employeeJobs.Engineer < 1) ? ns.corporation.hireEmployee(sDivName, sCity, "Engineer") : "";
|
||||
(oCurrentOffice.employeeJobs.Business < 1) ? ns.corporation.hireEmployee(sDivName, sCity, "Business") : "";
|
||||
(oCurrentOffice.employeeJobs.Management < 1) ? ns.corporation.hireEmployee(sDivName, sCity, "Management") : "";
|
||||
let [sDivName, sCity, oCurrentOffice, oWorkerDistribution] = ns.args;
|
||||
oCurrentOffice = JSON.parse(oCurrentOffice);
|
||||
let aWorkerDistribution = JSON.parse(oWorkerDistribution).nWorkerNumbers;
|
||||
let nTotalWorkers = 0;
|
||||
const len = aWorkerDistribution.length;
|
||||
for (let i = 0; i < len; i++) nTotalWorkers += aWorkerDistribution[i];
|
||||
let i = 0;
|
||||
while (oCurrentOffice.numEmployees < oCurrentOffice.size && oCurrentOffice.numEmployees < nTotalWorkers && i < 1) {
|
||||
(oCurrentOffice.employeeJobs.Operations < aWorkerDistribution[0]) ? ns.corporation.hireEmployee(sDivName, sCity, "Operations") : "";
|
||||
(oCurrentOffice.employeeJobs.Engineer < aWorkerDistribution[1]) ? ns.corporation.hireEmployee(sDivName, sCity, "Engineer") : "";
|
||||
(oCurrentOffice.employeeJobs.Business < aWorkerDistribution[2]) ? ns.corporation.hireEmployee(sDivName, sCity, "Business") : "";
|
||||
(oCurrentOffice.employeeJobs.Management < aWorkerDistribution[3]) ? ns.corporation.hireEmployee(sDivName, sCity, "Management") : "";
|
||||
(oCurrentOffice.employeeJobs["Research & Development"] < aWorkerDistribution[4]) ? ns.corporation.hireEmployee(sDivName, sCity, "Research & Development") : "";
|
||||
(oCurrentOffice.employeeJobs.Intern < aWorkerDistribution[5]) ? ns.corporation.hireEmployee(sDivName, sCity, "Intern") : "";
|
||||
await ns.sleep(1);
|
||||
i += 1;
|
||||
};
|
||||
ns.writePort(ns.pid, true);
|
||||
}
|
||||
3
Mizzajl/home/corp/PriceCalcCheatsheet.txt
Normal file
3
Mizzajl/home/corp/PriceCalcCheatsheet.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
getMaterial() -> material.marketPrice
|
||||
|
||||
ns.corporation.getMaterialData() -> baseMarkup
|
||||
@@ -1,4 +0,0 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.corporation.hasWarehouse();
|
||||
}
|
||||
Reference in New Issue
Block a user