Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

deckstrings

2.1.0 • Public • Published

deckstrings for Hearthstone

Travis npm

Decode and encode Hearthstone deckstrings.

Any deckstring or deck definition returned by this library will be canonical. This means that the cards and heroes are sorted in ascending order by dbf id.

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

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 1 for Wild, 2 for Standard
};
 
const deckstring = encode(deck);
console.log(deckstring); // AAEBAQcBBAMBAgMA
 
const decoded = decode(deckstring);
console.log(JSON.stringify(deck) === JSON.stringify(decoded)); // true

Install

npm i deckstrings

DownloadsWeekly Downloads

428

Version

2.1.0

License

ISC

Unpacked Size

41.6 kB

Total Files

10

Last publish

Collaborators

  • avatar
  • avatar
  • avatar