<commit_before>package com.jamieadkins.gwent.data

import com.jamieadkins.gwent.data.card.CardDetails
import com.jamieadkins.gwent.data.card.Faction
import com.jamieadkins.gwent.data.card.Type
import com.jamieadkins.gwent.model.*

object Mapper {

    fun cardDetailsToGwentCard(cardDetails: CardDetails): GwentCard {
        val card = GwentCard()
        card.id = cardDetails.ingameId
        card.strength = cardDetails.strength
        card.name = cardDetails.name
        card.info = cardDetails.info
        card.flavor = cardDetails.flavor
        card.faction = factionIdToFaction(cardDetails.faction)
        card.rarity = rarityIdToRarity(cardDetails.rarity)
        card.colour = typeToColour(cardDetails.type)

        card.cardArt = CardArt().apply {
            val variation = cardDetails.variations.values.firstOrNull()
            original = variation?.art?.original
            high = variation?.art?.high
            medium = variation?.art?.medium
            low = variation?.art?.low
            thumbnail = variation?.art?.thumbnail
            artist = variation?.art?.artist
        }

        cardDetails.loyalties?.forEach { id ->
            loyaltyIdToLoyalty(id)?.let {
                card.loyalties.add(it)
            }
        }

        return card
    }

    fun cardDetailsListToGwentCardList(list: List<CardDetails>): List<GwentCard> {
        val cards = mutableListOf<GwentCard>()
        list.forEach {
            if (it.isReleased) {
                cards.add(Mapper.cardDetailsToGwentCard(it))
            }
        }
        return cards
    }

    fun factionIdToFaction(factionId: String): GwentFaction? {
        return when (factionId) {
            Faction.MONSTERS_ID -> GwentFaction.MONSTER
            Faction.NORTHERN_REALMS_ID -> GwentFaction.NORTHERN_REALMS
            Faction.SCOIATAEL_ID -> GwentFaction.SCOIATAEL
            Faction.SKELLIGE_ID -> GwentFaction.SKELLIGE
            Faction.NILFGAARD_ID -> GwentFaction.NILFGAARD
            else -> null
        }
    }

    fun typeToColour(type: String): CardColour? {
        return when (type) {
            Type.BRONZE_ID -> CardColour.BRONZE
            Type.SILVER_ID -> CardColour.SILVER<commit_msg>Fixed Neutral cards beign missing<commit_after>package com.jamieadkins.gwent.data

import com.jamieadkins.gwent.data.card.CardDetails
import com.jamieadkins.gwent.data.card.Faction
import com.jamieadkins.gwent.data.card.Type
import com.jamieadkins.gwent.model.*

object Mapper {

    fun cardDetailsToGwentCard(cardDetails: CardDetails): GwentCard {
        val card = GwentCard()
        card.id = cardDetails.ingameId
        card.strength = cardDetails.strength
        card.name = cardDetails.name
        card.info = cardDetails.info
        card.flavor = cardDetails.flavor
        card.faction = factionIdToFaction(cardDetails.faction)
        card.rarity = rarityIdToRarity(cardDetails.rarity)
        card.colour = typeToColour(cardDetails.type)

        card.cardArt = CardArt().apply {
            val variation = cardDetails.variations.values.firstOrNull()
            original = variation?.art?.original
            high = variation?.art?.high
            medium = variation?.art?.medium
            low = variation?.art?.low
            thumbnail = variation?.art?.thumbnail
            artist = variation?.art?.artist
        }

        cardDetails.loyalties?.forEach { id ->
            loyaltyIdToLoyalty(id)?.let {
                card.loyalties.add(it)
            }
        }

        return card
    }

    fun cardDetailsListToGwentCardList(list: List<CardDetails>): List<GwentCard> {
        val cards = mutableListOf<GwentCard>()
        list.forEach {
            if (it.isReleased) {
                cards.add(Mapper.cardDetailsToGwentCard(it))
            }
        }
        return cards
    }

    fun factionIdToFaction(factionId: String): GwentFaction? {
        return when (factionId) {
            Faction.MONSTERS_ID -> GwentFaction.MONSTER
            Faction.NORTHERN_REALMS_ID -> GwentFaction.NORTHERN_REALMS
            Faction.SCOIATAEL_ID -> GwentFaction.SCOIATAEL
            Faction.SKELLIGE_ID -> GwentFaction.SKELLIGE
            Faction.NILFGAARD_ID -> GwentFaction.NILFGAARD
            Faction.NEUTRAL_ID -> GwentFaction.NEUTRAL
            else -> null
        }
    }

    fun typeToColour(type: String): CardColour? {
        return when (type) {
            Type.BRONZE_ID -> CardColour.BRONZE
            Type.SILVER_ID -> CardColour.SILVER
{'fraction_non_alphanumeric': 0.09177565949900243, 'fraction_numerical': 0.0, 'mean_word_length': 2.1707659873506677, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1457624', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1383, 'n_words': 207}