Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sunwell

Package Version Hex Docs test

What is sunwell

A Gleam package to encode & decode Hearthstone deckstrings.

Status

Work-in-progress.

Installation

gleam add sunwell

Usage

import gleam/io
import sunwell
import sunwell/deck

pub fn main() {
  let assert Ok(definition) =
    sunwell.decode("AAECAR8GxwPJBLsFmQfZB/gIDI0B2AGoArUDhwSSBe0G6wfbCe0JgQr+DAAA")

  definition.format // deck.Standard
  definition.heroes // [31]
  definition.cards  // [deck.DeckCard(141, 2), deck.DeckCard(216, 2), ..]

  let assert Ok(deckstring) = sunwell.encode(definition)
  io.println(deckstring)
}

Both functions return a Result, so malformed input is reported rather than raised:

sunwell.decode("not a deckstring")
// -> Error(deck.InvalidDeckstring)

See sunwell/deck for DeckDefinition, Format, and the full DeckError type.

Targets

Runs on both the Erlang and JavaScript targets. Pure Gleam with no FFI, and gleam_stdlib as the only dependency.

Acknowledgements

This package is an adaptation in Gleam of hearthstone_deckstrings, a JavaScript/TypeScript library with the same goal as this package.

The documentation provided here was of great help in understanding the deckstring format. Thanks to the HearthSim team for providing it.

License

MIT

About

A Gleam package to encode & decode Hearthstone deckstrings.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages