All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.eu.codlab.lorcana.raw.RawSet.kt Maven / Gradle / Ivy

There is a newer version: 0.13.0
Show newest version
package eu.codlab.lorcana.raw

import dev.icerock.moko.resources.FileResource
import eu.codlab.lorcana.resources.Resources
import eu.codlab.lorcana.utils.LorcanaConfiguration.github
import eu.codlab.tcgmapper.AbstractLoader
import eu.codlab.tcgmapper.Provider
import kotlinx.serialization.StringFormat
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer

enum class RawSet(
    fileResource: FileResource,
    fileName: String
) {
    TFC(Resources.files.tfc, "tfc"),
    ROTF(Resources.files.rotf, "rotf"),
    ITI(Resources.files.iti, "iti");

    private val loader = AbstractLoader(
        fileResource,
        fileName,
        ListSerializer(
            RawVirtualCard.serializer(
                String.serializer(),
                String.serializer(),
                String.serializer()
            )
        ),
        github
    )

    suspend fun loadFromGithub(tag: String = "main"): List =
        loader.loadFromGithub(tag)

    suspend fun loadFromResource(): List =
        loader.loadFromResource()

    fun to(values: List, encoder: StringFormat = Provider.json): String {
        return loader.to(values, encoder)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy