# `Islands.Board`
[🔗](https://github.com/RaymondLoranger/islands_board/blob/main/lib/islands/board.ex#L4)

A board struct and functions for the _Game of Islands_.

The board struct contains the fields:

  - `islands`
  - `misses`

representing the properties of a board 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.

# `islands`

```elixir
@type islands() :: %{required(Islands.Island.type()) =&gt; Islands.Island.t()}
```

A map assigning islands to their island types

# `t`

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

A board struct for the Game of Islands

# `all_islands_positioned?`

```elixir
@spec all_islands_positioned?(t()) :: boolean()
```

Checks if all islands have been positioned on `board`.

# `forested_types`

```elixir
@spec forested_types(t()) :: [Islands.Island.type()]
```

Returns a list of island types for forested islands.

# `grid_positions`

```elixir
@spec grid_positions(t()) :: %{
  required(Islands.Island.type()) =&gt; Islands.Island.grid_position()
}
```

Returns a map assigning the CSS grid position of each island
on `board` to its island type.

# `guess`

```elixir
@spec guess(t(), Islands.Coord.t()) :: Islands.Board.Response.t()
```

Checks if `guess` has hit any island on `board` and returns a response tuple.

# `hit_cells`

```elixir
@spec hit_cells(t()) :: %{
  required(Islands.Island.type()) =&gt; [Islands.Island.grid_cell()]
}
```

Returns a map assigning the list of hit "cells" of each island
on `board` to its island type.

# `hits`

```elixir
@spec hits(t()) :: non_neg_integer()
```

Returns `board`'s total number of hits.

# `miss_squares`

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

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

# `misses`

```elixir
@spec misses(t()) :: non_neg_integer()
```

Returns `board`'s total number of misses.

# `new`

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

Returns an empty board struct.

# `position_island`

```elixir
@spec position_island(t(), Islands.Island.t()) :: t() | {:error, atom()}
```

Positions `island` on `board` and returns an updated `board` or
`{:error, reason}` if `island` overlaps another island on `board`.

Error reason:

  - `:overlapping_island` - overlaps another island

---

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