RiotGames / LoRDeckCodes

Other
158 stars 46 forks source link

Deck codes doesn't include deck name (Quality of Life) #17

Open sampaiodias opened 4 years ago

sampaiodias commented 4 years ago

It would be very useful to have the deck name inside the deck code, as after importing the deck we have to select the deck, click edit, and manually type the name (which in many cases is a net deck with a proper name already).

One solution I can see for it is to split the string into 2+ parts, where the last one is the deck code itself.

Example: LoR=Discard Aggro=CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ

Another solution is to transform it into a Json file, which certainly helps with future additions of fields while also removing the need to provide the name (or other fields) every time.

{
    "name":"Discard Aggro",
    "code":"CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ"
}

// Also valid, as the json deserializer will set the name field to null

{
    "code":"CEBAGAIDCQRSOCQBAQAQYDISDQTCOKBNGQAACAIBAMFQ"
}
Rafalonso commented 4 years ago

I like the idea, in other card games, you end up having a lot of unnamed decks that you dont remember what their purpose is but are afraid to delete 😛 . Just feels like strings would get too long. Also I'm not a fan of mixing bytes/unicode with base32.

JSON is interesting. It's probably not a good idea because of mobile players which I guess they plan on releasing in the future.

sampaiodias commented 4 years ago

Why would JSON be a problem for mobile? It is a format that is universally used by developers, including on mobile.

The example I gave also doesn't increase the string length by a lot (only a few extra chars). Hearthstone has a much bigger deck code string (with the deck name and description) and I never found someone who pointed that as a problem.

Rafalonso commented 4 years ago

Developers have no problem with it but remember that these code strings will be used by players (Unless I'm interpreting the intent of the JSON wrong).

I guess there's no harm with it being part of the deck string as long as it's also b32 encoded.

sampaiodias commented 4 years ago

As far as I understand, players will always use deck codes with Ctrl C Ctrl V (even the deck code itself is not human readable). The intent of json here is to provide useful data along the deck code to improve the deck sharing ecosystem and the import-export usability.

An example:

using Newtonsoft.Json;

public class DeckCodeObject
{
    public string name;
    public string code;
}

public class MyDeckCodeImporter
{
    public void ImportDeckFromJson(string json)
    {
        DeckCodeObject deckObject = JsonConvert.DeserializeObject<DeckCodeObject>(json);
        CardCodeAndCount decoded = LoRDeckEncoder.GetDeckFromCode(deckObject.code);

        // Do something with 'deckObject.name' and 'decoded'
    }
}
sampaiodias commented 4 years ago

Also, not changing the current encoding doesn't break the current system (LoRDeckEncoder). If we had to convert to Base32 every additional data (like the deck name) to the final string, maintaining the system would be really hard, as any field changes or additions will break LoRDeckEncoder.GetDeckFromCode and LoRDeckEncoder.GetCodeFromDeck.