Sternhalma.Cell (Sternhalma v0.1.1) View Source

Link to this section Summary

Types

t()

Represents a single spot on the board.

Functions

Puts a marble in the given cell.

Set which marble is the target in a given cell. The target is used to determine if marbles are located in their winning positions.

Link to this section Types

Specs

marble() :: nil | String.t()

Specs

t() :: %Sternhalma.Cell{
  marble: marble(),
  position: Sternhalma.Hex.t(),
  target: marble()
}

Represents a single spot on the board.

Link to this section Functions

Link to this function

set_marble(cell, marble)

View Source

Specs

set_marble(t(), marble()) :: t()

Puts a marble in the given cell.

Examples

iex> set_marble(%Sternhalma.Cell{position: Sternhalma.Hex.new({0,0,0})}, "a")
%Sternhalma.Cell{marble: "a", position: %Sternhalma.Hex{x: 0, y: 0, z: 0}}
Link to this function

set_target(cell, marble)

View Source

Specs

set_target(t(), marble()) :: t()

Set which marble is the target in a given cell. The target is used to determine if marbles are located in their winning positions.

Examples

iex> set_target(%Sternhalma.Cell{position: Sternhalma.Hex.new({0,0,0})}, "a")
%Sternhalma.Cell{target: "a", position: %Sternhalma.Hex{x: 0, y: 0, z: 0}}

iex> set_target(%Sternhalma.Cell{marble: "b", position: Sternhalma.Hex.new({0,0,0})}, "a")
%Sternhalma.Cell{target: "a", marble: "b", position: %Sternhalma.Hex{x: 0, y: 0, z: 0}}