-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added 'pokemon' field to Pokedex #1304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi! Thanks for the contribution! I'm checking it out locally in the next days. In the meantime, could you remove from the PR all the files that have been just formatted? So that's going to be easier for me to review all the changes |
- I used black to format the entire project while I was fighting with the CI/CD pipeline
|
Hi! Thank you for taking your time reviewing my PR! I just pushed the commit where I reverted the files that I had reformatted while fighting with the CI Pipeline that are not relevant to this PR |
|
Hi! We merged a PR that brought in a schema change and now your branch fails. Could you take a look? |
- Swapped migrations 0019 and 0020 to keep them in order of merges on master
|
Already on it, I was testing locally before I pushed the fix, should be working again |
|
Hey, just wanted to check if there are any updates? Just curious, not trying to rush |
|
Hi Sorry I'm extremely busy at the moment! |
|
No worries! Like I said, I was just curious |
|
Hi! Is it possible that two pokemon belonging to the same species are part of a pokedex? If so hot to handle this case? |
|
Hi, Fair point! I would assume that if a newer pokemon game would get a pokedex where multiple varieties of the same species would be present, then each variety would get an own entry number. If this is the case, there would be no conflict and the API would simply return something among these lines (Omitted fields for clarity and used mock data): {
"id": 34,
"name": "future-pokedex",
"pokemon_entries": [
{
"entry_number": 1,
"pokemon_species": {
"name": "example",
"url": "<BASE_URL>/api/v2/pokemon-species/1/"
},
"pokemon": {
"name": "example-variety1",
"url": "<BASE_URL>/api/v2/pokemon/1/"
}
},
{
"entry_number": 2,
"pokemon_species": {
"name": "example",
"url": "<BASE_URL>/api/v2/pokemon-species/1/"
},
"pokemon": {
"name": "example-variety2",
"url": "<BASE_URL>/api/v2/pokemon/10001/"
}
}
]
}The only conflict I would see is with the implementation of the national pokedex, which is a collection of every species that exists. This case can be handled by fetching the provided species and getting the corresponding variant, which is the same as before my changes. I hope this answers your question 😄 |
|
Hey @BitTim, I can think of a few examples of multiple Pokémon forms for one species being available in a regional Pokédex:
I think this information is worth providing, and it's good future-proofing, as we already know AZ's Floette is in Z-A, and we're about to add a host of new mega evolutions from the same. Might as well do the work now, while there are only 277 variants. I suggest providing a list of the forms available in each Dex. Of course, since Generation 8, we now have to deal with forms no longer being available, so we can't just go off of the generation it was introduced in. For the long term: Perhaps we should start tracking what Pokemon are available in which games...? |
|
Thank you for your response @EthanRDoesMC ! If I am not mistaken though, you don't need the examples provided to complete a pokedex. Even though they might have different entry texts than the "main" form of the pokemon (Like the two other forms of Paldean Tauros), they are part of the same entry in-game. Although I must say, I haven't played Sword / Shield yet and it seems like the default and regional variants of most pokemon are also both part of the Galar dex, but are treated as different forms of the same pokemon (Like the Paldean Tauros). I agree that it would also be handy to be able to get all forms that are in a game as well, since currently each form must be checked explicitly if they contain the desired versionGroup reference, but I think greater changes than this would be more suited for v3, since there already is a desire to simplify the API structure in terms of forms/variants/species. There is a field in the pokemon variants though, that references all versions (specific games), the variant is in, but that field only reaches up to gen 5 I believe, everything above that is not present unfortunately. There also might be an open issue for that. |


What is this PR about?
This PR solves #1266 since it was something I need for my personal project as well.
In general, all I did was add a new field to PokemonDexNumber, that references a specific Pokemon as well, since there are Pokedexes (Basically every one from Gen 7 up until now) that have regional variants of Pokemon, which were not differentiated in the API up until now (There is also the Blueberry Dex from Gen 9 that has regional variants from regions that differ from the games region). The Pokemon themselves return also now contain a 'pokedex_numbers' array field, to be consistent with Pokemon Species.
How to test
Spin up a local instance of the API with the most recent migrations and request any pokedex (I recommend id 33) and observe the pokemon_entries field. Each item should now contain a fourth 'pokemon' field that references a Pokemon. Example (Omitted some fields and values for clarity):
https://<base_url>/api/v2/pokedex/33{ "id": 33, "name": "blueberry", "pokemon_entries": [ { "entry_number": 3, "pokemon_species": { "name": "exeggcute", "url": "http://localhost:8000/api/v2/pokemon-species/102/" }, "pokemon": { "name": "exeggcute", "url": "http://localhost:8000/api/v2/pokemon/102/" } }, { "entry_number": 4, "pokemon_species": { "name": "exeggutor", "url": "http://localhost:8000/api/v2/pokemon-species/103/" }, "pokemon": { "name": "exeggutor-alola", "url": "http://localhost:8000/api/v2/pokemon/10114/" } } ] }Pokemon now also contain the 'pokedex_numbers' field, one can request any Pokemon and observe the contents of that field as well. Example (Omitted some fields and values for clarity):
https://<base_url>/api/v2/pokemon/194{ "id": 194, "name": "wooper", "pokedex_numbers": [ { "entry_number": 58, "pokedex": { "name": "isle-of-armor", "url": "http://localhost:8000/api/v2/pokedex/28/" } }, { "entry_number": 5, "pokedex": { "name": "kitakami", "url": "http://localhost:8000/api/v2/pokedex/32/" } } ] }What about compatibility?
Since I only added the new fields while keeping the existing ones, there should be no issues with compatibility with already existing clients.
Where did the data come from?
The data I updated the CSV with was input by hand and came from a combination of PokeWiki and the already present PokeApi.