From ad1df008892aa980a3d0b40c81a5849fd2c96253 Mon Sep 17 00:00:00 2001 From: danielyxie Date: Wed, 9 Jan 2019 02:43:59 -0800 Subject: [PATCH] Home Computer now has max RAM --- src/Constants.ts | 47 +++++++-------------------------------- src/NetscriptFunctions.js | 10 ++++++--- src/ServerPurchases.js | 9 ++++++-- 3 files changed, 22 insertions(+), 44 deletions(-) diff --git a/src/Constants.ts b/src/Constants.ts index ea6ea6a12..355fc3b04 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -104,10 +104,11 @@ export let CONSTANTS: IMap = { NumNetscriptPorts: 20, //Server constants - ServerBaseGrowthRate: 1.03, //Unadjusted Growth rate - ServerMaxGrowthRate: 1.0035, //Maximum possible growth rate (max rate accounting for server security) - ServerFortifyAmount: 0.002, //Amount by which server's security increases when its hacked/grown - ServerWeakenAmount: 0.05, //Amount by which server's security decreases when weakened + HomeComputerMaxRam: 1073741824, // 2 ^ 30 + ServerBaseGrowthRate: 1.03, // Unadjusted Growth rate + ServerMaxGrowthRate: 1.0035, // Maximum possible growth rate (max rate accounting for server security) + ServerFortifyAmount: 0.002, // Amount by which server's security increases when its hacked/grown + ServerWeakenAmount: 0.05, // Amount by which server's security decreases when weakened PurchasedServerLimit: 25, PurchasedServerMaxRam: 1048576, //2^20 @@ -506,40 +507,8 @@ export let CONSTANTS: IMap = { LatestUpdate: ` - v0.42.0 - * Corporation Changes: - ** Corporation can now be self-funded with $150b or using seed money in exchange for 500m newly-issued shares - ** In BitNode-3, you no longer start with $150b - ** Changed initial market prices for many materials - ** Changed the way a material's demand, competition, and market price change over time - ** The sale price of materials can no longer be marked-up as high - ** Added a Research Tree mechanic. Spend Scientific Research on permanent upgrades for each industry - ** You can now redistribute earnings to shareholders (including yourself) as dividends - ** Cost of "Smart Supply" upgraded reduced from $50b to $25b - ** Now has offline progress, which works similarly to the Gang/Bladeburner mechanics - ** Slightly reduced the amount of money offered to you by investment firms - ** Employee salaries now slowly increase over time - ** Slightly reduced the effect "Real Estate" has on the Production Multiplier for the Agriculture industry - ** Changed the way your Corporation's value is calculated (this is what determines stock price) - ** After taking your corporation public, it is now possible to issue new shares to raise capital - ** Issuing new shares can only be done once every 12 hours - ** Buying back shares must now be done at a premium - ** Selling shares can now only be done once per hour - ** Selling large amounts of shares now immediately impacts stock price (during the transaction) - ** Reduced the initial cost of the DreamSense upgrade from $8b to $4b, but increased its price multiplier - ** Reduced the price multiplier for ABC SalesBots upgrade - - * Added getOrders() Netscript function to the TIX API - * Added getAugmentationPrereq() Singularity function (by havocmayhem) - * Added hackAnalyzePercent() and hackAnalyzeThreads() Netscript functions - * Stock Market, Travel, and Corporation main menu links are now properly styled - * Many pop-up/dialog boxes now support the 'Enter' and 'Esc' hotkeys. If you find a pop-up/dialog box that doesnt support this, let me know specifically which one ('Enter' for the default option, 'Esc' for cancelling and closing the pop-up box) - * Added "brace_style = preserve_inline" configuration to Script Editor Beautifier - * ServerProfiler.exe can now be purchased from the Dark Web - * Added an option to copy save data to clipboard - * Added total multiplier information on the "Augmentations" page - * Bug Fix: gymWorkout() Singularity function should now work properly with Millenium Fitness Gym - * Began migrating gameplay information to the ReadTheDocs documentation - ` + v0.43.0 + * Home Computer RAM is now capped at 2 ^ 30 GB (1073741824 GB) + ` } diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 0bd160870..6f90ddde0 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -2992,16 +2992,20 @@ function NetscriptFunctions(workerScript) { } } - const cost = Player.getUpgradeHomeRamCost(); + // Check if we're at max RAM + const homeComputer = Player.getHomeComputer(); + if (homeComputer.maxRam >= CONSTANTS.HomeComputerMaxRam) { + workerScript.log(`ERROR: upgradeHomeRam() failed because your home computer is at max RAM`); + return false; + } + const cost = Player.getUpgradeHomeRamCost(); if (Player.money.lt(cost)) { workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money"); return false; } - var homeComputer = Player.getHomeComputer(); homeComputer.maxRam *= 2; - Player.loseMoney(cost); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); diff --git a/src/ServerPurchases.js b/src/ServerPurchases.js index 18915770b..39bd22527 100644 --- a/src/ServerPurchases.js +++ b/src/ServerPurchases.js @@ -58,9 +58,14 @@ function purchaseRamForHomeComputer(cost) { return; } - var homeComputer = Player.getHomeComputer(); - homeComputer.maxRam *= 2; + const homeComputer = Player.getHomeComputer(); + if (homeComputer.maxRam >= CONSTANTS.HomeComputerMaxRam) { + dialogBoxCreate(`You cannot upgrade your home computer RAM because it is at its maximum possible value`); + return; + } + + homeComputer.maxRam *= 2; Player.loseMoney(cost); dialogBoxCreate("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");