diff --git a/src/GameOptions/ui/ConnectionBauble.tsx b/src/GameOptions/ui/ConnectionBauble.tsx
index 599a3389d..75965764c 100644
--- a/src/GameOptions/ui/ConnectionBauble.tsx
+++ b/src/GameOptions/ui/ConnectionBauble.tsx
@@ -1,18 +1,19 @@
+import { Typography } from "@mui/material";
import React, { useState, useEffect } from "react";
interface baubleProps {
- callback: () => boolean;
+ isConnected: () => boolean;
}
export const ConnectionBauble = (props: baubleProps): React.ReactElement => {
- const [connection, setConnection] = useState(props.callback());
+ const [connection, setConnection] = useState(props.isConnected());
useEffect(() => {
const timer = setInterval(() => {
- setConnection(props.callback());
+ setConnection(props.isConnected());
}, 1000);
return () => clearInterval(timer);
});
- return
{connection ? "Connected" : "Disconnected"}
;
+ return {connection ? "Connected" : "Disconnected"};
};
diff --git a/src/GameOptions/ui/CurrentOptionsPage.tsx b/src/GameOptions/ui/CurrentOptionsPage.tsx
index 7ab6ec88c..b9eaf3029 100644
--- a/src/GameOptions/ui/CurrentOptionsPage.tsx
+++ b/src/GameOptions/ui/CurrentOptionsPage.tsx
@@ -389,7 +389,7 @@ export const CurrentOptionsPage = (props: IProps): React.ReactElement => {
endAdornment: (
-
+
),
}}
diff --git a/src/Netscript/NetscriptHelpers.ts b/src/Netscript/NetscriptHelpers.ts
index 7752c6eac..043292ace 100644
--- a/src/Netscript/NetscriptHelpers.ts
+++ b/src/Netscript/NetscriptHelpers.ts
@@ -500,12 +500,39 @@ function player(ctx: NetscriptContext, p: unknown): IPlayer {
}
function server(ctx: NetscriptContext, s: unknown): Server {
- if (!roughlyIs(new Server(), s)) throw makeRuntimeErrorMsg(ctx, `server should be a Server.`);
+ const fakeServer = {
+ cpuCores: undefined,
+ ftpPortOpen: undefined,
+ hasAdminRights: undefined,
+ hostname: undefined,
+ httpPortOpen: undefined,
+ ip: undefined,
+ isConnectedTo: undefined,
+ maxRam: undefined,
+ organizationName: undefined,
+ ramUsed: undefined,
+ smtpPortOpen: undefined,
+ sqlPortOpen: undefined,
+ sshPortOpen: undefined,
+ purchasedByPlayer: undefined,
+ backdoorInstalled: undefined,
+ baseDifficulty: undefined,
+ hackDifficulty: undefined,
+ minDifficulty: undefined,
+ moneyAvailable: undefined,
+ moneyMax: undefined,
+ numOpenPortsRequired: undefined,
+ openPortCount: undefined,
+ requiredHackingSkill: undefined,
+ serverGrowth: undefined,
+ };
+ if (!roughlyIs(fakeServer, s)) throw makeRuntimeErrorMsg(ctx, `server should be a Server.`);
return s as Server;
}
function roughlyIs(expect: object, actual: unknown): boolean {
if (typeof actual !== "object" || actual == null) return false;
+
const expects = Object.keys(expect);
const actuals = Object.keys(actual);
for (const expect of expects)
diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts
index a68173274..4caab8e2e 100644
--- a/src/Netscript/RamCostGenerator.ts
+++ b/src/Netscript/RamCostGenerator.ts
@@ -546,6 +546,8 @@ const SourceRamCosts = {
},
formulas: {
+ mockServer: 0,
+ mockPlayer: 0,
reputation: {
calculateFavorToRep: 0,
calculateRepToFavor: 0,
diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts
index fb5cae6ab..c5ff32440 100644
--- a/src/NetscriptFunctions/Formulas.ts
+++ b/src/NetscriptFunctions/Formulas.ts
@@ -52,6 +52,9 @@ import { LocationName } from "../Locations/data/LocationNames";
import { calculateFactionExp, calculateFactionRep } from "../Work/formulas/Faction";
import { FactionWorkType } from "../Work/data/FactionWorkType";
+import { Player as INetscriptPlayer, Server as IServerDef } from "../ScriptEditor/NetscriptDefinitions";
+import { defaultMultipliers } from "../PersonObjects/Multipliers";
+
export function NetscriptFormulas(): InternalAPI {
const checkFormulasAccess = function (ctx: NetscriptContext): void {
if (!player.hasProgram(Programs.Formulas.name)) {
@@ -59,6 +62,68 @@ export function NetscriptFormulas(): InternalAPI {
}
};
return {
+ mockServer: () => (): IServerDef => ({
+ cpuCores: 0,
+ ftpPortOpen: false,
+ hasAdminRights: false,
+ hostname: "",
+ httpPortOpen: false,
+ ip: "",
+ isConnectedTo: false,
+ maxRam: 0,
+ organizationName: "",
+ ramUsed: 0,
+ smtpPortOpen: false,
+ sqlPortOpen: false,
+ sshPortOpen: false,
+ purchasedByPlayer: false,
+ backdoorInstalled: false,
+ baseDifficulty: 0,
+ hackDifficulty: 0,
+ minDifficulty: 0,
+ moneyAvailable: 0,
+ moneyMax: 0,
+ numOpenPortsRequired: 0,
+ openPortCount: 0,
+ requiredHackingSkill: 0,
+ serverGrowth: 0,
+ }),
+ mockPlayer: () => (): INetscriptPlayer => ({
+ hp: { current: 0, max: 0 },
+ skills: {
+ hacking: 0,
+ strength: 0,
+ defense: 0,
+ dexterity: 0,
+ agility: 0,
+ charisma: 0,
+ intelligence: 0,
+ },
+ exp: {
+ hacking: 0,
+ strength: 0,
+ defense: 0,
+ dexterity: 0,
+ agility: 0,
+ charisma: 0,
+ intelligence: 0,
+ },
+ mults: defaultMultipliers(),
+ numPeopleKilled: 0,
+ money: 0,
+ city: "",
+ location: "",
+ bitNodeN: 0,
+ totalPlaytime: 0,
+ playtimeSinceLastAug: 0,
+ playtimeSinceLastBitnode: 0,
+ jobs: {},
+ factions: [],
+ tor: false,
+ hasCorporation: false,
+ inBladeburner: false,
+ entropy: 0,
+ }),
reputation: {
calculateFavorToRep:
(ctx: NetscriptContext) =>
diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts
index ffa447b6d..bc5be7694 100644
--- a/src/ScriptEditor/NetscriptDefinitions.d.ts
+++ b/src/ScriptEditor/NetscriptDefinitions.d.ts
@@ -4149,6 +4149,8 @@ interface GangFormulas {
* @public
*/
export interface Formulas {
+ mockServer(): Server;
+ mockPlayer(): Player;
/** Reputation formulas */
reputation: ReputationFormulas;
/** Skills formulas */