# `Islands.Guesses`
[🔗](https://github.com/RaymondLoranger/islands_guesses/blob/main/lib/islands/guesses.ex#L4)

A guesses struct and functions for the _Game of Islands_.

The guesses struct contains the fields:

  - `hits`
  - `misses`

representing the guesses of an opponent in the _Game of Islands_.

##### Based on the book [Functional Web Development](https://pragprog.com/titles/lhelph/functional-web-development-with-elixir-otp-and-phoenix/) by Lance Halvorsen.

# `t`

```elixir
@type t() :: %Islands.Guesses{
  hits: Islands.Island.coords(),
  misses: Islands.Island.coords()
}
```

A guesses struct for the Game of Islands

# `type`

```elixir
@type type() :: :hit | :miss
```

Type of guess

# `add`

```elixir
@spec add(t(), type(), Islands.Coord.t()) :: t() | {:error, atom()}
```

Adds a hit `guess` to the `:hits` set or a miss `guess` to the `:misses` set.

# `hit_squares`

```elixir
@spec hit_squares(t()) :: %{squares: [Islands.Coord.square()]}
```

Returns a map assigning to `:squares` the list of square numbers
from `guesses`'s hits.

# `miss_squares`

```elixir
@spec miss_squares(t()) :: %{squares: [Islands.Coord.square()]}
```

Returns a map assigning to `:squares` the list of square numbers
from `guesses`'s misses.

# `new`

```elixir
@spec new() :: t()
```

Creates a new guesses struct.

## Examples

    iex> alias Islands.Guesses
    iex> Guesses.new()
    %Guesses{hits: MapSet.new(), misses: MapSet.new()}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
