Accurately Pull From Pokemon Base Stats #5
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Utilize the existing scaffolding of the Pokedex-Compose App to accurately display a given Pokemon's base stats, only falling back to randomized stats if the initial stat cannot be found in the Pokemon's StatsResponse object.
🛠 Implementation details
This pull request changes code across the application, but only in a way that facilitates the integration of a Pokemon's stats data rather than fundamentally changing any of the core architectural features of the application. As such, the code changes are distributed throughout core-model, core-database, and features, but mostly consist of changes meant to account for the additional fields introduced in PokemonInfo.kt
Core Model Changes
PokemonInfo.kt: Added new fields that corresponds to a Pokemon's 'stats' field, as outlined in the PokeAPI. Replaced existing hp, attack, speed, and defense fields with lazily initialized values that either return the relevant stat from the stats field or a random integer if the stat cannot be found.
Preview Changes
PreviewUtils.kt: Updated mockPokemonInfo() to reflect changes to the core model.
Core Database Changes
DatabseModule.kt: Added the StatsResponse type converter to the application database in provideAppDatabase()
StatsResponseConverter.kt: Added a type converter for StatsResponse.
Updated Pokemon Info DAO, Entity Mapper, and Entity Kotlin files to account for PokemonInfo's new stats fields.
✍️ Explain examples