CS5500-F-2023 / bot-falcon

bot-falcon created by GitHub Classroom
Apache License 2.0
0 stars 0 forks source link

Bugs to fixed: Evolution related #124

Closed z-q-ying closed 10 months ago

z-q-ying commented 10 months ago

Hi @cptbtptp01 sorry to bother you but when I am testing evolution on my end, I found the below things to fix. Could I bother you to take a look at it (better to do this after merging the pull request #127 as there is a minor but impactful global fix too). Happy to discuss if needed.

Logical bug

Evolution-chain.json

think a global check is needed. below is some mistakes I happen to come across

    "Darumaka": {
        "evolutionFrom": "",
        "evolutionTo": "Darmanitan\n Standard Mode",
        "prev": []
    },
    "Darmanitan\n Standard Mode": {
        "evolutionFrom": "Darumaka",
        "evolutionTo": "",
        "prev": [
            "Darumaka"
        ]
    },
"Zorua\n Hisuian Zorua": {
        "evolutionFrom": "",
        "evolutionTo": "Zoroark\n Hisuian Zoroark",
        "prev": []
    },
    "Zoroark\n Hisuian Zoroark": {
        "evolutionFrom": "Zorua\n Hisuian Zorua",
        "evolutionTo": "",
        "prev": [
            "Zorua\n Hisuian Zorua"
        ]
    },

PokemonEvolutionController

cptbtptp01 commented 10 months ago

evolution method

If a pokemon starting level is 10, whatever XP points it gets, via battle or feed, it will evolve based on current math && If it gains XP, of even if I just happen to check if it can evolve...

did this happens when you call controller's evolvePokemon method when checking if the pokemon can be evolved? If so, it is because the current evolvePokemon does not handle checking XP when we call the method, it will just check if level is 10/15/20..., and if it has evolutionTo, then it will update.

my initial assumption is: this method is being called after check for xp in battle/feed framework.

happy to adjust base on battle/feed's needs. hope we can discuss a little bit more about how evolveController can provide better method for bettle/feed. let me know if there is any discrepancy among three of us regarding definition in evolve controller:

evolution json

As for Evolution-chain.json, yes, there is \n in some of the species name, that is because, the data source i found is actually use Pokemon Form Name, for some pokemon, such as rattata, whose species is Rattata, and for rattata-alola, whose species is also Rattata:

    {
        "name": "rattata",
        "speciesNames": {
            "ja-Hrkt": "コラッタ",
            "roomaji": "Koratta",
            "ko": "꼬렛",
            "zh-Hant": "小拉達",
            "fr": "Rattata",
            "de": "Rattfratz",
            "es": "Rattata",
            "it": "Rattata",
            "en": "Rattata",
            "ja": "コラッタ",
            "zh-Hans": "小拉达"
        },
        "formNames": {},
        "number": 19,
        "spriteURL": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/19.png",
        "shinySpriteURL": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/19.png",
        "hp": 30,
        "attack": 56,
        "defense": 35,
        "spAttack": 25,
        "spDefense": 35,
        "speed": 72,
        "id": "19",
        "types": [
            "normal"
        ]
    },
    {
        "name": "rattata-alola",
        "speciesNames": {
            "ja-Hrkt": "コラッタ",
            "roomaji": "Koratta",
            "ko": "꼬렛",
            "zh-Hant": "小拉達",
            "fr": "Rattata",
            "de": "Rattfratz",
            "es": "Rattata",
            "it": "Rattata",
            "en": "Rattata",
            "ja": "コラッタ",
            "zh-Hans": "小拉达"
        },
        "formNames": {
            "ja-Hrkt": "アローラのすがた",
            "ko": "알로라의 모습",
            "zh-Hant": "阿羅拉的樣子",
            "fr": "Forme d’Alola",
            "de": "Alola-Form",
            "es": "Forma de Alola",
            "it": "Forma di Alola",
            "en": "Alolan Form",
            "ja": "アローラのすがた",
            "zh-Hans": "阿罗拉的样子"
        },
        "number": 19,
        "spriteURL": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/10091.png",
        "shinySpriteURL": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/10091.png",
        "hp": 30,
        "attack": 56,
        "defense": 35,
        "spAttack": 25,
        "spDefense": 35,
        "speed": 72,
        "id": "10091",
        "types": [
            "dark",
            "normal"
        ]
    },

and in evolution.json:

    "Rattata": {
        "evolutionFrom": "",
        "evolutionTo": "Raticate",
        "prev": []
    },
    "Raticate": {
        "evolutionFrom": "Rattata",
        "evolutionTo": "",
        "prev": [
            "Rattata"
        ]
    },
    "Rattata\n Alolan Rattata": {
        "evolutionFrom": "",
        "evolutionTo": "Raticate\n Alolan Raticate",
        "prev": []
    },
    "Raticate\n Alolan Raticate": {
        "evolutionFrom": "Rattata\n Alolan Rattata",
        "evolutionTo": "",
        "prev": [
            "Rattata\n Alolan Rattata"
        ]
    },

I did not find a good way to solve it, since we are using species name to build our pokemon, we don't consider form at all, thought about remove \n, but left as is for now, as i thought map's .containsKey() or .get() would handle everything. for the example you provide:

    "Darumaka": {
        "evolutionFrom": "",
        "evolutionTo": "Darmanitan\n Standard Mode",
        "prev": []
    },
    "Darmanitan\n Standard Mode": {
        "evolutionFrom": "Darumaka",
        "evolutionTo": "",
        "prev": [
            "Darumaka"
        ]
    },

in our pokemon.json, we have:

    {
        "name": "darmanitan-standard",
        "speciesNames": {
            "ja-Hrkt": "ヒヒダルマ",
            "roomaji": "Hihidaruma",
            "ko": "불비달마",
            "zh-Hant": "達摩狒狒",
            "fr": "Darumacho",
            "de": "Flampivian",
            "es": "Darmanitan",
            "it": "Darmanitan",
            "en": "Darmanitan",
            "ja": "ヒヒダルマ",
            "zh-Hans": "达摩狒狒"
        },
        "formNames": {
            "ja-Hrkt": "ノーマルモード",
            "ko": "노말모드",
            "zh-Hant": "普通模式",
            "fr": "Mode Normal",
            "de": "Normalmodus",
            "es": "Modo Normal",
            "it": "Stato Normale",
            "en": "Standard Mode",
            "ja": "ノーマルモード",
            "zh-Hans": "普通模式"
        },

i did not find a smart way or even a a quick and dirty way to completely solve the issue... we'll probabaly just not evolve our Darumaka successfully, because i won't find Darmanitan\n Standard Mode or Darmanitan Standard Mode as species.getName() // pokemonData.getName() // pokemonData.getForNames...etc. if our Darumaka is passing to evolvePokemon, the method will just return false.

cptbtptp01 commented 10 months ago

Conclusion if you want to skip my long comment:

z-q-ying commented 10 months ago

Hey @cptbtptp01 not at all. Thanks for the detailed and patient explanation - this is very helpful!!!

Just to confirm:

z-q-ying commented 10 months ago

okay let me fix this so we can move the pr forward

cptbtptp01 commented 10 months ago

Am i understood correclty that before I call evolve, I need to check if levelUp occurs - in other words, i shall call evolve only when levelUp returns true?

yes! When level up occurs, as for xp, do you think we should keep it or set xp to zero after evolved? For example if a Pokémon ‘s xp is 70, and was rewarded 30 xp, its current xp becomes 100, it evolves, shall keep the 30xp or not? Feel like we should reset to 0?

cptbtptp01 commented 10 months ago

Regarding the json file, I’m thinking of directly modifying (read then write) the JSON file - which looks straightforward to me, something like 1h eta... if not then I would agree with you, we shall leave it as it is. But happy to give it a try on my end to see if it works, just let me know

sure but need to cross check with pokemon.json🥲 may I ask the goal, do you want a json file contains all valid entries?

z-q-ying commented 10 months ago

sorry I just see the message 😂 but it's done - check PR#129 - i really think this is half-an-hour or so workload so with the shared goal to finish our bot sooner, let me just handle this on my end