upgradeHomeCores

This commit is contained in:
tyasuh.taeragan@gmail.com
2021-10-14 12:01:42 -04:00
parent 3f1d4875e7
commit 737d9e027f
3 changed files with 51 additions and 3 deletions
+38 -3
View File
@@ -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;