Class TBoard

A game state. This is newly instantiated every time a player makes a move and the game state gets updated.

Hierarchy

  • TBoard

Constructors

Properties

design: TDesign
forks: TMoveContext[]
lastFrom: number
lastlyMadeMove: TMove
legalMoves: TMove[]
parent: TBoard
pieces: TPiece[]
player: number
turn: number

Methods

  • Clear the current board state.

    Returns void

  • Generate a list of the legal moves from the current game state

    Returns void

  • Return a piece on the given location.

    Returns

    a piece (null if no piece occupies the given location)

    Parameters

    • loc: number

      a location id

    Returns TPiece

  • Check if a chain of move contexts is completed as a legal move

    Parameters

    Returns boolean

  • Check if a location is the origin square (the location where the move starts)

    Parameters

    • loc: number

    Returns boolean

  • Make a move and creates a new game state.

    Returns

    next game state

    Parameters

    • move: TMove

    Returns TBoard

  • Set the origin square (the location where the move starts)

    Parameters

    • loc: number

    Returns void

  • Put a piece to a location on the board.

    Parameters

    • loc: number

      a piece location id

    • piece: TPiece

      a piece

    Returns void

Generated using TypeDoc