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.
Gets a single 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
@spec calculate_match_type(Teiserver.Game.Lobby.t()) :: Teiserver.Game.MatchType.id()
@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{}}
@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{}}
@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
@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{}}
@spec get_match_type(Teiserver.Game.MatchType.id(), Teiserver.query_args()) :: Teiserver.Game.MatchType.t() | nil
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
@spec get_match_type!(Teiserver.Game.MatchType.id(), Teiserver.query_args()) :: Teiserver.Game.MatchType.t()
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)
@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
@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{}
@spec list_match_types(Teiserver.query_args()) :: [Teiserver.Game.MatchType.t()]
Returns the list of match_types.
Examples
iex> list_match_types()
[%MatchType{}, ...]
@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{}}