Class Game<TPlayer>Abstract

Base class for a custom game, using a custom Player type.

Type Parameters

Hierarchy

  • Game

Implements

Constructors

  • Base constructor for . You need to pass in your player type here so that BGE knows how to make instances of it.

    Type Parameters

    Parameters

    • PlayerType: (new (index, config) => TPlayer)

      Constructor for your custom player type.

        • new (index, config): TPlayer
        • Parameters

          Returns TPlayer

    Returns Game<TPlayer>

Properties

Dynamically add or remove objects to be displayed here.

revealEverythingToSpectators: boolean = false

If true, hidden objects like player hands are revealed to spectators.

Accessors

  • get players(): readonly TPlayer[]
  • Array of all the players in this running game. Only valid when onInitialize has been called.

    Returns readonly TPlayer[]

  • get replayData(): IReplayData
  • Information describing inputs fed to the game so far. Can be passed to run to resume a suspended game, or recreate the final state of a completed game.

    Returns IReplayData

Methods

  • Cancel all player input prompts and delays with the given reason.

    Parameters

    • Optional reason: any

      A message or error describing why the promises were cancelled.

    Returns void

  • Returns the player following the given one in clockwise turn order.

    Parameters

    • player: TPlayer

      Previous player in clockwise turn order.

    Returns TPlayer

    Next player in clockwise turn order.

  • Called after the game and player list have been configured.

    Returns void

  • Returns void

  • Override this to implement your game, moving objects around as players respond to prompts.

    Returns Promise<IGameResult>

  • Called by the host when a player has responded to a prompt for input.

    Parameters

    • playerIndex: number

      Which player responded.

    • promptIndex: number

      Which prompt did they respond to.

    • Optional payload: any

    Returns void

  • Called exactly once by a host to run a game.

    Parameters

    • config: IRunConfig

      Configuration containing info like player count and names

    Returns Promise<IGameResult>

Generated using TypeDoc