New functionality added inspired by Wicked Quest game.

This commit is contained in:
Storm Dragon
2025-09-16 01:21:20 -04:00
parent a96f9744a9
commit 5e5d33256e
6 changed files with 1554 additions and 25 deletions

View File

@@ -25,13 +25,62 @@ from .speech import Speech
from .scoreboard import Scoreboard
class Game:
"""Central class to manage all game systems."""
"""Central class to manage all game systems.
The Game class provides a unified interface to all libstormgames functionality,
including the new v2.0+ systems (StatTracker, SaveManager, Combat).
Example usage with new systems:
```python
import libstormgames as sg
# Initialize game with all systems
game = sg.Game("My RPG").initialize()
# Set up new game systems
stats = sg.StatTracker({"level": 1, "exp": 0, "kills": 0})
save_manager = sg.SaveManager("my-rpg") # Uses game's PathService
weapon = sg.Weapon.create_sword("Iron Sword", damage=15)
# Use in game loop
stats.update_stat("kills", 1)
game.speak(f"Level {stats.get_stat('level')} warrior!")
# Save complete game state
game_state = {
"stats": stats.to_dict(),
"weapon": weapon.to_dict(),
"progress": {"area": "forest", "time": 1200}
}
save_manager.create_save(game_state, {"display_name": "Forest Adventure"})
# Clean exit
game.exit()
```
Integration with services:
The Game class automatically initializes and connects all services:
- PathService: Manages XDG-compliant file paths
- ConfigService: Handles game configuration
- VolumeService: Controls audio volume settings
New systems like SaveManager automatically use the Game's PathService
for consistent directory structure.
"""
def __init__(self, title):
"""Initialize a new game.
"""Initialize a new game with all core services.
Args:
title (str): Title of the game
title (str): Title of the game, used for configuration paths
Note:
The game title is used to create XDG-compliant directories:
- Linux: ~/.config/storm-games/game-title/
- Windows: %APPDATA%/storm-games/game-title/
- macOS: ~/Library/Application Support/storm-games/game-title/
All new systems (SaveManager, etc.) will use these paths automatically.
"""
self.title = title