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

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

package eu.codlab.lorcana.raw

import eu.codlab.lorcana.cards.ClassificationHolder
import eu.codlab.lorcana.cards.Erratas
import eu.codlab.lorcana.cards.Language
import eu.codlab.lorcana.cards.VariantRarity
import eu.codlab.lorcana.cards.to
import kotlinx.serialization.Serializable

@Serializable
data class Variant(
    val set: SetDescription,
    val id: Int,
    val rarity: VariantRarity,
    val illustrator: String? = null,
    val erratas: Map>? = null
)

fun Variant.to(
    mapOfClassifications: Map
): Variant = Variant(
    set = set,
    id = id,
    rarity = rarity,
    illustrator = illustrator,
    erratas = if (null == erratas) {
        null
    } else {
        mutableMapOf>().let { map ->
            erratas.keys.forEach { language ->
                map[language] = erratas[language]!!.to(mapOfClassifications)
            }

            map
        }
    }
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy