View Source Islands.Player (Islands Player v0.1.28)

Creates a player struct for the Game of Islands.

The player struct contains the fields name, gender, pid, board and guesses representing the characteristics of a player in the Game of Islands.

Based on the book Functional Web Development by Lance Halvorsen.

Link to this section Summary

Types

Player's gender

Player's name

t()

A player struct for the Game of Islands

Functions

Creates a player struct from name, gender and pid.

Link to this section Types

Specs

gender() :: :f | :m

Player's gender

Specs

name() :: String.t()

Player's name

Specs

t() :: %Islands.Player{
  board: Islands.Board.t(),
  gender: gender(),
  guesses: Islands.Guesses.t(),
  name: name(),
  pid: pid() | nil
}

A player struct for the Game of Islands

Link to this section Functions

Specs

new(name(), gender(), pid() | nil) :: t() | {:error, atom()}

Creates a player struct from name, gender and pid.

Examples

iex> alias Islands.{Board, Guesses, Player}
iex> Player.new("Joe", :m, nil)
%Player{
  name: "Joe",
  gender: :m,
  pid: nil,
  board: Board.new(),
  guesses: Guesses.new()
}