MarsExplorer.HighlandGrid (SWAP - Mars Explorer v0.1.0) View Source

Module responsible for managing a highland grid

Link to this section Summary

Functions

Generates the highland grid

Determines if a position would be within the highland grid's limits

Link to this section Types

Specs

t() :: %MarsExplorer.HighlandGrid{east_limit: integer(), north_limit: integer()}

Link to this section Functions

Specs

build(%{north: integer(), east: integer()}) :: t()

Generates the highland grid

Examples

iex> alias MarsExplorer.HighlandGrid
MarsExplorer.HighlandGrid
iex> HighlandGrid.build(%{north: 5, east: 5})
%HighlandGrid{north_limit: 5, east_limit: 5}
Link to this function

valid_position?(highland_grid, map)

View Source

Specs

valid_position?(t(), %{north: integer(), east: integer()}) :: boolean()

Determines if a position would be within the highland grid's limits

Examples

iex> alias MarsExplorer.HighlandGrid
MarsExplorer.HighlandGrid
iex> grid = %HighlandGrid{north_limit: 5, east_limit: 5}
%HighlandGrid{north_limit: 5, east_limit: 5}
iex> grid |> HighlandGrid.valid_position?(%{north: 0, east: 0})
true
iex> grid |> HighlandGrid.valid_position?(%{north: 5, east: 5})
true
iex> grid |> HighlandGrid.valid_position?(%{north: 0, east: 6})
false
iex> grid |> HighlandGrid.valid_position?(%{north: 6, east: 0})
false