Skip to content

Releases: ericmaddox/pokemon-battle

Version 1.0.1

07 Dec 19:10
03f20fb
Compare
Choose a tag to compare

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Damage Variance:

    • Damage calculations now have slight randomness to add variability, making each battle feel more dynamic.

Code Improvements:

  1. Modularized Functions:

    • Functions like battle() and calculate_damage() were broken down into smaller, reusable components for better readability and maintainability.
  2. Error Handling:

    • More robust error handling was added for API requests to ensure stability and smooth user experience, even in case of failed requests.
  3. Caching:

    • LRU (Least Recently Used) caching for type data has been implemented to minimize redundant API calls and speed up data retrieval.
  4. 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