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

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

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_yml, "tfc"),
    ROTF(Resources.files.rotf_yml, "rotf"),
    ITI(Resources.files.iti_yml, "iti"),
    URR(Resources.files.urr_yml, "urr"),
    SSK(Resources.files.ssk_yml, "ssk");

    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