Coder Social home page Coder Social logo

schmich / deckstrings Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 13 KB

(Archived, see below) Go library for encoding and decoding Hearthstone deckstrings

Home Page: https://godoc.org/github.com/schmich/deckstrings

License: MIT License

Makefile 0.80% Go 99.20%
hearthstone deckstrings cards blizzard hs wow world-of-warcraft deck-codes decklist ccg

deckstrings's Introduction

Archival Notice

Due directly to the decisions and actions of Blizzard Entertainment, Inc., I will no longer be maintaining this project. The community is free to fork and continue it, but I do not wish to be involved.

Hearthstone Deckstrings

Go library for encoding and decoding Hearthstone deckstrings. See documentation for help.

Usage

go get github.com/schmich/deckstrings
import "github.com/schmich/deckstrings"

A Hearthstone deckstring encodes a Hearthstone deck in a compact string format. The IDs used in deckstrings and in this library are Hearthstone DBF IDs which are unique identifiers for Hearthstone entities like cards and heroes.

For additional entity metadata (e.g. hero class, card cost, card name), DBF IDs can be used in conjunction with the official Hearthstone API or HearthstoneJSON database.

See the deckstrings.Deck type for details on how a Hearthstone deck is represented.

Decoding

deckstrings.Decode decodes a deckstring into a Hearthstone deck.

deckstring := "AAECAZICCPIF+Az5DK6rAuC7ApS9AsnHApnTAgtAX/4BxAbkCLS7Asu8As+8At2+AqDNAofOAgA="
deck, err := deckstrings.Decode(deckstring)
fmt.Printf("%+v %v", deck, err)
{Format:2 Heroes:[274] Cards:[[64 2] [95 2] [254 2] [754 1] [836 2] [1124 2] [1656 1] [1657 1] [38318 1] [40372 2] [40416 1] [40523 2] [40527 2] [40596 1] [40797 2] [41929 1] [42656 2] [42759 2] [43417 1]]} <nil>

Encoding

deckstrings.Encode encodes a Hearthstone deck into a deckstring using base64.StdEncoding.

cards := [][2]uint64{
    {9, 1}, {279, 1}, {436, 1}, {545, 2}, {613, 1},
    {1363, 1}, {1367, 1}, {41169, 2}, {41176, 2},
    {42046, 1}, {42597, 2}, {42598, 1}, {42804, 2},
    {42818, 1}, {42992, 2}, {43112, 2}, {46307, 2},
    {46495, 2}, {48002, 1}, {49184, 1}, {49421, 1},
}
deck := Deck{
    Format: deckstrings.FormatStandard, // Standard
    Heroes: []uint64{41887},            // Tyrande Whisperwind
    Cards:  cards,                      // Cards in deck as (DBF ID, count) pairs
}
deckstring, err := deckstrings.Encode(deck)
fmt.Println(deckstring, err)
AAECAZ/HAgwJlwK0A+UE0wrXCr7IAubMAsLOAoL3AqCAA42CAwmhBNHBAtjBAuXMArTOAvDPAujQAuPpAp/rAgA= <nil>

License

Copyright © 2018 Chris Schmich
MIT License. See LICENSE for details.

deckstrings's People

Contributors

schmich avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.