Sternhalma.Board (Sternhalma v0.1.1) View Source
Provides functions to manipulate the Chinese Checkers game board.
Link to this section Summary
Functions
Generate an empty board.
Return a cell from the game board based on pixel coordinates, x and y. Return nil if the cell does not exist.
Fill in a home triangle with marbles.
Return the list of unique marbles found on a game board.
Link to this section Types
Specs
home_triangle() :: :top_left | :top | :top_right | :bottom_left | :bottom | :bottom_right
Specs
t() :: [Sternhalma.Cell.t()]
Link to this section Functions
Specs
Specs
empty() :: t()
Generate an empty board.
Specs
get_board_cell(t(), {number(), number()}) :: {:ok | :error, Sternhalma.Cell.t() | nil}
Return a cell from the game board based on pixel coordinates, x and y. Return nil if the cell does not exist.
Examples
iex> get_board_cell(empty(), {17.794, 14.5})
{:ok, %Sternhalma.Cell{marble: nil, position: %Sternhalma.Hex{x: 3, y: -6, z: 3}}}
iex> get_board_cell(empty(), {172.794, -104.5})
{:error, nil}
Specs
position_opponent(0..5) :: {:ok, home_triangle()} | {:error, nil}
Specs
setup_triangle(t(), home_triangle(), String.t()) :: t()
Fill in a home triangle with marbles.
Return the list of unique marbles found on a game board.