Skip to content
Permalink
main
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

LoRDeckCodes

The LorDeckCodes library can be used to encode/decode Legends of Runeterra decks to/from simple strings. Below is an example code for a Ionia/Piltover & Zaun deck.

CEAAECABAQJRWHBIFU2DOOYIAEBAMCIMCINCILJZAICACBANE4VCYBABAILR2HRL

These strings can be used to share decks across Legends of Runeterra clients. Just remember: you can't netdeck skill.

Cards & Decks

Every Legends of Runeterra card has a corresponding card code. Card codes are seven character strings comprised of two characters for card set, two characters for faction identifier, and three characters for card number.

01DE123
│ │ └ card number - 123
│ └ faction - DE
└ set - 01

The deck code library accepts a Legends of Runeterra deck as a list of CardCodeAndCount objects. This is simply the code and an associated integer for the number of occurences of the card in the deck.

Process

Decks are encoding via arranging VarInts (big endian) into an array and then base 32 encoding into a string.

All encodings begin with 4 bits for format and 4 bits for version.

Format Version Date Patch About
1 1 Oct 18, 2019 - Closed alpha. Supports original set.
1 2 April 28, 2020 1.0 Launch. Supports second set with the Bilgewater faction.
1 2 August 17th, 2020 1.8 Supports third set with the Targon faction.
1 3 March 3rd, 2021 2.3 Supports Empires of the Ascended expansion with Shurima faction.
1 4 August 25, 2021 2.14 Supports Beyond the Bandlewood expansion with Bandle City faction and an update to the deck code library which will create the lowest version code required based on the cards in the deck.

The list of cards are then encoded according to the following scheme:

  1. Cards are grouped together based on how many copies of the card are in the deck (e.g., cards with three copies are grouped together, cards with two copies are grouped together, and cards with a single copy are grouped together).
  2. Within those groups, lists of cards are created which share the same set AND faction.
  3. The set/faction lists are ordered by increasing length. The contents of the set/faction lists are ordered alphanumerically.
  4. Variable length integer (varints) (big endian) bytes for each ordered group of cards are written into the byte array according to the following convention:
    • [how many lists of set/faction combination have three copies of a card]
      • [how many cards within this set/faction combination follow]
      • [set]
      • [faction]
        • [card number]
        • [card number]
        • ...
      • [how many cards in this next set/faction combination follow]
      • [set]
      • [faction]
        • [card number]
        • [card number]
        • ...
    • [repeat for the groups of two copies of a card]
    • [repeat for the groups of a single copy of a card]
  5. The resulting byte array is base32 encoded into a string.

Faction Identifiers

Factions are mapped as follows:

Version Integer Identifier Faction Identifier Faction Name
1 0 DE Demacia
1 1 FR Freljord
1 2 IO Ionia
1 3 NX Noxus
1 4 PZ Piltover & Zaun
1 5 SI Shadow Isles
2 6 BW Bilgewater
2 9 MT Mount Targon
3 7 SH Shurima
4 10 BC Bandle City

Implementations

Members of the community have graciously created implementations of this library in various languages. The following is intended to assist in choosing the implementation that works best for you. If you're a developer and would like to include your implementation in this list, please create a pull request and add a row to the README.

Current Version

Name Language Version* Maintainer
R4J Java 8 4 stelar7
LoRDeckCodesPython Python 3 4 Rafalonso
runeterra JavaScript 3 SwitchbladeBot
RuneTerraPHP PHP 7.2 3 Mike-Reinders
lordeckcodes-rs Rust 3 iulianR
LoRDeckCodes Android 3 Pole
lor_deck_codes_dart Dart 3 edenizk
ForDeckmacia Scala 4 Billzabob
runeterra_cards Ruby 4 zofrex
runeterra_decks Nim 4 SolitudeSF
lor-deckcodes-ts TypeScript 4 jcuker
lordecks R 4 pholzmgit
goterra Golang 4 sousa-andre
lor-deckcodes Swift 4 tomaszbak

Leading up to the release of a new version of the library, we'll keep the original and new version in the Current Version section. A couple weeks after the release of a new version, any libraries that have not been updated to the latest version will be moved into the Previous Versions section. Any libraries in the Previous Version section that get updated to the latest version will get appended to the Current Version section.

Previous Versions

Name Language Version* Maintainer
LoRDeckCodes.jl Julia 3 wookay
twisted_fate Python 3 2** snowcola
lor_deckcodes_dart Dart 2 2** exts
lordeckoder Golang 2 MarekSalgovic
lor-deckcode TypeScript 2 icepeng
LoRDeck++ C++ 2 EvanKaraf
LorElixir Elixir 1 petter-kaspersen
CardGameFr-LoRDeckCode Ruby 1 Yohan-Frmt
LoRDeckCoder Java 8 1 Paul1365972

*Version refers to the MAX_KNOWN_VERSION supported by the implementation.
**Supports deck code version 2 with the Targon faction.

License

Apache 2 (see LICENSE for details)