Islands.Score (Islands Score v0.1.49)

View Source

A score struct and functions for the Game of Islands.

The score struct contains the fields:

  • name
  • gender
  • hits
  • misses
  • forested_types

representing the properties of a score in the Game of Islands.

Inspired by the book Functional Web Development by Lance Halvorsen.

Summary

Types

t()

A score struct for the Game of Islands

Functions

Creates a score struct from a player's board struct.

Prints score formatted with embedded ANSI escapes.

Creates a score struct from an opponent's board struct.

Types

t()

@type t() :: %Islands.Score{
  forested_types: [Islands.Island.type()],
  gender: Islands.Player.gender(),
  hits: non_neg_integer(),
  misses: non_neg_integer(),
  name: Islands.Player.name()
}

A score struct for the Game of Islands

Functions

board_score(game, player_id)

@spec board_score(Islands.Game.t(), Islands.PlayerID.t()) :: t()

Creates a score struct from a player's board struct.

format(score, options)

@spec format(
  t(),
  keyword()
) :: :ok

Prints score formatted with embedded ANSI escapes.

guesses_score(game, player_id)

@spec guesses_score(Islands.Game.t(), Islands.PlayerID.t()) :: t()

Creates a score struct from an opponent's board struct.