Options
All
  • Public
  • Public/Protected
  • All
Menu

Abstract class handling priority and sleep returns.

abstract
implements

IFocusable

Hierarchy

Implements

Index

Constructors

  • new BaseFocusable(name: string, ns: NS, priority: number, detailField?: string, sleepTime?: number, checkInterval?: number): BaseFocusable
  • Creates a new focusable action.

    Parameters

    • name: string

      The name of this focusable.

    • ns: NS

      The Netscript object.

    • priority: number

      Priority this action should run at, lower first.

    • Optional detailField: string
    • sleepTime: number = DEFAULT_SLEEP_TIME

      Time to sleep after a successful focus event, defaults to 15 minutes.

    • checkInterval: number = DEFAULT_CHECK_INTERVAL

    Returns BaseFocusable

Properties

_checkInterval: number

Interval to check while sleeping.

_detailField: undefined | string

Field to pull detail from.

_ns: NS

The Netscript object.

_priority: number

Priority of this focusable.

_sleepTime: number

Time to sleep after a successful focus event.

name: string

The name of the focusable.

Methods

  • _focus(): boolean
  • Execute focus using ns.singularity, must be implemented by subclass.

    virtual

    Must be overridden by implementing classes.

    Returns boolean

    Whether the focus action was successful.

  • canFocus(): boolean
  • virtual

    Must be overridden by implementing classes.

    Returns boolean

  • focus(): number
  • Executes a focus action, returning a predefined sleep time.

    Returns number

    _sleepTime if successful, -1 otherwise.

  • getCheckInterval(): number
  • Gets how often to check for task completion, defaults to this._checkInterval.

    Returns number

    How often to check for task completion.

  • getDetailText(): string
  • Returns value from preset field.

    Returns string

    Value of this._detailField if set, "" otherwise

  • getFocusTime(): number
  • Get time needed for task, defaults to this._sleepTime.

    Returns number

    The time to sleep before running the manager again.

  • getPriority(): number
  • Gets the current priority of the focusable action.

    Returns number

    Current priority, with 0 being the highest.

  • shouldContinueRunning(): boolean
  • Checks if the player is still working.

    virtual

    Can be overridden, but run super.shouldContinueRunning if you do.

    Returns boolean

    True if user is still working, false otherwise.

  • shouldRunInBackground(): boolean
  • Checks if the action should run in the background, defaults to if priority is > 50.

    Returns boolean

    True if this can run in the background, False if it needs to be in the foreground.

Generated using TypeDoc