Hearthstone Deckstrings
Ruby library for encoding and decoding Hearthstone deckstrings. See documentation for help.
Usage
gem install deckstrings
require 'deckstrings'
Hearthstone deckstrings encode a Hearthstone deck in a compact format.
The IDs used in deckstrings and in this library refer to Hearthstone DBF IDs which uniquely define Hearthstone entities like cards and heroes.
For additional entity metadata (e.g. hero class, card cost, card name), the DBF IDs can be used in conjunction with the HearthstoneJSON database.
Decoding
Deckstrings::decode
decodes a deckstring with basic validation.
deckstring = 'AAECAZICCPIF+Az5DK6rAuC7ApS9AsnHApnTAgtAX/4BxAbkCLS7Asu8As+8At2+AqDNAofOAgA='
puts Deckstrings::decode(deckstring)
{:format=>2, :heroes=>[274], :cards=>{754=>1, 1656=>1, 1657=>1, 38318=>1, 40416=>1, 40596=>1, 41929=>1, 43417=>1, 64=>2, 95=>2, 254=>2, 836=>2, 1124=>2, 40372=>2, 40523=>2, 40527=>2, 40797=>2, 42656=>2, 42759=>2}}
Deckstrings::Deck.decode
decodes a deckstring with extended validation and additional deck information including card names and costs.
deckstring = 'AAECAZICCPIF+Az5DK6rAuC7ApS9AsnHApnTAgtAX/4BxAbkCLS7Asu8As+8At2+AqDNAofOAgA='
puts Deckstrings::Deck.decode(deckstring)
Format: Standard
Class: Druid
Hero: Malfurion Stormrage
2× Innervate
2× Jade Idol
2× Wild Growth
2× Wrath
2× Jade Blossom
2× Swipe
2× Jade Spirit
1× Fandral Staghelm
1× Spellbreaker
2× Nourish
1× Big Game Hunter
2× Spreading Plague
1× The Black Knight
1× Aya Blackpaw
2× Jade Behemoth
1× Malfurion the Pestilent
1× Primordial Drake
2× Ultimate Infestation
1× Kun the Forgotten King
Encoding
Deckstrings::encode
encodes deck information in a deckstring with basic validation.
puts Deckstrings::encode(
format: Deckstrings::Format.standard,
heroes: [Deckstrings::Hero.malfurion],
cards: {
254 => 2,
40372 => 2,
1124 => 2,
836 => 2,
40523 => 2,
64 => 2,
40527 => 2,
38318 => 1,
754 => 1,
95 => 2,
1657 => 1,
42656 => 2,
1656 => 1,
40596 => 1,
40797 => 2,
43417 => 1,
41929 => 1,
42759 => 2,
40416 => 1
}
)
AAECAZICCPIF+Az5DK6rAuC7ApS9AsnHApnTAgtAX/4BxAbkCLS7Asu8As+8At2+AqDNAofOAgA=
Deckstrings::Deck.encode
encodes deck information in a deckstring with extended validation.
puts Deckstrings::Deck.encode(
format: 2,
heroes: [274],
cards: {
254 => 2,
40372 => 2,
1124 => 2,
836 => 2,
40523 => 2,
64 => 2,
40527 => 2,
38318 => 1,
754 => 1,
95 => 2,
1657 => 1,
42656 => 2,
1656 => 1,
40596 => 1,
40797 => 2,
43417 => 1,
41929 => 1,
42759 => 2,
40416 => 1
}
)
AAECAZICCPIF+Az5DK6rAuC7ApS9AsnHApnTAgtAX/4BxAbkCLS7Asu8As+8At2+AqDNAofOAgA=
License
Copyright © 2017 Chris Schmich
MIT License. See LICENSE for details.