Skip to content

MarekSalgovic/hsdeckoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hearthstone Deckcode Decoder - hsdeckoder

Golang package to decode hearthstone deckstring to useful data inspired by hearthsim.

Installation

go get github.com/MarekSalgovic/hsdeckoder

Usage

Decodes deckcode string to deck struct. For more details see format.

func main(){
	deckstring := "AAECAaIHBrICyAOvBOEE5/oC/KMDDLQBywPNA9QF7gaIB90I7/ECj5cDiZsD/6UD9acDAA=="
	deck, err := hsdeckoder.Decode(deckstring)
	//handle error
	if err != nil{
	  log.Fatalln(err)
	}
	fmt.Println(deck)
	//{2 [930] [{306 1} {456 1} {559 1} {609 1} {48487 1} {53756 1} {180 2} {459 2} {461 2} 
	//{724 2} {878 2} {904 2} {1117 2} {47343 2} {52111 2} {52617 2} {54015 2} {54261 2}]}
}

Available deck struct contains 3 fields:

type Deck struct {
	Format	Format //constant defining format - standart/wild
	Heroes	[]int //array of hero portrait dbfIds used in deckcode
	Cards 	[]Card // array of cards
}

type Card struct {
	Id int // dbfId of card
	Count int // occurrance count of card
}

hsvalidator

Package using hearthstonejson API to validate created deck struct.

validator, err := validator.NewValidator()
//handle error
if err != nil{
  panic(err)
}
validatedDeck, err := validator.ValidateDeck(deck)
//handle error
if err != nil{
  panic(err)
}

Initializing validator downloads cards to runtime memory from hearthstonejson API.

About

Golang package to decode hearthstone deckstring

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages