mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-27 03:25:44 +02:00
MISC: move server constants into their own constant (#1075)
This commit is contained in:
@@ -6,7 +6,7 @@ import { AddToAllServers, createUniqueRandomIp, GetServer, renameServer } from "
|
||||
import { safelyCreateUniqueServer } from "./ServerHelpers";
|
||||
|
||||
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
||||
import { CONSTANTS } from "../Constants";
|
||||
import { ServerConstants } from "./data/Constants";
|
||||
import { Player } from "@player";
|
||||
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
@@ -20,6 +20,7 @@ import { workerScripts } from "../Netscript/WorkerScripts";
|
||||
* @returns Cost of purchasing the given server. Returns infinity for invalid arguments
|
||||
*/
|
||||
export function getPurchaseServerCost(ram: number): number {
|
||||
// TODO shift checks into
|
||||
const sanitizedRam = Math.round(ram);
|
||||
if (isNaN(sanitizedRam) || !isPowerOfTwo(sanitizedRam) || !(Math.sign(sanitizedRam) === 1)) {
|
||||
return Infinity;
|
||||
@@ -33,7 +34,7 @@ export function getPurchaseServerCost(ram: number): number {
|
||||
|
||||
return (
|
||||
sanitizedRam *
|
||||
CONSTANTS.BaseCostFor1GBOfRamServer *
|
||||
ServerConstants.BaseCostFor1GBOfRamServer *
|
||||
currentNodeMults.PurchasedServerCost *
|
||||
Math.pow(currentNodeMults.PurchasedServerSoftcap, upg)
|
||||
);
|
||||
@@ -86,11 +87,11 @@ export const renamePurchasedServer = (hostname: string, newName: string): void =
|
||||
};
|
||||
|
||||
export function getPurchaseServerLimit(): number {
|
||||
return Math.round(CONSTANTS.PurchasedServerLimit * currentNodeMults.PurchasedServerLimit);
|
||||
return Math.round(ServerConstants.PurchasedServerLimit * currentNodeMults.PurchasedServerLimit);
|
||||
}
|
||||
|
||||
export function getPurchaseServerMaxRam(): number {
|
||||
const ram = Math.round(CONSTANTS.PurchasedServerMaxRam * currentNodeMults.PurchasedServerMaxRam);
|
||||
const ram = Math.round(ServerConstants.PurchasedServerMaxRam * currentNodeMults.PurchasedServerMaxRam);
|
||||
|
||||
// Round this to the nearest power of 2
|
||||
return 1 << (31 - Math.clz32(ram));
|
||||
@@ -155,7 +156,7 @@ export function purchaseRamForHomeComputer(): void {
|
||||
}
|
||||
|
||||
const homeComputer = Player.getHomeComputer();
|
||||
if (homeComputer.maxRam >= CONSTANTS.HomeComputerMaxRam) {
|
||||
if (homeComputer.maxRam >= ServerConstants.HomeComputerMaxRam) {
|
||||
dialogBoxCreate(`You cannot upgrade your home computer RAM because it is at its maximum possible value`);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user