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)
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -1 +1 @@
|
||||
{"nStep":200}
|
||||
{"nStep":70}
|
||||
@@ -190,6 +190,9 @@ export async function purchaseAndUpgradeServers(ns) {
|
||||
minHackLvl: 1,
|
||||
rootAccess: true,
|
||||
openPorts: 0,
|
||||
serverOrgs: "",
|
||||
serverCores: 1,
|
||||
serverFiles: []
|
||||
});
|
||||
ns.write("serverList.txt", JSON.stringify(serverList), "w");
|
||||
continue
|
||||
@@ -208,10 +211,10 @@ export async function purchaseAndUpgradeServers(ns) {
|
||||
if (ns.upgradePurchasedServer(currentServer, targetRam)) {
|
||||
ns.print(currentServer + " upgraded to " + targetRam + " GB RAM");
|
||||
serverList = JSON.parse(ns.read("serverList.txt"));
|
||||
let newServerList = serverList.map((entry) => { if (entry.serverName === currentServer) { entry.maxRam = targetRam } { entry.serverOrgs = "" } { entry.serverCores = 1 } { entry.serverFiles = [] } return entry });
|
||||
let newServerList = serverList.map((entry) => { if (entry.serverName === currentServer) { entry.maxRam = targetRam } return entry });
|
||||
ns.write("serverList.txt", JSON.stringify(newServerList), "w");
|
||||
ns.tprint(cCyan + "Server: " + currentServer + " upgraded to: " + targetRam.toLocaleString() + " GB" + cReset);
|
||||
ns.toast("Server: " + currentServer + " upgraded to: " + targetRam.toLocaleString() + " GB", "info", 10000);
|
||||
//ns.toast("Server: " + currentServer + " upgraded to: " + targetRam.toLocaleString() + " GB", "info", 10000);
|
||||
}
|
||||
} else {
|
||||
await ns.sleep(5000);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
let [sDivName, sCity] = ns.args;
|
||||
//ns.tprint("sDivName = " + sDivName);
|
||||
//ns.tprint("sCity = " + sCity);
|
||||
let bSuccess = ns.corporation.buyTea(sDivName, sCity)
|
||||
//ns.tprint("bSuccess = " + bSuccess);
|
||||
let bSuccess = ns.corporation.buyTea(sDivName, sCity);
|
||||
ns.writePort(ns.pid, bSuccess);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
let [sDivName, sCity] = ns.args;
|
||||
//ns.tprint(ns.corporation.getOffice(sDivName, sCity))
|
||||
ns.writePort(ns.pid, ns.corporation.getOffice(sDivName, sCity))
|
||||
}
|
||||
@@ -1,21 +1,10 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
let [sDivName, sCity, oCurrentOffice, oWorkerDistribution] = ns.args;
|
||||
let [sDivName, sCity, oCurrentOffice] = 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") : "";
|
||||
if (oCurrentOffice.numEmployees < oCurrentOffice.size) {
|
||||
ns.corporation.hireEmployee(sDivName, sCity, "Research & Development");
|
||||
await ns.sleep(1)
|
||||
i += 1;
|
||||
};
|
||||
ns.writePort(ns.pid, true);
|
||||
}
|
||||
26
Ramses/home/corp/SetWorkerOnPosition.js
Normal file
26
Ramses/home/corp/SetWorkerOnPosition.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
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];
|
||||
if (nTotalWorkers <= oCurrentOffice.numEmployees) {
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Operations", 0);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Engineer", 0);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Business", 0);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Management", 0);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Research & Development", 0);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Intern", 0);
|
||||
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Operations", aWorkerDistribution[0]);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Engineer", aWorkerDistribution[1]);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Business", aWorkerDistribution[2]);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Management", aWorkerDistribution[3]);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Research & Development", aWorkerDistribution[4]);
|
||||
ns.corporation.setAutoJobAssignment(sDivName, sCity, "Intern", aWorkerDistribution[5]);
|
||||
await ns.sleep(1)
|
||||
};
|
||||
ns.writePort(ns.pid, true);
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
let [sDivName, sCity, nSpend] = ns.args;
|
||||
//ns.tprint("sDivName = " + sDivName);
|
||||
//ns.tprint("sCity = " + sCity);
|
||||
//ns.tprint("nSpend = " + nSpend);
|
||||
let nMoraleMultiplier = ns.corporation.throwParty(sDivName, sCity, nSpend)
|
||||
//ns.tprint("nMoraleMultiplier = " + nMoraleMultiplier);
|
||||
let nMoraleMultiplier = ns.corporation.throwParty(sDivName, sCity, nSpend);
|
||||
ns.writePort(ns.pid, nMoraleMultiplier);
|
||||
}
|
||||
Reference in New Issue
Block a user