From 737d9e027f440e091d8b0fd5644b4e30bcafb1eb Mon Sep 17 00:00:00 2001 From: "tyasuh.taeragan@gmail.com" Date: Thu, 14 Oct 2021 12:01:42 -0400 Subject: [PATCH 1/4] upgradeHomeCores --- .../netscriptsingularityfunctions.rst | 1 + .../singularityfunctions/upgradeHomeCores.rst | 12 ++++++ src/NetscriptFunctions.ts | 41 +++++++++++++++++-- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 doc/source/netscript/singularityfunctions/upgradeHomeCores.rst diff --git a/doc/source/netscript/netscriptsingularityfunctions.rst b/doc/source/netscript/netscriptsingularityfunctions.rst index 146fac645..dbea2ed0c 100644 --- a/doc/source/netscript/netscriptsingularityfunctions.rst +++ b/doc/source/netscript/netscriptsingularityfunctions.rst @@ -43,6 +43,7 @@ The player has access to all of these functions while in BitNode-4. Completing B getFactionRep() getFactionFavor() getFactionFavorGain() + upgradeHomeCores() .. toctree:: :caption: Level 3 Functions diff --git a/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst b/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst new file mode 100644 index 000000000..cdaeeb4db --- /dev/null +++ b/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst @@ -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 RAM is successfully upgraded, and false otherwise. diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index cc0192905..f0cd762b1 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -3276,6 +3276,41 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { return true; } 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 *= 2; + Player.loseMoney(cost); + + Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); + workerScript.log( + "upgradeHomeCores", + `Purchased additional CORES for home computer! It now has $( + homeComputer.cpuCores + )} of CORES.`, + ); + return true; + }, + getUpgradeHomeCoresCost: function (): any { + updateDynamicRam("getUpgradeHomeCoresCost", getRamCost("getUpgradeHomeCoresCost")); + checkSingularityAccess("getUpgradeHomeCoresCost", 2); + + return Player.getUpgradeHomeCoresCost(); }, upgradeHomeRam: function (): any { updateDynamicRam("upgradeHomeRam", getRamCost("upgradeHomeRam")); @@ -3299,9 +3334,9 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); workerScript.log( - "upgradeHomeRam", - `Purchased additional RAM for home computer! It now has ${numeralWrapper.formatRAM( - homeComputer.maxRam, + "upgradeHomeCores", + `Purchased additional RAM for home computer! It now has ${( + homeComputer.cpuCores )} of RAM.`, ); return true; From cee716bbb082a48a1a629c8c03b4360041373184 Mon Sep 17 00:00:00 2001 From: "tyasuh.taeragan@gmail.com" Date: Thu, 14 Oct 2021 12:22:35 -0400 Subject: [PATCH 2/4] Typo Corrections --- package-lock.json | 1 + src/NetscriptFunctions.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index af00c6697..18e9f6d6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "bitburner", "version": "0.56.0", "hasInstallScript": true, "license": "SEE LICENSE IN license.txt", diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index f0cd762b1..8e28c236e 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -3335,8 +3335,8 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); workerScript.log( "upgradeHomeCores", - `Purchased additional RAM for home computer! It now has ${( - homeComputer.cpuCores + `Purchased additional RAM for home computer! It now has ${numeralWrapper.formatRAM( + homeComputer.maxRam, )} of RAM.`, ); return true; From f6ffe5b5befc96b29f8fc537158965654ca148c9 Mon Sep 17 00:00:00 2001 From: "tyasuh.taeragan@gmail.com" Date: Thu, 14 Oct 2021 14:35:57 -0400 Subject: [PATCH 3/4] Corrective Revisions --- src/NetscriptFunctions.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 8e28c236e..00dd44b10 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -3300,10 +3300,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); workerScript.log( "upgradeHomeCores", - `Purchased additional CORES for home computer! It now has $( - homeComputer.cpuCores - )} of CORES.`, - ); + `Purchased an additional core for home computer! It now has ${(homeComputer.cpuCores)} cores.`,); return true; }, getUpgradeHomeCoresCost: function (): any { @@ -3334,7 +3331,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); workerScript.log( - "upgradeHomeCores", + "upgradeHomeRam", `Purchased additional RAM for home computer! It now has ${numeralWrapper.formatRAM( homeComputer.maxRam, )} of RAM.`, From db9c3193f70e9a7c9ae950f71b4cf9fa7dc970c7 Mon Sep 17 00:00:00 2001 From: "tyasuh.taeragan@gmail.com" Date: Thu, 14 Oct 2021 15:20:05 -0400 Subject: [PATCH 4/4] Commented Fixes --- .../netscript/singularityfunctions/upgradeHomeCores.rst | 2 +- src/NetscriptFunctions.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst b/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst index cdaeeb4db..eb1a76c81 100644 --- a/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst +++ b/doc/source/netscript/singularityfunctions/upgradeHomeCores.rst @@ -9,4 +9,4 @@ upgradeHomeRam() Netscript 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 RAM is successfully upgraded, and false otherwise. + This function will return true if the player's home computer core count is successfully upgraded, and false otherwise. diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 00dd44b10..c53e7f071 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -3284,7 +3284,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { // 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.`); + workerScript.log("upgradeHomeCores", `Your home computer is at max cores.`); return false; } @@ -3294,13 +3294,13 @@ function NetscriptFunctions(workerScript: WorkerScript): NS { return false; } - homeComputer.cpuCores *= 2; + 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.`,); + `Purchased an additional core for home computer! It now has ${(homeComputer.cpuCores)} cores.`,); return true; }, getUpgradeHomeCoresCost: function (): any {