Merge pull request #1487 from danielyxie/dev

upgrade home cores
This commit is contained in:
hydroflame 2021-10-14 15:30:41 -04:00 committed by GitHub
commit 418c09e5ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 4 deletions

@ -43,6 +43,7 @@ The player has access to all of these functions while in BitNode-4. Completing B
getFactionRep() <singularityfunctions/getFactionRep> getFactionRep() <singularityfunctions/getFactionRep>
getFactionFavor() <singularityfunctions/getFactionFavor> getFactionFavor() <singularityfunctions/getFactionFavor>
getFactionFavorGain() <singularityfunctions/getFactionFavorGain> getFactionFavorGain() <singularityfunctions/getFactionFavorGain>
upgradeHomeCores() <singularityfunctions/upgradeHomeCores>
.. toctree:: .. toctree::
:caption: Level 3 Functions :caption: Level 3 Functions

@ -0,0 +1,12 @@
upgradeHomeRam() Netscript Function
===================================
.. js:function:: upgradeHomeCores()
:RAM cost: 3 GB
If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
This function will upgrade amount of CORES on the player's home computer. The cost is the same as if you were to do it manually.
This function will return true if the player's home computer core count is successfully upgraded, and false otherwise.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
package-lock.json generated

@ -5,6 +5,7 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "bitburner",
"version": "0.56.0", "version": "0.56.0",
"hasInstallScript": true, "hasInstallScript": true,
"license": "SEE LICENSE IN license.txt", "license": "SEE LICENSE IN license.txt",

@ -2747,6 +2747,39 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
return false; return false;
}, },
upgradeHomeCores: function (): any {
updateDynamicRam("upgradeHomeCores", getRamCost("upgradeHomeCores"));
checkSingularityAccess("upgradeHomeCores", 2);
// Check if we're at max cores
const homeComputer = Player.getHomeComputer();
if (homeComputer.cpuCores >= 8) {
workerScript.log("upgradeHomeCores", `Your home computer is at max cores.`);
return false;
}
const cost = Player.getUpgradeHomeCoresCost();
if (Player.money.lt(cost)) {
workerScript.log("upgradeHomeCores", `You don't have enough money. Need ${numeralWrapper.formatMoney(cost)}`);
return false;
}
homeComputer.cpuCores += 1;
Player.loseMoney(cost);
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
workerScript.log(
"upgradeHomeCores",
`Purchased an additional core for home computer! It now has ${homeComputer.cpuCores} cores.`,
);
return true;
},
getUpgradeHomeCoresCost: function (): any {
updateDynamicRam("getUpgradeHomeCoresCost", getRamCost("getUpgradeHomeCoresCost"));
checkSingularityAccess("getUpgradeHomeCoresCost", 2);
return Player.getUpgradeHomeCoresCost();
},
upgradeHomeRam: function (): any { upgradeHomeRam: function (): any {
updateDynamicRam("upgradeHomeRam", getRamCost("upgradeHomeRam")); updateDynamicRam("upgradeHomeRam", getRamCost("upgradeHomeRam"));
checkSingularityAccess("upgradeHomeRam", 2); checkSingularityAccess("upgradeHomeRam", 2);

@ -28,7 +28,8 @@ export async function executeJSScript(scripts: Script[] = [], workerScript: Work
// but not really behaves like import. Particularly, it cannot // but not really behaves like import. Particularly, it cannot
// load fully dynamic content. So we hide the import from webpack // load fully dynamic content. So we hide the import from webpack
// by placing it inside an eval call. // by placing it inside an eval call.
script.markUpdated(); await script.updateRamUsage(scripts);
workerScript.ramUsage = script.ramUsage;
uurls = _getScriptUrls(script, scripts, []); uurls = _getScriptUrls(script, scripts, []);
script.url = uurls[uurls.length - 1].url; script.url = uurls[uurls.length - 1].url;
script.module = new Promise((resolve) => resolve(eval("import(uurls[uurls.length - 1].url)"))); script.module = new Promise((resolve) => resolve(eval("import(uurls[uurls.length - 1].url)")));