commonMain.eu.codlab.lorcana.CompiledSet.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lorcana-data Show documentation
Show all versions of lorcana-data Show documentation
Lorcana set descriptions and data
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)
}
}