_internal.classes.store.hacknet.HacknetStore - vladzaharia/bitburner GitHub Wiki

Class: HacknetStore

_internal/classes/store/hacknet.HacknetStore

Layer on top of NS and Hacknet to simplify node management.

Hierarchy

  • Store<HacknetParams, null>

    HacknetStore

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new HacknetStore(ns)

Creates a new Hacknet instance which allows for purchasing and upgrading nodes.

Parameters

Name Type Description
ns NS The Netscript object.

Overrides

Store.constructor

Defined in

_internal/classes/store/hacknet.ts:42

Properties

_baseNode

Private _baseNode: NodeStats

Base node (index 0) to use for upgrades.

Defined in

_internal/classes/store/hacknet.ts:34


_hacknet

Private Readonly _hacknet: Hacknet

Hacknet object within NS.

Defined in

_internal/classes/store/hacknet.ts:28


_ns

Protected _ns: NS

The Netscript object.

Inherited from

Store._ns

Defined in

_internal/classes/store/_base.ts:15


_numNodes

Private _numNodes: number = 0

Current number of nodes purchased.

Defined in

_internal/classes/store/hacknet.ts:31

Methods

_checkParams

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

Parameters

Name Type Description
params HacknetParams Parameters for this transaction.

Returns

boolean

Whether the parameters are valid.

Overrides

Store._checkParams

Defined in

_internal/classes/store/hacknet.ts:257


_purchase

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.

Parameters

Name Type
params HacknetParams

Returns

Promise<boolean>

Overrides

Store._purchase

Defined in

_internal/classes/store/hacknet.ts:111


_purchaseNode

Private _purchaseNode(): boolean

Purchase a new node.

Returns

boolean

Defined in

_internal/classes/store/hacknet.ts:198


_sell

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

Parameters

Name Type Description
params null Parameters for this sale.

Returns

Promise<boolean>

Whether the transaction was successful.

Inherited from

Store._sell

Defined in

_internal/classes/store/_base.ts:137


_updateBaseNodeStats

Private _updateBaseNodeStats(): NodeStats

Update the base node stats.

Returns

NodeStats

The statistics of the base node.

Defined in

_internal/classes/store/hacknet.ts:284


_updateNumNodes

Private _updateNumNodes(): number

Update the number of nodes purchased.

Returns

number

The number of nodes purchased.

Defined in

_internal/classes/store/hacknet.ts:275


_upgradeNodeToBaseline

Private _upgradeNodeToBaseline(index): Promise<boolean>

Upgrade node index to base node stats.

async

Parameters

Name Type Description
index number The index of the node to upgrade.

Returns

Promise<boolean>

Defined in

_internal/classes/store/hacknet.ts:215


canPurchase

canPurchase(params): boolean

Checks whether the user can purchase based on parameters params.

Parameters

Name Type Description
params HacknetParams Parameters for this transaction.

Returns

boolean

Whether this transaction is possible.

Inherited from

Store.canPurchase

Defined in

_internal/classes/store/_base.ts:59


getAvailableMoney

getAvailableMoney(): number

Gets the amount of money available to this store.

Returns

number

Available money according to this._budget.

Inherited from

Store.getAvailableMoney

Defined in

_internal/classes/store/_base.ts:41


getPurchaseCost

getPurchaseCost(params, useNodes?): number

Gets the price of a hacknet upgrade, multiplied by number of nodes.

override

Parameters

Name Type Default value
params HacknetParams undefined
useNodes boolean false

Returns

number

The price of the upgrade.

Overrides

Store.getPurchaseCost

Defined in

_internal/classes/store/hacknet.ts:69


purchase

purchase(params): Promise<boolean>

Purchase an item with parameters params if there is money available.

virtual Must be overridden by implementing classes.

async

Parameters

Name Type Description
params HacknetParams Parameters for this transaction.

Returns

Promise<boolean>

Whether the transaction was successful.

Inherited from

Store.purchase

Defined in

_internal/classes/store/_base.ts:85


purchaseOnAllNodes

purchaseOnAllNodes(params): Promise<boolean>

Upgrade upgrade stat on all nodes by levels amount.

async

throws If trying to upgrade "node".

Parameters

Name Type Description
params HacknetParams Parameters for purchasing.

Returns

Promise<boolean>

Whether the upgrades were successful.

Defined in

_internal/classes/store/hacknet.ts:155


sell

sell(params): Promise<boolean>

Sell an item with params params, if possible.

async

Parameters

Name Type Description
params null Parameters for this sale.

Returns

Promise<boolean>

Whether the transaction was successful.

Inherited from

Store.sell

Defined in

_internal/classes/store/_base.ts:122


upgradeAllNodesToBaseline

upgradeAllNodesToBaseline(): Promise<boolean>

Upgrade all nodes to base node stats, if needed.

async

Returns

Promise<boolean>

Defined in

_internal/classes/store/hacknet.ts:180

⚠️ **GitHub.com Fallback** ⚠️