Release Notes for pokemon_battle.py
Version 1.0.1 - Asynchronous requests and code improvements
Release Date: December 7th, 2024
This release introduces several major updates to the Pokémon Battle script, improving gameplay mechanics, performance, and overall code structure.
New Features:
-
Leveling System:
- Pokémon now level up and evolve based on experience points (EXP). Evolution is triggered at specific levels (e.g., Bulbasaur evolves into Ivysaur at level 16).
- Pokémon gain EXP from battle outcomes, and reaching 100 EXP results in a level-up.
-
Critical Hit Enhancements:
- Pokémon now have a dynamically calculated critical hit chance based on their stats (e.g., Speed). Critical hits provide a 1.5x damage multiplier.
- The critical hit chance is influenced by a formula that scales with the Pokémon's attributes.
-
Asynchronous Requests:
- API calls (e.g., to fetch Pokémon data or move data) are now asynchronous, reducing wait times during battle and data retrieval.
-
Battle Logic:
- Turn-based strategy is implemented, where players and opponents take turns choosing moves.
- Type effectiveness and weather effects are factored into damage calculations.
-
Expanded Evolution Logic:
- Evolution now respects Pokémon evolutionary chains and handles missing evolutions properly.
- Additional evolutionary rules can easily be added to accommodate more Pokémon.
-
Damage Variance:
- Damage calculations now have slight randomness to add variability, making each battle feel more dynamic.
Code Improvements:
-
Modularized Functions:
- Functions like
battle()
andcalculate_damage()
were broken down into smaller, reusable components for better readability and maintainability.
- Functions like
-
Error Handling:
- More robust error handling was added for API requests to ensure stability and smooth user experience, even in case of failed requests.
-
Caching:
- LRU (Least Recently Used) caching for type data has been implemented to minimize redundant API calls and speed up data retrieval.
-
Constants and Validation:
- Introduced constants for common values (e.g., experience thresholds) to make the code more maintainable.
- Added validation for missing or invalid data to prevent crashes during runtime.
Dependencies:
aiohttp
(for asynchronous HTTP requests)asyncio
(for asynchronous functionality)
Installation:
To install the dependencies, run the following command:
pip install -r requirements.txt