Skip to content
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

Accurately Pull From Pokemon Base Stats #5

Merged
merged 5 commits into from
Apr 23, 2024

Conversation

cmhhelgeson
Copy link
Contributor

🎯 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

image

image

… reverting to randomly generating the stat should it not be present within a given Pokemon
@cmhhelgeson cmhhelgeson requested a review from skydoves as a code owner April 18, 2024 22:03
@cmhhelgeson
Copy link
Contributor Author

Apologies for the issues on the previous builds, I believe I was able to get spotlessApply to work correctly on my machine.

Copy link
Owner

@skydoves skydoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you so much for your valuable contribution 😄

@skydoves skydoves merged commit 6615a24 into skydoves:main Apr 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants