Add missing get_active_pets method to database

- Added get_active_pets() method that returns all active pets for a player
- Method includes pet details and species information needed for gym battles
- Fixes "get_active_pets" AttributeError in gym challenge command

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
megaproxy 2025-07-14 13:00:34 +01:00
parent c1f82b6c6d
commit dc49e5f9c9

View file

@ -739,6 +739,21 @@ class Database:
await db.commit()
return True
async def get_active_pets(self, player_id: int) -> List[Dict]:
"""Get all active pets for a player"""
async with aiosqlite.connect(self.db_path) as db:
db.row_factory = aiosqlite.Row
cursor = await db.execute("""
SELECT p.*, ps.name as species_name, ps.type1, ps.type2,
ps.base_hp, ps.base_attack, ps.base_defense, ps.base_speed
FROM pets p
JOIN pet_species ps ON p.species_id = ps.id
WHERE p.player_id = ? AND p.is_active = 1
ORDER BY p.id ASC
""", (player_id,))
rows = await cursor.fetchall()
return [dict(row) for row in rows]
# Gym Battle System Methods
async def get_gyms_in_location(self, location_id: int, player_id: int = None) -> List[Dict]:
"""Get all gyms in a specific location with optional player progress"""