Skip to content

Legends of Runeterra deck code encoder/decoder in JavaScript

License

Notifications You must be signed in to change notification settings

SwitchbladeBot/runeterra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runeterra

JavaScript port of the RiotGames/LoRDeckCodes library, made for encoding and decoding Legends of Runeterra card decks. Below is an example code for the Warmother Control deck by prohibit_hb on Mobalytics.

CEBAIAIFAEHSQNQIAEAQGDAUDAQSOKJUAIAQCBI5AEAQCFYA

Install

npm install runeterra

Cards, decks and how to encode them

If you want to understand the process of the encoding and decoding decks, please refer to the original library, as Riot has done a great job explaining it there.

Usage

const { DeckEncoder } = require('runeterra')

const deck = DeckEncoder.decode('CEAAECABAQJRWHBIFU2DOOYIAEBAMCIMCINCILJZAICACBANE4VCYBABAILR2HRL')
/*
[ Card { code: '01PZ019', count: 2 },
  Card { code: '01PZ027', count: 2 },
  Card { code: '01PZ028', count: 2 },
  Card { code: '01PZ040', count: 2 },
  Card { code: '01PZ045', count: 2 },
  Card { code: '01PZ052', count: 2 },
  Card { code: '01PZ055', count: 2 },
  Card { code: '01PZ059', count: 2 },
  Card { code: '01IO006', count: 2 },
  Card { code: '01IO009', count: 2 },
  Card { code: '01IO012', count: 2 },
  Card { code: '01IO018', count: 2 },
  Card { code: '01IO026', count: 2 },
  Card { code: '01IO036', count: 2 },
  Card { code: '01IO045', count: 2 },
  Card { code: '01IO057', count: 2 },
  Card { code: '01PZ013', count: 1 },
  Card { code: '01PZ039', count: 1 },
  Card { code: '01PZ042', count: 1 },
  Card { code: '01PZ044', count: 1 },
  Card { code: '01IO023', count: 1 },
  Card { code: '01IO029', count: 1 },
  Card { code: '01IO030', count: 1 },
  Card { code: '01IO043', count: 1 } ]
*/

// Card
deck[0].code    // "01PZ019"
deck[0].count   // 2
deck[0].set     // 1
deck[0].id      // 19
deck[0].faction // Faction { id: 4, shortCode: "PZ" }

const code = DeckEncoder.encode(deck)
// CEAAECABAQJRWHBIFU2DOOYIAEBAMCIMCINCILJZAICACBANE4VCYBABAILR2HRL