osu!ex v0.2.0 OsuEx.Utils View Source

Utility functions.

Link to this section Summary

Functions

Translates bitwise mods into a list of atoms and vice versa. This function does not handle the KeyMod, FreeModAllowed, or ScoreIncreaseMods

Link to this section Functions

Link to this function

mods(n) View Source
mods(0..2_147_483_647) :: {:ok, MapSet.t()}
mods(Enum.t()) :: {:ok, 0..2_147_483_647} | {:error, {:unknown_mod, atom()}}

Translates bitwise mods into a list of atoms and vice versa. This function does not handle the KeyMod, FreeModAllowed, or ScoreIncreaseMods.

Examples

iex> OsuEx.API.Utils.mods(24) |> elem(1) |> MapSet.to_list()
[:HD, :HR]

iex> OsuEx.API.Utils.mods([:DT, :FL])
{:ok, 1088}

iex> OsuEx.API.Utils.mods([:QQ])
{:error, {:unknown_mod, :QQ}}