GamesEngine.Grid.Tile (games_engine v0.3.2)

Tile Component Representation of a Game Tile on a Grid

Summary

Functions

Adds a new attributes to a %Tile{} Will not overwrite the attribute if it already exists

Creates a new %Tile{} struct row/col validation is relegated to the %Coordinate{} module

Replaces the entire attributes map of a %Tile{} with a new map

Updates an existing attribute of a %Tile{}

Types

@type t() :: %GamesEngine.Grid.Tile{attributes: term(), coordinate: term()}

Functions

Link to this function

add_attribute(tile, key, value)

@spec add_attribute(t(), atom(), any()) :: t()

Adds a new attributes to a %Tile{} Will not overwrite the attribute if it already exists

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

Creates a new %Tile{} struct row/col validation is relegated to the %Coordinate{} module

Link to this function

new(arg, attributes)

@spec new(
  {non_neg_integer(), non_neg_integer()},
  map()
) :: t() | {:error, String.t()}
Link to this function

replace_attributes(tile, attributes)

@spec replace_attributes(t(), map()) :: t() | {:error, String.t()}

Replaces the entire attributes map of a %Tile{} with a new map

Link to this function

update_attribute(tile, key, value)

@spec update_attribute(t(), atom(), any()) :: t()

Updates an existing attribute of a %Tile{}