Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • Store<HacknetParams, null>
    • HacknetStore

Index

Constructors

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

    Parameters

    • ns: NS

      The Netscript object.

    Returns HacknetStore

Properties

_baseNode: NodeStats

Base node (index 0) to use for upgrades.

_hacknet: Hacknet

Hacknet object within NS.

_ns: NS

The Netscript object.

_numNodes: number = 0

Current number of nodes purchased.

Methods

  • _checkParams(params: HacknetParams): 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

    • params: HacknetParams

      Parameters for this transaction.

    Returns boolean

    Whether the parameters are valid.

  • _purchase(params: HacknetParams): Promise<boolean>
  • Upgrade upgrade stat on index node by levels amount.

    override
    async
    throws

    If trying to upgrade "node" or unknown upgrade type.

    Parameters

    • params: HacknetParams

    Returns Promise<boolean>

  • _purchaseNode(): boolean
  • Purchase a new node.

    Returns boolean

  • _sell(params: null): 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

    • params: null

      Parameters for this sale.

    Returns Promise<boolean>

    Whether the transaction was successful.

  • _updateBaseNodeStats(): NodeStats
  • Update the base node stats.

    Returns NodeStats

    The statistics of the base node.

  • _updateNumNodes(): number
  • Update the number of nodes purchased.

    Returns number

    The number of nodes purchased.

  • _upgradeNodeToBaseline(index: number): Promise<boolean>
  • Upgrade node index to base node stats.

    async

    Parameters

    • index: number

      The index of the node to upgrade.

    Returns Promise<boolean>

  • canPurchase(params: HacknetParams): boolean
  • Checks whether the user can purchase based on parameters params.

    Parameters

    • params: HacknetParams

      Parameters for this transaction.

    Returns boolean

    Whether this transaction is possible.

  • getAvailableMoney(): number
  • Gets the amount of money available to this store.

    Returns number

    Available money according to this._budget.

  • getPurchaseCost(params: HacknetParams, useNodes?: boolean): number
  • Gets the price of a hacknet upgrade, multiplied by number of nodes.

    override

    Parameters

    • params: HacknetParams
    • useNodes: boolean = false

    Returns number

    The price of the upgrade.

  • purchase(params: HacknetParams): Promise<boolean>
  • Purchase an item with parameters params if there is money available.

    virtual

    Must be overridden by implementing classes.

    async

    Parameters

    • params: HacknetParams

      Parameters for this transaction.

    Returns Promise<boolean>

    Whether the transaction was successful.

  • purchaseOnAllNodes(params: HacknetParams): Promise<boolean>
  • Upgrade upgrade stat on all nodes by levels amount.

    async
    throws

    If trying to upgrade "node".

    Parameters

    • params: HacknetParams

      Parameters for purchasing.

    Returns Promise<boolean>

    Whether the upgrades were successful.

  • sell(params: null): Promise<boolean>
  • Sell an item with params params, if possible.

    async

    Parameters

    • params: null

      Parameters for this sale.

    Returns Promise<boolean>

    Whether the transaction was successful.

  • upgradeAllNodesToBaseline(): Promise<boolean>
  • Upgrade all nodes to base node stats, if needed.

    async

    Returns Promise<boolean>

Generated using TypeDoc