package eu.gaudian.translator.model

import eu.gaudian.translator.R


object LanguageLevels {
    val all: List<MyAppLanguageLevel> = listOf(
        MyAppLanguageLevel.Newborn,
        MyAppLanguageLevel.EchoingEcho,
        MyAppLanguageLevel.GoldfishMemory,
        MyAppLanguageLevel.CleverPigeon,
        MyAppLanguageLevel.KoshikTheElephant,
        MyAppLanguageLevel.GossipLovingCrow,
        MyAppLanguageLevel.HoneybeeCartographer,
        MyAppLanguageLevel.ChattyParrotlet,
        MyAppLanguageLevel.CuriousToddler,
        MyAppLanguageLevel.RicoTheDog,
        MyAppLanguageLevel.AuctioneerInTraining,
        MyAppLanguageLevel.AlexTheParrot,
        MyAppLanguageLevel.PilitaTheSeaLion,
        MyAppLanguageLevel.KanziTheBonobo,
        MyAppLanguageLevel.KokoTheGorilla,
        MyAppLanguageLevel.ShakespeareanInsultGenerator,
        MyAppLanguageLevel.FirstGrader,
        MyAppLanguageLevel.PuppyInTraining,
        MyAppLanguageLevel.ChaserTheSuperdog,
        MyAppLanguageLevel.Bookworm,
        MyAppLanguageLevel.MiddleSchooler,
        MyAppLanguageLevel.AvidDebater,
        MyAppLanguageLevel.HighSchoolGrad,
        MyAppLanguageLevel.TheJournalist,
        MyAppLanguageLevel.TheProfessor,
        MyAppLanguageLevel.TheNovelist,
        MyAppLanguageLevel.MasterLinguist,
        MyAppLanguageLevel.ThePolyglotOracle
    )

    fun getLevelForWords(wordsLearned: Int): MyAppLanguageLevel {
        return all.lastOrNull { wordsLearned >= it.wordsKnown } ?: MyAppLanguageLevel.Newborn
    }
    fun getNextLevel(wordsLearned: Int): MyAppLanguageLevel? {
        return all.firstOrNull { wordsLearned < it.wordsKnown }

    }
}

sealed class MyAppLanguageLevel(
    val nameResId: Int,
    val descriptionResId: Int,
    val wordsKnown: Int,
    val iconResId: Int
) {
    object Newborn : MyAppLanguageLevel(
        nameResId = R.string.level_newborn_name,
        descriptionResId = R.string.level_newborn_description,
        wordsKnown = 0,
        iconResId = R.drawable.ic_level_newborn
    )

    object EchoingEcho : MyAppLanguageLevel( // New
        nameResId = R.string.level_echo_name,
        descriptionResId = R.string.level_echo_description,
        wordsKnown = 3,
        iconResId = R.drawable.ic_level_echo
    )

    object GoldfishMemory : MyAppLanguageLevel(
        nameResId = R.string.level_goldfish_name,
        descriptionResId = R.string.level_goldfish_description,
        wordsKnown = 5,
        iconResId = R.drawable.ic_level_goldfish
    )

    object CleverPigeon : MyAppLanguageLevel(
        nameResId = R.string.level_pigeon_name,
        descriptionResId = R.string.level_pigeon_description,
        wordsKnown = 10,
        iconResId = R.drawable.ic_level_pigeon
    )

    object KoshikTheElephant : MyAppLanguageLevel(
        nameResId = R.string.level_elephant_name,
        descriptionResId = R.string.level_elephant_description,
        wordsKnown = 20,
        iconResId = R.drawable.ic_level_elephant
    )

    object GossipLovingCrow : MyAppLanguageLevel(
        nameResId = R.string.level_crow_name,
        descriptionResId = R.string.level_crow_description,
        wordsKnown = 25,
        iconResId = R.drawable.ic_level_crow
    )

    object HoneybeeCartographer : MyAppLanguageLevel(
        nameResId = R.string.level_honeybee_name,
        descriptionResId = R.string.level_honeybee_description,
        wordsKnown = 35,
        iconResId = R.drawable.ic_level_bee
    )

    object ChattyParrotlet : MyAppLanguageLevel(
        nameResId = R.string.level_parrotlet_name,
        descriptionResId = R.string.level_parrotlet_description,
        wordsKnown = 50,
        iconResId = R.drawable.ic_level_parrotlet
    )

    object CuriousToddler : MyAppLanguageLevel(
        nameResId = R.string.level_toddler_name,
        descriptionResId = R.string.level_toddler_description,
        wordsKnown = 75,
        iconResId = R.drawable.ic_level_toddler
    )

    object RicoTheDog : MyAppLanguageLevel(
        nameResId = R.string.level_rico_name,
        descriptionResId = R.string.level_rico_description,
        wordsKnown = 100,
        iconResId = R.drawable.ic_level_rico
    )

    object AuctioneerInTraining : MyAppLanguageLevel( // New
        nameResId = R.string.level_auctioneer_name,
        descriptionResId = R.string.level_auctioneer_description,
        wordsKnown = 125,
        iconResId = R.drawable.ic_level_auctioneer
    )

    object AlexTheParrot : MyAppLanguageLevel(
        nameResId = R.string.level_alex_name,
        descriptionResId = R.string.level_alex_description,
        wordsKnown = 150,
        iconResId = R.drawable.ic_level_parrot
    )

    object PilitaTheSeaLion : MyAppLanguageLevel(
        nameResId = R.string.level_pilita_name,
        descriptionResId = R.string.level_pilita_description,
        wordsKnown = 225,
        iconResId = R.drawable.ic_level_sea_lion
    )

    object KanziTheBonobo : MyAppLanguageLevel(
        nameResId = R.string.level_kanzi_name,
        descriptionResId = R.string.level_kanzi_description,
        wordsKnown = 350,
        iconResId = R.drawable.ic_level_bonobo
    )

    object KokoTheGorilla : MyAppLanguageLevel(
        nameResId = R.string.level_koko_name,
        descriptionResId = R.string.level_koko_description,
        wordsKnown = 500,
        iconResId = R.drawable.ic_level_gorilla
    )

    object ShakespeareanInsultGenerator : MyAppLanguageLevel(
        nameResId = R.string.level_shakespeare_name,
        descriptionResId = R.string.level_shakespeare_description,
        wordsKnown = 600,
        iconResId = R.drawable.ic_level_shakespeare
    )

    object FirstGrader : MyAppLanguageLevel(
        nameResId = R.string.level_first_grader_name,
        descriptionResId = R.string.level_first_grader_description,
        wordsKnown = 750,
        iconResId = R.drawable.ic_level_first_grader
    )

    object PuppyInTraining : MyAppLanguageLevel(
        nameResId = R.string.level_puppy_in_training_name,
        descriptionResId = R.string.level_puppy_in_training_description,
        wordsKnown = 900,
        iconResId = R.drawable.ic_level_puppy
    )

    object ChaserTheSuperdog : MyAppLanguageLevel(
        nameResId = R.string.level_chaser_name,
        descriptionResId = R.string.level_chaser_description,
        wordsKnown = 1100,
        iconResId = R.drawable.ic_level_chaser
    )

    object Bookworm : MyAppLanguageLevel(
        nameResId = R.string.level_bookworm_name,
        descriptionResId = R.string.level_bookworm_description,
        wordsKnown = 1600,
        iconResId = R.drawable.ic_level_bookworm
    )

    object MiddleSchooler : MyAppLanguageLevel(
        nameResId = R.string.level_middle_schooler_name,
        descriptionResId = R.string.level_middle_schooler_description,
        wordsKnown = 2300,
        iconResId = R.drawable.ic_level_middle_schooler
    )

    object AvidDebater : MyAppLanguageLevel(
        nameResId = R.string.level_avid_debater_name,
        descriptionResId = R.string.level_avid_debater_description,
        wordsKnown = 3500,
        iconResId = R.drawable.ic_level_avid_debater
    )

    object HighSchoolGrad : MyAppLanguageLevel(
        nameResId = R.string.level_high_school_grad_name,
        descriptionResId = R.string.level_high_school_grad_description,
        wordsKnown = 5000,
        iconResId = R.drawable.ic_level_high_school_grad
    )

    object TheJournalist : MyAppLanguageLevel(
        nameResId = R.string.level_journalist_name,
        descriptionResId = R.string.level_journalist_description,
        wordsKnown = 7500,
        iconResId = R.drawable.ic_level_journalist
    )

    object TheProfessor : MyAppLanguageLevel(
        nameResId = R.string.level_professor_name,
        descriptionResId = R.string.level_professor_description,
        wordsKnown = 12000,
        iconResId = R.drawable.ic_level_professor
    )

    object TheNovelist : MyAppLanguageLevel(
        nameResId = R.string.level_novelist_name,
        descriptionResId = R.string.level_novelist_description,
        wordsKnown = 18000,
        iconResId = R.drawable.ic_level_novelist
    )

    object MasterLinguist : MyAppLanguageLevel(
        nameResId = R.string.level_linguist_name,
        descriptionResId = R.string.level_linguist_description,
        wordsKnown = 25000,
        iconResId = R.drawable.ic_level_master_linguist
    )

    object ThePolyglotOracle : MyAppLanguageLevel(
        nameResId = R.string.level_oracle_name,
        descriptionResId = R.string.level_oracle_description,
        wordsKnown = 50000,
        iconResId = R.drawable.ic_level_oracle
    )
}