From dc49e5f9c928578bc847e4f8a1ceee312d134d64 Mon Sep 17 00:00:00 2001 From: megaproxy Date: Mon, 14 Jul 2025 13:00:34 +0100 Subject: [PATCH] Add missing get_active_pets method to database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/database.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/database.py b/src/database.py index 03c3fbe..e6a767a 100644 --- a/src/database.py +++ b/src/database.py @@ -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"""