Skip to content

fixed gene sprites not loading#11

Merged
Mel-Raeven merged 1 commit into
mainfrom
fix/gene-sprites
Dec 14, 2025
Merged

fixed gene sprites not loading#11
Mel-Raeven merged 1 commit into
mainfrom
fix/gene-sprites

Conversation

@Mel-Raeven

Copy link
Copy Markdown
Owner

This pull request refactors the src/sprite_manager.py file to improve code clarity and type safety, particularly regarding dragon sprite retrieval and color constants. The main changes involve moving color constant imports to the module level, improving function signatures with Optional typing, and ensuring that stage values are always handled as strings.

Improvements to imports and code organization:

  • Moved dragon color constant imports (DRAGON_RED, DRAGON_BLUE, etc.) from inside methods to the top of the file, reducing redundancy and improving import clarity. [1] [2] [3]

Type safety and function signature improvements:

  • Updated function arguments and internal variables to use Optional typing for stage, dragon_type, and enchantments, making the code more robust and type-safe. [1] [2]
  • Ensured that stage is always treated as a string within get_dragon_sprite, reducing the risk of type errors.

Bug fixes and fallback improvements:

  • Changed fallback sprite creation to use _create_pixel_art_sprite instead of the deprecated _create_placeholder_sprite.
  • Fixed fallback logic in get_dragon_with_enchantments to always use the dragon's current stage, ensuring correct sprite selection.

Minor interface changes:

  • Changed the return type of _load_sprite_from_file to Optional[pygame.Surface] to better reflect cases where loading may fail.
  • Updated calls to get_sprite to use the new actual_stage variable, ensuring consistent stage handling.

@Mel-Raeven
Mel-Raeven merged commit cf01a97 into main Dec 14, 2025
7 checks passed
@Mel-Raeven
Mel-Raeven deleted the fix/gene-sprites branch December 14, 2025 22:35
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.

1 participant