Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Stats<T, E>

Type parameters

Hierarchy

Implements

Index

Constructors

constructor

  • new Stats(host: T): Stats

Properties

Readonly attributes

attributes: AttributeManipulator<this>

Readonly classes

classes: ClassManipulator<this>

Readonly data

data: DataManipulator<this>

Readonly event

Readonly style

style: StyleManipulator<this>

Accessors

childCount

  • get childCount(): number
  • Returns number

dataset

  • get dataset(): DOMStringMap
  • Returns DOMStringMap

element

  • get element(): E
  • Returns E

listen

  • get listen(): (...args: A) => R
  • Alias of .element.addEventListener

    Returns (...args: A) => R

      • (...args: A): R
      • Parameters

        • Rest ...args: A

        Returns R

selectable

Methods

all

  • Returns IStatBase[]

append

appendTo

closest

  • closest(selector: string): null | Element
  • Parameters

    • selector: string

    Returns null | Element

contains

  • Parameters

    Returns boolean

deregisterBindHandlers

  • deregisterBindHandlers(): void

deregisterEventBusSubscriber

  • deregisterEventBusSubscriber(): void

dump

  • dump(filter?: undefined | ((element: HTMLElement, component?: Component) => boolean)): this
  • Parameters

    • Optional filter: undefined | ((element: HTMLElement, component?: Component) => boolean)

    Returns this

exceedsMax

  • Returns whether the stat exceeds its max value. If there is no max for this stat, returns false.

    Parameters

    Returns boolean

exists

  • exists(): boolean
  • Returns boolean

findDescendants

  • findDescendants<E>(selector: string): NodeListOf<E>

get

  • get<STAT_DATA>(stat: Stat | IStat, allowFailure?: boolean): STAT_DATA
  • Returns the stat object of a given Stat. The return type is a vague IStat, but can be passed a type which extends IStatBase for automatic narrowing.

    Type parameters

    Parameters

    • stat: Stat | IStat

      The Stat to get

    • Default value allowFailure: boolean = false

    Returns STAT_DATA

getAs

  • getAs<C>(cls: Class<C>): undefined | C
  • Type parameters

    Parameters

    Returns undefined | C

getBaseMax

  • getBaseMax(stat: Stat | IStat): undefined | number
  • Returns the max of the given stat, or undefined if the stat isn't an IStatMax. Stat bonus is not applied.

    Parameters

    Returns undefined | number

getBaseValue

  • getBaseValue(stat: Stat | IStat): number | undefined
  • Returns the value of the given stat, or undefined if the stat does not exist. Stat bonus is not applied.

    Parameters

    Returns number | undefined

getBonus

  • getBonus(stat: Stat | IStat): undefined | number
  • Parameters

    Returns undefined | number

getBox

  • getBox(regenIfZero?: boolean, forceRegen?: boolean): Rectangle
  • Parameters

    • Default value regenIfZero: boolean = true
    • Default value forceRegen: boolean = false

    Returns Rectangle

getChildren

  • getChildren<C>(selector?: undefined | string): Stream<C>
  • Type parameters

    Parameters

    • Optional selector: undefined | string

    Returns Stream<C>

getIndex

  • getIndex(): number | undefined
  • Returns number | undefined

getMax

  • Returns the max of the given stat, or undefined if the stat isn't an IStatMax. Stat bonus is applied.

    Parameters

    Returns number

getNthChild

  • getNthChild<C>(nth?: number): C
  • Type parameters

    Parameters

    • Default value nth: number = 0

    Returns C

getOffset

  • getOffset(): { left: number; top: number }
  • Returns { left: number; top: number }

    • left: number
    • top: number

getParent

  • getParent<C>(): C | null
  • Type parameters

    Returns C | null

getPercent

  • Returns the "percent" of the given stat, calculated with value / max. If there is no max for this stat, returns undefined.

    Parameters

    Returns number

getTimeUntilChange

  • getTimeUntilChange(stat: Stat | IStat): undefined | number
  • Parameters

    Returns undefined | number

getValue

  • getValue(stat: Stat | IStat, allowFailure?: undefined | true): number | undefined
  • Returns the value of the given stat, or undefined if the stat does not exist. Stat bonus is applied.

    Parameters

    • stat: Stat | IStat
    • Optional allowFailure: undefined | true

    Returns number | undefined

has

  • Returns whether the given stat exists on this entity.

    Parameters

    Returns boolean

hasMax

  • Returns whether the given stat has a max.

    Parameters

    Returns boolean

hide

  • hide(): this
  • Returns this

increase

  • Increases the given Stat by the given amount. Triggers statChange

    Parameters

    Returns boolean

increaseChangeTimer

  • increaseChangeTimer(stat: Stat | IStat, amt?: undefined | number): T
  • Increases the change timer for the given stat.

    Parameters

    • stat: Stat | IStat

      The stat to increase the change timer for.

    • Optional amt: undefined | number

      The amount to increase the change timer by. Defaults to the stat's changeTimerSpeed.

    Returns T

init

  • init(stat: Stat, initializer?: undefined | ((factory: StatFactory) => any)): T
  • init(stat: Stat, value: number, initializer?: undefined | ((factory: StatFactory) => any)): T
  • Initializes the given stat from a StatFactory instance.

    Parameters

    • stat: Stat
    • Optional initializer: undefined | ((factory: StatFactory) => any)

    Returns T

  • Parameters

    • stat: Stat
    • value: number
    • Optional initializer: undefined | ((factory: StatFactory) => any)

    Returns T

isFocused

  • isFocused(): boolean
  • Returns boolean

isVisible

  • isVisible(): boolean

matches

  • matches(selector: string): boolean
  • Parameters

    • selector: string

    Returns boolean

Protected onContextMenu

Protected onEnter

  • onEnter(reason: "mouse" | "focus"): void
  • Parameters

    • reason: "mouse" | "focus"

    Returns void

Protected onLeave

  • onLeave(reason: "mouse" | "focus"): void
  • Parameters

    • reason: "mouse" | "focus"

    Returns void

reduce

  • Reduces the given Stat by the given amount. Triggers statChange

    Parameters

    Returns boolean

reduceChangeTimer

  • reduceChangeTimer(stat: Stat | IStat, amt?: undefined | number): T
  • Decreases the change timer for the given stat.

    Parameters

    • stat: Stat | IStat

      The stat to decrease the change timer for.

    • Optional amt: undefined | number

      The amount to decrease the change timer by. Defaults to the stat's changeTimerSpeed.

    Returns T

reflow

  • reflow(reason: string): void
  • Parameters

    • reason: string

    Returns void

regenerateBoxes

  • regenerateBoxes(): void

registerBindHandlers

  • registerBindHandlers(...untilEvents: Array<keyof Events<this>>): void
  • registerBindHandlers(warnIfNoHandlers: false, ...untilEvents: Array<keyof Events<this>>): void
  • Parameters

    • Rest ...untilEvents: Array<keyof Events<this>>

    Returns void

  • Parameters

    • warnIfNoHandlers: false
    • Rest ...untilEvents: Array<keyof Events<this>>

    Returns void

registerEventBusSubscriber

  • registerEventBusSubscriber(...untilEvents: Array<keyof Events<this>>): void

registerHookHost

  • registerHookHost(name?: undefined | string, ...untilEvents: Array<keyof Events<this>>): void
  • Parameters

    • Optional name: undefined | string
    • Rest ...untilEvents: Array<keyof Events<this>>

    Returns void

remove

  • Removes the given stat from this entity.

    Parameters

    Returns T

removeChangeTimer

  • Parameters

    Returns T

removeTooltip

  • removeTooltip(): void
  • Returns void

repaint

  • repaint(): void

resetChangeTimer

  • Resets the change timer for the given stat.

    Parameters

    • stat: Stat | IStat

      The stat to reset the change timer for.

    Returns T

schedule

  • schedule<A>(cb: (this: this, button: this, ...args: A) => any, ...args: A): this
  • schedule(cb?: undefined | ((this: this, button: this) => any), ...args: any[]): this
  • schedule<A>(ms: number, cb: (this: this, button: this, ...args: A) => any, ...args: A): this
  • schedule(ms: number, cb?: undefined | ((this: this, button: this) => any), ...args: any[]): this
  • schedule<A>(ms: number, debounce: number, cb: (this: this, button: this, ...args: A) => any, ...args: A): this
  • schedule(ms: number, debounce: number, cb?: undefined | ((this: this, button: this) => any), ...args: any[]): this
  • Type parameters

    • A: any[]

    Parameters

    • cb: (this: this, button: this, ...args: A) => any
        • (this: this, button: this, ...args: A): any
        • Parameters

          • this: this
          • button: this
          • Rest ...args: A

          Returns any

    • Rest ...args: A

    Returns this

  • Parameters

    • Optional cb: undefined | ((this: this, button: this) => any)
    • Rest ...args: any[]

    Returns this

  • Type parameters

    • A: any[]

    Parameters

    • ms: number
    • cb: (this: this, button: this, ...args: A) => any
        • (this: this, button: this, ...args: A): any
        • Parameters

          • this: this
          • button: this
          • Rest ...args: A

          Returns any

    • Rest ...args: A

    Returns this

  • Parameters

    • ms: number
    • Optional cb: undefined | ((this: this, button: this) => any)
    • Rest ...args: any[]

    Returns this

  • Type parameters

    • A: any[]

    Parameters

    • ms: number
    • debounce: number
    • cb: (this: this, button: this, ...args: A) => any
        • (this: this, button: this, ...args: A): any
        • Parameters

          • this: this
          • button: this
          • Rest ...args: A

          Returns any

    • Rest ...args: A

    Returns this

  • Parameters

    • ms: number
    • debounce: number
    • Optional cb: undefined | ((this: this, button: this) => any)
    • Rest ...args: any[]

    Returns this

scrollTo

  • scrollTo(child: Component, ms?: undefined | number): void
  • scrollTo(child: Component, offsetTop: number, ms?: undefined | number): void
  • Parameters

    • child: Component
    • Optional ms: undefined | number

    Returns void

  • Parameters

    • child: Component
    • offsetTop: number
    • Optional ms: undefined | number

    Returns void

set

  • Sets the given Stat's value to the given amount. Triggers statChange

    Parameters

    Returns boolean

setBonus

  • Change the bonus for a stat.

    Parameters

    Returns T

setChangeTimer

  • Sets how frequently the stat should change. Triggers statTimerChange

    Parameters

    • stat: Stat | IStat

      The Stat that should change.

    • timer: number

      How many turns should pass between changes.

    • Optional initializer: undefined | ((factory: StatChangeTimerFactory) => any)

    Returns T

setContents

  • setContents(html: string, escape?: boolean): this
  • Parameters

    • html: string
    • Default value escape: boolean = false

    Returns this

setContextMenu

  • setContextMenu(): this
  • setContextMenu(generator: (contextMenu: ContextMenu) => ContextMenu | undefined, priority?: undefined | number): this

setElement

  • setElement(element: E): this
  • setElement(elementType?: undefined | string, namespace?: Namespace): this
  • Warning: This method will replace the internal element backing this component.

    Only call this directly after constructing the element.

    Parameters

    • element: E

    Returns this

  • Warning: This method will replace the internal element backing this component.

    Only call this directly after constructing the element.

    Parameters

    • Optional elementType: undefined | string
    • Optional namespace: Namespace

    Returns this

setHighlight

setId

  • setId(id: string): this
  • Parameters

    • id: string

    Returns this

setInitialSelection

  • setInitialSelection(initialSelection?: boolean): this
  • Parameters

    • Default value initialSelection: boolean = true

    Returns this

setMax

  • setMax(stat: Stat | IStat, max: number, newValue?: undefined | number): T
  • Sets the given Stat's max to the given amount. Triggers statMaxChange

    Parameters

    • stat: Stat | IStat

      The Stat to set.

    • max: number

      The amount to set the value to.

    • Optional newValue: undefined | number

      The new value for the stat, optional. Calls Stat.set internally.

    Returns T

setPlayer

  • setPlayer(player: Player): this
  • Parameters

    Returns this

setSelectable

setStyle

  • setStyle(property: string, value: string | number): this
  • Parameters

    • property: string
    • value: string | number

    Returns this

setTooltip

  • setTooltip(initializer?: undefined | ((tooltip: ITooltip) => any), _showOnHover?: boolean): this
  • Parameters

    • Optional initializer: undefined | ((tooltip: ITooltip) => any)
    • Default value _showOnHover: boolean = true

    Returns this

show

  • show(): this
  • Returns this

siblings

  • siblings<C>(selector?: undefined | string): Stream<C>
  • Type parameters

    Parameters

    • Optional selector: undefined | string

    Returns Stream<C>

store

  • store(): this

toggle

  • toggle(visible?: boolean): this
  • Parameters

    • Default value visible: boolean = this.classes.hasAny("hidden")

    Returns this

updateTimers

  • updateTimers(): this
  • Passes the "turn" for stats, decrements their changeTimers. If a stat's timer reaches 0, the stat value is changed by changeAmount and the changeTimer is reset to nextChangeTimer

    Returns this

Static all

  • all(selector: string): Stream<Component<HTMLElement>>
  • Parameters

    • selector: string

    Returns Stream<Component<HTMLElement>>

Static append

  • Parameters

    Returns void

Static findDescendants

  • findDescendants(inElement: IComponent | HTMLElement, selector: string, includeSelf?: boolean): HTMLElement[]
  • Parameters

    • inElement: IComponent | HTMLElement
    • selector: string
    • Default value includeSelf: boolean = false

    Returns HTMLElement[]

Static get

  • get(selector: string): Component | undefined
  • Parameters

    • selector: string

    Returns Component | undefined

Static getSelectableLayer

  • getSelectableLayer(element: IComponent | HTMLElement): number | false

Static remove

  • Parameters

    Returns void

Generated using TypeDoc