Added maxNumNodes to the hacknet API

This commit is contained in:
Olivier Gagnon 2021-03-07 16:03:21 -05:00
parent 58e38faad6
commit dabb5016fc
5 changed files with 14 additions and 2 deletions

@ -0,0 +1,8 @@
maxNumNodes() Netscript Function
=============================
.. js:function:: maxNumNodes()
:RAM cost: 0 GB
Returns the maximum number of Hacknet Nodes you can own.

@ -242,6 +242,7 @@ export let CONSTANTS: IMap<any> = {
* getCharacterInformation now additionally returns exp * getCharacterInformation now additionally returns exp
* pid resets back to 1 when installing or destroying a BitNode. * pid resets back to 1 when installing or destroying a BitNode.
* New '.ns' scripts start with a main function. * New '.ns' scripts start with a main function.
* hacknet.maxNumNodes returns the maximum number of hacknet nodes.
Misc. Misc.
* Fixed an issue where SF3 was listed as infinitly repeatable and SF12 as * Fixed an issue where SF3 was listed as infinitly repeatable and SF12 as

@ -52,7 +52,7 @@ import {
purchaseHashUpgrade, purchaseHashUpgrade,
updateHashManagerCapacity, updateHashManagerCapacity,
} from "./Hacknet/HacknetHelpers"; } from "./Hacknet/HacknetHelpers";
import { HacknetServer } from "./Hacknet/HacknetServer"; import { HacknetServer, MaxNumberHacknetServers } from "./Hacknet/HacknetServer";
import { CityName } from "./Locations/data/CityNames"; import { CityName } from "./Locations/data/CityNames";
import { LocationName } from "./Locations/data/LocationNames"; import { LocationName } from "./Locations/data/LocationNames";
@ -392,6 +392,9 @@ function NetscriptFunctions(workerScript) {
numNodes : function() { numNodes : function() {
return Player.hacknetNodes.length; return Player.hacknetNodes.length;
}, },
maxNumNodes : function() {
return MaxNumberHacknetServers;
},
purchaseNode : function() { purchaseNode : function() {
return purchaseHacknet(); return purchaseHacknet();
}, },

@ -103,7 +103,7 @@ let NetscriptFunctions =
// Hacknet Node API // Hacknet Node API
"hacknet|numNodes|purchaseNode|getPurchaseNodeCost|getNodeStats|" + "hacknet|numNodes|purchaseNode|getPurchaseNodeCost|getNodeStats|" +
"upgradeLevel|upgradeRam|upgradeCore|upgradeCache|getLevelUpgradeCost|" + "upgradeLevel|upgradeRam|upgradeCore|upgradeCache|getLevelUpgradeCost|" +
"getRamUpgradeCost|getCoreUpgradeCost|getCacheUpgradeCost|" + "getRamUpgradeCost|getCoreUpgradeCost|getCacheUpgradeCost|maxNumNodes|" +
// Gang API // Gang API
"gang|" + "gang|" +