_internal.classes.store.hacknet.HacknetStore - vladzaharia/bitburner GitHub Wiki
_internal/classes/store/hacknet.HacknetStore
Layer on top of NS and Hacknet to simplify node management.
-
Store<HacknetParams,null>↳
HacknetStore
- _checkParams
- _purchase
- _purchaseNode
- _sell
- _updateBaseNodeStats
- _updateNumNodes
- _upgradeNodeToBaseline
- canPurchase
- getAvailableMoney
- getPurchaseCost
- purchase
- purchaseOnAllNodes
- sell
- upgradeAllNodesToBaseline
• new HacknetStore(ns)
Creates a new Hacknet instance which allows for purchasing and upgrading nodes.
| Name | Type | Description |
|---|---|---|
ns |
NS |
The Netscript object. |
_internal/classes/store/hacknet.ts:42
• Private _baseNode: NodeStats
Base node (index 0) to use for upgrades.
_internal/classes/store/hacknet.ts:34
• Private Readonly _hacknet: Hacknet
Hacknet object within NS.
_internal/classes/store/hacknet.ts:28
• Protected _ns: NS
The Netscript object.
_internal/classes/store/_base.ts:15
• Private _numNodes: number = 0
Current number of nodes purchased.
_internal/classes/store/hacknet.ts:31
▸ Protected _checkParams(params): boolean
Verifies the Hacknet purchase transaction.
If upgrade is set to "node", checks that index is unset.
Otherwise, checks if index is set.
override
| Name | Type | Description |
|---|---|---|
params |
HacknetParams |
Parameters for this transaction. |
boolean
Whether the parameters are valid.
_internal/classes/store/hacknet.ts:257
▸ Protected _purchase(params): Promise<boolean>
Upgrade upgrade stat on index node by levels amount.
override
async
throws If trying to upgrade "node" or unknown upgrade type.
| Name | Type |
|---|---|
params |
HacknetParams |
Promise<boolean>
_internal/classes/store/hacknet.ts:111
▸ Private _purchaseNode(): boolean
Purchase a new node.
boolean
_internal/classes/store/hacknet.ts:198
▸ Protected _sell(params): Promise<boolean>
Sell an item with params params, must be overridden by implementing classes if supported.
virtual Must be overridden by implementing classes.
async
| Name | Type | Description |
|---|---|---|
params |
null |
Parameters for this sale. |
Promise<boolean>
Whether the transaction was successful.
_internal/classes/store/_base.ts:137
▸ Private _updateBaseNodeStats(): NodeStats
Update the base node stats.
NodeStats
The statistics of the base node.
_internal/classes/store/hacknet.ts:284
▸ Private _updateNumNodes(): number
Update the number of nodes purchased.
number
The number of nodes purchased.
_internal/classes/store/hacknet.ts:275
▸ Private _upgradeNodeToBaseline(index): Promise<boolean>
Upgrade node index to base node stats.
async
| Name | Type | Description |
|---|---|---|
index |
number |
The index of the node to upgrade. |
Promise<boolean>
_internal/classes/store/hacknet.ts:215
▸ canPurchase(params): boolean
Checks whether the user can purchase based on parameters params.
| Name | Type | Description |
|---|---|---|
params |
HacknetParams |
Parameters for this transaction. |
boolean
Whether this transaction is possible.
_internal/classes/store/_base.ts:59
▸ getAvailableMoney(): number
Gets the amount of money available to this store.
number
Available money according to this._budget.
_internal/classes/store/_base.ts:41
▸ getPurchaseCost(params, useNodes?): number
Gets the price of a hacknet upgrade, multiplied by number of nodes.
override
| Name | Type | Default value |
|---|---|---|
params |
HacknetParams |
undefined |
useNodes |
boolean |
false |
number
The price of the upgrade.
_internal/classes/store/hacknet.ts:69
▸ purchase(params): Promise<boolean>
Purchase an item with parameters params if there is money available.
virtual Must be overridden by implementing classes.
async
| Name | Type | Description |
|---|---|---|
params |
HacknetParams |
Parameters for this transaction. |
Promise<boolean>
Whether the transaction was successful.
_internal/classes/store/_base.ts:85
▸ purchaseOnAllNodes(params): Promise<boolean>
Upgrade upgrade stat on all nodes by levels amount.
async
throws If trying to upgrade "node".
| Name | Type | Description |
|---|---|---|
params |
HacknetParams |
Parameters for purchasing. |
Promise<boolean>
Whether the upgrades were successful.
_internal/classes/store/hacknet.ts:155
▸ sell(params): Promise<boolean>
Sell an item with params params, if possible.
async
| Name | Type | Description |
|---|---|---|
params |
null |
Parameters for this sale. |
Promise<boolean>
Whether the transaction was successful.
_internal/classes/store/_base.ts:122
▸ upgradeAllNodesToBaseline(): Promise<boolean>
Upgrade all nodes to base node stats, if needed.
async
Promise<boolean>