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

commonMain.eu.codlab.lorcana.CompiledSet.kt Maven / Gradle / Ivy

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

import eu.codlab.lorcana.raw.SetDescription
import eu.codlab.lorcana.raw.VirtualCard
import eu.codlab.tcgmapper.Provider
import korlibs.datastructure.iterators.parallelMap
import kotlinx.serialization.StringFormat
import kotlinx.serialization.builtins.ListSerializer

class CompiledSet(
    private val cards: List,
    private val set: SetDescription
) {

    fun cards(): List {
        return cards.parallelMap { it.toCard(set) }.filterNotNull().flatten()
    }

    fun to(values: List, encoder: StringFormat = Provider.yaml): String {
        val serializer = Card.serializer()
        return encoder.encodeToString(ListSerializer(serializer), values)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy