Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/HearthSim/hearthstone-deckstrings
🔗 Decode and encode Hearthstone Deckstrings.
https://github.com/HearthSim/hearthstone-deckstrings
deckstrings hearthstone
Last synced: about 2 months ago
JSON representation
🔗 Decode and encode Hearthstone Deckstrings.
- Host: GitHub
- URL: https://github.com/HearthSim/hearthstone-deckstrings
- Owner: HearthSim
- License: isc
- Created: 2017-05-24T13:00:52.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T11:41:30.000Z (6 months ago)
- Last Synced: 2024-05-03T14:44:37.236Z (5 months ago)
- Topics: deckstrings, hearthstone
- Language: JavaScript
- Homepage: https://hearthsim.info/docs/deckstrings/
- Size: 125 KB
- Stars: 50
- Watchers: 10
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `deckstrings` for Hearthstone
[![npm](https://img.shields.io/npm/v/deckstrings.svg)](http://npmjs.com/package/deckstrings)Decode and encode Hearthstone [deckstrings](https://hearthsim.info/docs/deckstrings/).
A mapping between DBF ids and cards can be found at [HearthstoneJSON](https://hearthstonejson.com/).
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
```javascript
import { encode, decode, FormatType } from "deckstrings";const deck = {
cards: [[1, 2], [2, 2], [3, 2], [4, 1]], // [dbfId, count] pairs
sideboardCards: [[5, 1, 90749]], // [dbfId, count, sideboardOwnerDbfId] triplets
heroes: [7], // Garrosh Hellscream
format: FormatType.FT_WILD, // or FT_STANDARD or FT_CLASSIC
};const deckstring = encode(deck);
console.log(deckstring); // AAEBAQcBBAMBAgMAAQEF/cQFAAA=const decoded = decode(deckstring);
console.log(JSON.stringify(deck) === JSON.stringify(decoded)); // true
```