View Source Teiserver.Game.MatchTypeLib (Teiserver v0.0.4)

Library of match_type related functions.

Summary

Functions

Returns an %Ecto.Changeset{} for tracking match_type changes.

Creates a match_type.

The default method used to define match types

Deletes a match_type.

Gets a single match_type by name or id (must be an integer).

Gets a match_type of a given name, if the match_type does not exist it is created.

Returns the list of match_types.

Updates a match_type.

Functions

Link to this function

calculate_match_type(lobby)

View Source
@spec calculate_match_type(Teiserver.Game.Lobby.t()) :: Teiserver.Game.MatchType.id()
Link to this function

change_match_type(match_type, attrs \\ %{})

View Source
@spec change_match_type(Teiserver.Game.MatchType.t(), map()) :: Ecto.Changeset.t()

Returns an %Ecto.Changeset{} for tracking match_type changes.

Examples

iex> change_match_type(match_type)
%Ecto.Changeset{data: %MatchType{}}
Link to this function

create_match_type(attrs \\ %{})

View Source
@spec create_match_type(map()) ::
  {:ok, Teiserver.Game.MatchType.t()} | {:error, Ecto.Changeset.t()}

Creates a match_type.

Examples

iex> create_match_type(%{field: value})
{:ok, %MatchType{}}

iex> create_match_type(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

default_calculate_match_type(lobby)

View Source
@spec default_calculate_match_type(Teiserver.Game.Lobby.t()) :: String.t()

The default method used to define match types

Can be over-ridden using the config fn_calculate_match_type

Link to this function

delete_match_type(match_type)

View Source
@spec delete_match_type(Teiserver.Game.MatchType.t()) ::
  {:ok, Teiserver.Game.MatchType.t()} | {:error, Ecto.Changeset.t()}

Deletes a match_type.

Examples

iex> delete_match_type(match_type)
{:ok, %MatchType{}}

iex> delete_match_type(match_type)
{:error, %Ecto.Changeset{}}
Link to this function

get_match_type(match_type_id, query_args \\ [])

View Source

Gets a single match_type.

Returns nil if the MatchType does not exist.

Examples

iex> get_match_type(123)
%MatchType{}

iex> get_match_type(456)
nil
Link to this function

get_match_type!(match_type_id, query_args \\ [])

View Source

Gets a single match_type.

Raises Ecto.NoResultsError if the MatchType does not exist.

Examples

iex> get_match_type!(123)
%MatchType{}

iex> get_match_type!(456)
** (Ecto.NoResultsError)
Link to this function

get_match_type_by_name_or_id(match_type_id)

View Source
@spec get_match_type_by_name_or_id(String.t() | Teiserver.Game.MatchType.id()) ::
  Teiserver.Game.MatchType.t() | nil

Gets a single match_type by name or id (must be an integer).

Returns nil if the MatchType does not exist.

Examples

iex> get_match_type_by_name_or_id("main")
%MatchType{}

iex> get_match_type_by_name_or_id(123)
%MatchType{}

iex> get_match_type_by_name_or_id("not a name")
nil

iex> get_match_type_by_name_or_id(456)
nil
Link to this function

get_or_create_match_type(match_type_name)

View Source
@spec get_or_create_match_type(String.t()) :: Teiserver.Game.MatchType.t()

Gets a match_type of a given name, if the match_type does not exist it is created.

Examples

iex> get_or_create_match_type("name")
%MatchType{}

iex> get_or_create_match_type("not a match_type"")
%MatchType{}
Link to this function

list_match_types(query_args \\ [])

View Source
@spec list_match_types(Teiserver.query_args()) :: [Teiserver.Game.MatchType.t()]

Returns the list of match_types.

Examples

iex> list_match_types()
[%MatchType{}, ...]
Link to this function

update_match_type(match_type, attrs)

View Source
@spec update_match_type(Teiserver.Game.MatchType.t(), map()) ::
  {:ok, Teiserver.Game.MatchType.t()} | {:error, Ecto.Changeset.t()}

Updates a match_type.

Examples

iex> update_match_type(match_type, %{field: new_value})
{:ok, %MatchType{}}

iex> update_match_type(match_type, %{field: bad_value})
{:error, %Ecto.Changeset{}}