/LoRDeckCoder

☯ Java 8 library to decode/encode Legends of Runeterra deck codes

Primary LanguageJava

☯ LoRDeckCoder

Build

Java 8 library port of RiotGames/LoRDeckCodes to decode/encode Legends of Runeterra deck codes. The project uses no external libraries and is highly configurable. Created following the guidelines from RiotGames/LoRDeckCodes.

Download

Download the latest release from Gradle:

repositories { 
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation 'com.github.paul1365972:lordeckcoder:v1.0'
}

or Maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.paul1365972</groupId>
    <artifactId>lordeckcoder</artifactId>
    <version>v1.0</version>
</dependency>

Examples

Simple decoding and encoding:

LoRDeck deck = LoRDeckCoder.toDeck("CEBAIAIFB4WDANQIAEAQGDAUDAQSIJZUAIAQCBIFAEAQCBAA");

String code = LoRDeckCoder.toCode(deck, FormatVersion.LIVE);

Parsing and fetching card codes:

LoRCard card = LoRCard.fromCardCode("01PZ019");	
	
String cardCode = card.getCardCode();
LoRFaction faction = card.getFaction();

Deck manipulation and analysis:

deck.addCards(LoRCard.fromCardCode("01PZ019"), 2);

int freljordCards = deck.getCards().entrySet().stream()
        .filter(e -> e.getKey().getFaction() == LoRFaction.FRELJORD)
        .mapToInt(Map.Entry::getValue)
        .sum();

Custom decoder if you prefer your own implementation:

LoRDeck customDeck = LoRCoder.decode(code, LoRDecoder.from(
        LoRDeck::new,
        (deck, set, factionId, cardNumber, amount) ->
            deck.addCards(new LoRCard(set, factionId, cardNumber), amount)
));

Implementation Details

  • All operations on the default implementation objects (LoRDeck, LoRCard) are safe. This means a deck or card cannot be in an invalid state and is thus always encodable