chess

Types

pub type GameState {
  GameState(
    players: Queue(Player),
    board: Grid(Space),
    stage: Stage,
    turn: Int,
    check: Map(Player, List(Coordinate)),
    mate: Option(Player),
    message: String,
  )
}

Constructors

  • GameState(
      players: Queue(Player),
      board: Grid(Space),
      stage: Stage,
      turn: Int,
      check: Map(Player, List(Coordinate)),
      mate: Option(Player),
      message: String,
    )
pub type MoveError {
  NoPath
  EmptySpace
}

Constructors

  • NoPath
  • EmptySpace
pub type Stage {
  Setup
  Playing
  End
}

Constructors

  • Setup
  • Playing
  • End

Functions

pub fn next(state: GameState, from from: Coordinate, to to: Coordinate) -> GameState
pub fn set(board: Grid(Space), x: Int, y: Int, player: Player, piece: Piece, transform: Transform) -> Result(
  Grid(Space),
  Error,
)
pub fn setup(p1: String, p2: String) -> GameState
pub fn start(state: GameState) -> GameState
Search Document