Options
All
  • Public
  • Public/Protected
  • All
Menu

状态化的游戏客户端。

Type parameters

Hierarchy

Index

Constructors

constructor

Properties

Protected client

client: Client

当前玩家的 Client

Protected events

events: EventHandlers<State, Event, EP>

客户端的事件处理方法

Protected store

store: Store<State, ReplaceAction<State>>

维护游戏状态的 Store

Static prefixed

prefixed: string | boolean

Accessors

players

  • get players(): Player[]

state

  • get state(): State
  • set state(nextState: State): void

Methods

addListener

  • addListener<T>(event: T, fn: EventEmitter.EventListener<string | symbol, T>, context?: Context): this
  • Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T
    • fn: EventEmitter.EventListener<string | symbol, T>
    • Optional context: Context

    Returns this

emit

  • emit<T>(event: T, ...args: EventEmitter.EventArgs<string | symbol, T>): boolean
  • Calls each of the listeners registered for a given event.

    Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T
    • Rest ...args: EventEmitter.EventArgs<string | symbol, T>

    Returns boolean

emitEvent

  • emitEvent<N>(name: N, payload?: EP[N]): void
  • 派发游戏事件,在客户端派发的事件会同时在客户端与服务端被处理

    Type parameters

    • N: Event

    Parameters

    • name: N

      事件名

    • Optional payload: EP[N]

      事件的有效载荷

    Returns void

eventNames

  • eventNames(): Array<EventEmitter.EventNames<string | symbol>>
  • Return an array listing the events for which the emitter has registered listeners.

    Returns Array<EventEmitter.EventNames<string | symbol>>

listenerCount

  • listenerCount(event: EventEmitter.EventNames<string | symbol>): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: EventEmitter.EventNames<string | symbol>

    Returns number

listeners

  • listeners<T>(event: T): Array<EventEmitter.EventListener<string | symbol, T>>
  • Return the listeners registered for a given event.

    Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T

    Returns Array<EventEmitter.EventListener<string | symbol, T>>

off

  • off<T>(event: T, fn?: EventEmitter.EventListener<string | symbol, T>, context?: Context, once?: undefined | false | true): this
  • Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T
    • Optional fn: EventEmitter.EventListener<string | symbol, T>
    • Optional context: Context
    • Optional once: undefined | false | true

    Returns this

on

  • on<T>(event: T, fn: EventEmitter.EventListener<string | symbol, T>, context?: Context): this
  • Add a listener for a given event.

    Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T
    • fn: EventEmitter.EventListener<string | symbol, T>
    • Optional context: Context

    Returns this

Protected onUpdate

  • onUpdate(nextState: State): State
  • Parameters

    • nextState: State

    Returns State

once

  • once<T>(event: T, fn: EventEmitter.EventListener<string | symbol, T>, context?: Context): this
  • Add a one-time listener for a given event.

    Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T
    • fn: EventEmitter.EventListener<string | symbol, T>
    • Optional context: Context

    Returns this

removeAllListeners

  • removeAllListeners(event?: EventEmitter.EventNames<string | symbol>): this
  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: EventEmitter.EventNames<string | symbol>

    Returns this

removeListener

  • removeListener<T>(event: T, fn?: EventEmitter.EventListener<string | symbol, T>, context?: Context, once?: undefined | false | true): this
  • Remove the listeners of a given event.

    Type parameters

    • T: EventEmitter.EventNames<string | symbol>

    Parameters

    • event: T
    • Optional fn: EventEmitter.EventListener<string | symbol, T>
    • Optional context: Context
    • Optional once: undefined | false | true

    Returns this

Legend

  • Object literal
  • Variable
  • Function with type parameter
  • Type alias with type parameter
  • Class with type parameter
  • Constructor
  • Accessor
  • Interface
  • Interface with type parameter
  • Protected property
  • Protected method
  • Enumeration
  • Inherited method

Generated using TypeDoc