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

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.

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.

Types

@type gender() :: :f | :m

Player's gender

@type name() :: String.t()

Player's name

@type 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

Functions

@spec 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()
}