Improve gym challenge command with location-aware and case-insensitive search
- Updated gym challenge to automatically search in player's current location first - Made gym search case-insensitive (forest guardian, Forest Guardian, FOREST GUARDIAN all work) - Added helpful error messages showing available gyms in current location - Updated gym info command to also prioritize current location and be case-insensitive - Added get_gym_by_name_in_location() database method for location-specific searches - Improved user experience by removing need to travel between locations to challenge gyms Fixes: \!gym challenge forest guardian now works correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4ccfdd3505
commit
c1f82b6c6d
3 changed files with 48 additions and 16 deletions
|
|
@ -770,18 +770,31 @@ class Database:
|
|||
return [dict(row) for row in rows]
|
||||
|
||||
async def get_gym_by_name(self, gym_name: str) -> Optional[Dict]:
|
||||
"""Get gym details by name"""
|
||||
"""Get gym details by name (case-insensitive)"""
|
||||
async with aiosqlite.connect(self.db_path) as db:
|
||||
db.row_factory = aiosqlite.Row
|
||||
cursor = await db.execute("""
|
||||
SELECT g.*, l.name as location_name
|
||||
FROM gyms g
|
||||
JOIN locations l ON g.location_id = l.id
|
||||
WHERE g.name = ?
|
||||
WHERE LOWER(g.name) = LOWER(?)
|
||||
""", (gym_name,))
|
||||
row = await cursor.fetchone()
|
||||
return dict(row) if row else None
|
||||
|
||||
async def get_gym_by_name_in_location(self, gym_name: str, location_id: int) -> Optional[Dict]:
|
||||
"""Get gym details by name in a specific location (case-insensitive)"""
|
||||
async with aiosqlite.connect(self.db_path) as db:
|
||||
db.row_factory = aiosqlite.Row
|
||||
cursor = await db.execute("""
|
||||
SELECT g.*, l.name as location_name
|
||||
FROM gyms g
|
||||
JOIN locations l ON g.location_id = l.id
|
||||
WHERE g.location_id = ? AND LOWER(g.name) = LOWER(?)
|
||||
""", (location_id, gym_name))
|
||||
row = await cursor.fetchone()
|
||||
return dict(row) if row else None
|
||||
|
||||
async def get_gym_team(self, gym_id: int, difficulty_multiplier: float = 1.0) -> List[Dict]:
|
||||
"""Get gym team with difficulty scaling applied"""
|
||||
async with aiosqlite.connect(self.db_path) as db:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue