artifact_deck_code v0.1.0 ArtifactDeckCode View Source

Encoder and decoder for Artifact decks.

Current version is 2.

Link to this section Summary

Functions

Decode a deck code string into a map representing an Artifact deck

Encode an Artifact deck into a binary string

Link to this section Types

Link to this type deck() View Source
deck() :: %{
  optional(:name) => String.t(),
  :heroes => [{id :: pos_integer(), turn :: pos_integer()}],
  :cards => [{id :: pos_integer(), count :: pos_integer()}]
}
Link to this type deck_code() View Source
deck_code() :: binary()

Link to this section Functions

Link to this function decode(deck_code) View Source
decode(deck_code :: deck_code()) :: {:ok, deck()} | {:error, atom()}

Decode a deck code string into a map representing an Artifact deck.

Link to this function encode(deck, version \\ 2) View Source
encode(deck :: deck(), version :: pos_integer()) ::
  {:ok, deck_code()} | {:error, atom()}

Encode an Artifact deck into a binary string.

Version 2 supports encoding deck name.