From dabb5016fc1855b4b53c18f3f84a3b4a44aa6cd1 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sun, 7 Mar 2021 16:03:21 -0500 Subject: [PATCH] Added maxNumNodes to the hacknet API --- doc/Stats | 0 doc/source/netscript/hacknetnodeapi/maxNumNodes.rst | 8 ++++++++ src/Constants.ts | 1 + src/NetscriptFunctions.js | 5 ++++- src/ScriptEditor/AceNetscriptMode.js | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) delete mode 100644 doc/Stats create mode 100644 doc/source/netscript/hacknetnodeapi/maxNumNodes.rst diff --git a/doc/Stats b/doc/Stats deleted file mode 100644 index e69de29bb..000000000 diff --git a/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst b/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst new file mode 100644 index 000000000..0007a5036 --- /dev/null +++ b/doc/source/netscript/hacknetnodeapi/maxNumNodes.rst @@ -0,0 +1,8 @@ +maxNumNodes() Netscript Function +============================= + +.. js:function:: maxNumNodes() + + :RAM cost: 0 GB + + Returns the maximum number of Hacknet Nodes you can own. diff --git a/src/Constants.ts b/src/Constants.ts index 55e54ea35..023686096 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -242,6 +242,7 @@ export let CONSTANTS: IMap = { * getCharacterInformation now additionally returns exp * pid resets back to 1 when installing or destroying a BitNode. * New '.ns' scripts start with a main function. + * hacknet.maxNumNodes returns the maximum number of hacknet nodes. Misc. * Fixed an issue where SF3 was listed as infinitly repeatable and SF12 as diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 689d834b0..285c1ee56 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -52,7 +52,7 @@ import { purchaseHashUpgrade, updateHashManagerCapacity, } from "./Hacknet/HacknetHelpers"; -import { HacknetServer } from "./Hacknet/HacknetServer"; +import { HacknetServer, MaxNumberHacknetServers } from "./Hacknet/HacknetServer"; import { CityName } from "./Locations/data/CityNames"; import { LocationName } from "./Locations/data/LocationNames"; @@ -392,6 +392,9 @@ function NetscriptFunctions(workerScript) { numNodes : function() { return Player.hacknetNodes.length; }, + maxNumNodes : function() { + return MaxNumberHacknetServers; + }, purchaseNode : function() { return purchaseHacknet(); }, diff --git a/src/ScriptEditor/AceNetscriptMode.js b/src/ScriptEditor/AceNetscriptMode.js index a5dea72d3..06a4a818e 100644 --- a/src/ScriptEditor/AceNetscriptMode.js +++ b/src/ScriptEditor/AceNetscriptMode.js @@ -103,7 +103,7 @@ let NetscriptFunctions = // Hacknet Node API "hacknet|numNodes|purchaseNode|getPurchaseNodeCost|getNodeStats|" + "upgradeLevel|upgradeRam|upgradeCore|upgradeCache|getLevelUpgradeCost|" + - "getRamUpgradeCost|getCoreUpgradeCost|getCacheUpgradeCost|" + + "getRamUpgradeCost|getCoreUpgradeCost|getCacheUpgradeCost|maxNumNodes|" + // Gang API "gang|" +