diff --git a/Ramses/home/CorpControl.js b/Ramses/home/CorpControl.js index 91c7ee1..8d24578 100644 --- a/Ramses/home/CorpControl.js +++ b/Ramses/home/CorpControl.js @@ -1,6 +1,7 @@ /** @param {NS} ns */ export async function main(ns) { let aCitites = ["Sector-12", "Aevum", "Volhaven", "Chongqing", "New Tokyo", "Ishima"]; + let sCorpName = "RM Enterprises"; let sDivisionName = "Agri-Ram"; let reset = ns.args[0]; if (reset === true || !ns.fileExists("CorpStatus.txt")) { @@ -14,6 +15,14 @@ export async function main(ns) { let oOfficeData = {}; let oWarehouseData = {}; let bUnlockStatus = false; + nListenPID = ns.run("/corp/HasCorp.js"); + await ns.nextPortWrite(nListenPID); + let bCorpExists = ns.readPort(nListenPID); + if (!bCorpExists) { + nListenPID = ns.run("/corp/CreateCorp.js", 1, sCorpName); + await ns.nextPortWrite(nListenPID); + } + if (!ns.readPort(nListenPID)) { ns.tprint("Error! Couldn't start Corporation!"); return }; ns.tprint(oCorpStatus); while (nStep < 199) { nStep = oCorpStatus.nStep; @@ -79,9 +88,24 @@ export async function main(ns) { nListenPID = ns.run("/corp/HireWorkers.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData)); await ns.nextPortWrite(nListenPID); } - oCorpStatus.nStep = 200; + oCorpStatus.nStep = 50; break; case 50: + let aCurrentGoods = [ + {"sMaterialName":"Food","yAmount":"MAX","yPrice":"MP"}, + {"sMaterialName":"Plants","yAmount":"MAX","yPrice":"MP"} + ] + aCurrentGoods.forEach(async (entry) =>{ + for (let sCity of aCitites) { + forEach + nListenPID = ns.run("/corp/SetSalePrices.js", 1, sDivisionName, sCity, oCurrentGoods); + await ns.nextPortWrite(nListenPID); + oOfficeData = ns.readPort(nListenPID); + ns.tprint(oOfficeData); + nListenPID = ns.run("/corp/HireWorkers.js", 1, sDivisionName, sCity, JSON.stringify(oOfficeData)); + await ns.nextPortWrite(nListenPID); + }}) + oCorpStatus.nStep = 200; break; case 60: break; diff --git a/Ramses/home/EveryServerRun.js b/Ramses/home/EveryServerRun.js index e7deaf5..e9f9481 100644 --- a/Ramses/home/EveryServerRun.js +++ b/Ramses/home/EveryServerRun.js @@ -39,7 +39,7 @@ export async function main(ns) { let nMaxRam; let nScripts; - serverList.forEach((entry) => { + serverList.forEach(async (entry) => { //let rootAccess = ns.hasRootAccess(currentServer); //ns.tprint(entry.serverName + " sTarget = " + sTarget); diff --git a/Ramses/home/corp/CreateCorp.js b/Ramses/home/corp/CreateCorp.js new file mode 100644 index 0000000..aa0dd7d --- /dev/null +++ b/Ramses/home/corp/CreateCorp.js @@ -0,0 +1,7 @@ +/** @param {NS} ns */ +export async function main(ns) { + let [sCorpName] = ns.args; + ns.corporation.createCorporation(sCorpName,false) + ns.writePort(ns.pid, true); + } + \ No newline at end of file diff --git a/Ramses/home/corp/HasCorp.js b/Ramses/home/corp/HasCorp.js new file mode 100644 index 0000000..dde0fff --- /dev/null +++ b/Ramses/home/corp/HasCorp.js @@ -0,0 +1,5 @@ +/** @param {NS} ns */ +export async function main(ns) { + ns.writePort(ns.pid,ns.corporation.hasCorporation()); + } + \ No newline at end of file diff --git a/Ramses/home/corp/SetSalePrices.js b/Ramses/home/corp/SetSalePrices.js new file mode 100644 index 0000000..c1fbc3b --- /dev/null +++ b/Ramses/home/corp/SetSalePrices.js @@ -0,0 +1,7 @@ +/** @param {NS} ns */ +export async function main(ns) { + let [sDivName, sCity, oCurrentGoods] = ns.args; + oCurrentGoods = JSON.parse(oCurrentGoods); + ns.corporation.sellMaterial(sDivName,sCity,oCurrentGoods.sMaterialName,oCurrentGoods.yAmount,oCurrentGoods.yPrice); + ns.writePort(ns.pid, true); + } \ No newline at end of file