Skip to content

Zero-to-Heroes/hearthstone-deckstrings

 
 

Repository files navigation

deckstrings for Hearthstone

Travis npm

Decode and encode Hearthstone deckstrings.

A mapping between DBF ids and cards can be found at HearthstoneJSON.

Any deckstring or deck definition returned by this library will be "canonical": The cards and heroes are sorted by DBF id in ascending order.

Install

Install the package from npm using your favourite package manager:

$ yarn add deckstrings

Usage

import { encode, decode, FormatType } from "deckstrings";

const deck = {
	cards: [
		[1, 2],
		[2, 2],
		[3, 2],
		[4, 1],
	], // [dbfId, count] pairs
	heroes: [7], // Garrosh Hellscream
	format: FormatType.FT_WILD, // or FT_STANDARD or FT_CLASSIC
};

const deckstring = encode(deck);
console.log(deckstring); // AAEBAQcBBAMBAgMA

const decoded = decode(deckstring);
console.log(JSON.stringify(deck) === JSON.stringify(decoded)); // true

About

🔗 Decode and encode Hearthstone Deckstrings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 54.6%
  • TypeScript 45.4%