A Gleam package to encode & decode Hearthstone deckstrings.
Work-in-progress.
gleam add sunwellimport 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.
Runs on both the Erlang and JavaScript targets. Pure Gleam with no FFI, and gleam_stdlib as the only dependency.
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.