GamesEngine.Validations.GridValidations (games_engine v0.2.2)

Functions with perform validations of a game grid

Summary

Functions

Ensures a linear index is within the bounds of the supplied grid

Ensures a row/col subscript is within the bounds of the supplied grid

Functions

Link to this function

ind_within_bounds(ind, grid)

@spec ind_within_bounds(non_neg_integer(), GamesEngine.Grid.t()) :: :ok

Ensures a linear index is within the bounds of the supplied grid

Link to this function

ind_within_bounds(ind, rows, cols)

@spec ind_within_bounds(non_neg_integer(), non_neg_integer(), non_neg_integer()) ::
  :ok
Link to this function

sub_within_bounds(arg, grid)

@spec sub_within_bounds(
  {non_neg_integer(), non_neg_integer()},
  GamesEngine.Grid.t()
) :: :ok | {:error, String.t()}

Ensures a row/col subscript is within the bounds of the supplied grid

Link to this function

sub_within_bounds(arg, rows, cols)

@spec sub_within_bounds(
  {non_neg_integer(), non_neg_integer()},
  non_neg_integer(),
  non_neg_integer()
) :: :ok | {:error, String.t()}