View Source Islands.Board.Response (Islands Board v0.1.31)

A 4-element tuple reflecting the effect of a guess (hit or miss) on a board.

Summary

Types

Preliminary response to a guess

t()

Full response to a guess

Functions

Checks if guess hit any island on board.

Converts a preliminary response to a guess into a full response.

Types

@type guess_check() :: {:hit, Islands.Island.t()} | {:miss, Islands.Coord.t()}

Preliminary response to a guess

@type t() ::
  {:hit | :miss, Islands.Island.type() | :none, :no_win | :win,
   Islands.Board.t()}

Full response to a guess

Functions

Link to this function

check_guess(board, guess)

View Source
@spec check_guess(Islands.Board.t(), Islands.Coord.t()) :: guess_check()

Checks if guess hit any island on board.

Returns {:hit, hit_island}, where hit_island is the island hit by guess once updated, or {:miss, guess} if guess was a miss.

Link to this function

format_response(guess_check, board)

View Source
@spec format_response(guess_check(), Islands.Board.t()) :: t()

Converts a preliminary response to a guess into a full response.