knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The package can be used to encode/decode Legends of Runeterra decks to/from simple strings. Such codes are e.g. generated by the game for imports and exports and also how decks are specified in the game API. Any analysis of matchdata therefore requires the ability to parse deck codes into actual deck lists.
This is an R implementation following https://github.com/RiotGames/LoRDeckCodes .
You can install lordecks from github via:
remotes::install_github("https://github.com/pholzmgit/lordecks")
The library provides a function that parses deck codes into interpretable deck lists. For the output format, 2 options are available
library(lordecks) deck_code <- "CEDACAIFDUAQEBAIAECAIBICAECDGNACAMCQIBQDAMCAKDISAIAQCBBWAIAQKEZPAIAQGBIMAMAQKAIZEE" simple_decklist <- get_decklist_from_code(deck_code, format = "simple") simple_decklist
df_decklist <- get_decklist_from_code(deck_code) df_decklist
For both deck formats, functions for the reverse action are provided
get_code_from_decklist(simple_decklist)
# a dataframe with only 'cardcode' and 'count' columns is sufficient, all other columns are ignored get_code_from_decklist_df(df_decklist)
The deck codes start with 4 bit for format and 4 bit for version. So far this only indicates which regions are available - too old versions of the decoder have no information on factions released more recently. Like the game client, this library encodes the minimal supported version based on the factions in the deck.
The C# library previously always generated codes with the latest version, but the most recent version (4+) behaves the same way. While older versions produced slightly different deck codes, the resulting decklists were identical.
#example code list provided from the test data set code <- "CMAQSAIFBMHREHRAFEVCWMABAYAQKAIUDURSYLIBAEAQKGQ" #manually import and re-export in the game (Patch 2.10) code_game <- "CEAQSAIFBMHREHRAFEVCWMABAYAQKAIUDURSYLIBAEAQKGQ" code_lordecks <- get_code_from_decklist_df(get_decklist_from_code(code)) code_lordecks
identical(code, code_lordecks) identical(code_game, code_lordecks)
identical( get_decklist_from_code(code), get_decklist_from_code(code_lordecks) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.