Fix exploration and battle system state management bugs
- Fixed exploration bug: prevent multiple \!explore when encounter is active - Fixed battle bug: prevent starting multiple battles from exploration encounters - Enforced exploration encounter workflow: must choose fight/capture/flee before exploring again - Fixed \!gym challenge to use player's current location instead of requiring location parameter - Added proper state management to prevent race conditions - Improved user experience with clear error messages for active encounters 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3c628c7f51
commit
d05b2ead53
3 changed files with 92 additions and 19 deletions
|
|
@ -66,7 +66,7 @@ class GymBattles(BaseModule):
|
|||
f" Status: {status} | Next difficulty: {difficulty}")
|
||||
|
||||
self.send_message(channel,
|
||||
f"💡 Use '!gym challenge \"<gym name>\"' to battle!")
|
||||
f"💡 Use '!gym challenge' to battle (gym name optional if only one gym in location)!")
|
||||
|
||||
async def cmd_gym_list_all(self, channel, nickname):
|
||||
"""List all gyms across all locations"""
|
||||
|
|
@ -97,10 +97,6 @@ class GymBattles(BaseModule):
|
|||
|
||||
async def cmd_gym_challenge(self, channel, nickname, args):
|
||||
"""Challenge a gym"""
|
||||
if not args:
|
||||
self.send_message(channel, f"{nickname}: Specify a gym to challenge! Example: !gym challenge \"Forest Guardian\"")
|
||||
return
|
||||
|
||||
player = await self.require_player(channel, nickname)
|
||||
if not player:
|
||||
return
|
||||
|
|
@ -111,19 +107,37 @@ class GymBattles(BaseModule):
|
|||
self.send_message(channel, f"{nickname}: You are not in a valid location! Use !travel to go somewhere first.")
|
||||
return
|
||||
|
||||
gym_name = " ".join(self.normalize_input(args)).strip('"')
|
||||
# Get available gyms in current location
|
||||
available_gyms = await self.database.get_gyms_in_location(location["id"])
|
||||
if not available_gyms:
|
||||
self.send_message(channel, f"{nickname}: No gyms found in {location['name']}! Try traveling to a different location.")
|
||||
return
|
||||
|
||||
# Look for gym in player's current location (case-insensitive)
|
||||
gym = await self.database.get_gym_by_name_in_location(gym_name, location["id"])
|
||||
if not gym:
|
||||
# List available gyms in current location for helpful error message
|
||||
available_gyms = await self.database.get_gyms_in_location(location["id"])
|
||||
if available_gyms:
|
||||
gym = None
|
||||
|
||||
if not args:
|
||||
# No gym name provided - auto-challenge if only one gym, otherwise list options
|
||||
if len(available_gyms) == 1:
|
||||
gym = available_gyms[0]
|
||||
self.send_message(channel, f"🏛️ {nickname}: Challenging the {gym['name']} gym in {location['name']}!")
|
||||
else:
|
||||
# Multiple gyms - show list and ask user to specify
|
||||
gym_list = ", ".join([f'"{g["name"]}"' for g in available_gyms])
|
||||
self.send_message(channel, f"{nickname}: Multiple gyms found in {location['name']}! Specify which gym to challenge:")
|
||||
self.send_message(channel, f"Available gyms: {gym_list}")
|
||||
self.send_message(channel, f"💡 Use: !gym challenge \"<gym name>\"")
|
||||
return
|
||||
else:
|
||||
# Gym name provided - find specific gym
|
||||
gym_name = " ".join(self.normalize_input(args)).strip('"')
|
||||
|
||||
# Look for gym in player's current location (case-insensitive)
|
||||
gym = await self.database.get_gym_by_name_in_location(gym_name, location["id"])
|
||||
if not gym:
|
||||
# List available gyms in current location for helpful error message
|
||||
gym_list = ", ".join([f'"{g["name"]}"' for g in available_gyms])
|
||||
self.send_message(channel, f"{nickname}: No gym named '{gym_name}' found in {location['name']}! Available gyms: {gym_list}")
|
||||
else:
|
||||
self.send_message(channel, f"{nickname}: No gyms found in {location['name']}! Try traveling to a different location.")
|
||||
return
|
||||
return
|
||||
|
||||
# Check if player has active pets
|
||||
active_pets = await self.database.get_active_pets(player["id"])
|
||||
|
|
@ -311,7 +325,7 @@ class GymBattles(BaseModule):
|
|||
return
|
||||
|
||||
# This will show a summary - for detailed view they can use !gym list
|
||||
self.send_message(channel, f"🏆 {nickname}: Use !gym list to see all gym progress, or check your profile at: http://petz.rdx4.com/player/{nickname}")
|
||||
self.send_message(channel, f"🏆 {nickname}: Use !gym list to see all gym progress, or check your profile at: http://petz.rdx4.com/player/{nickname}#gym-badges")
|
||||
|
||||
async def cmd_forfeit(self, channel, nickname):
|
||||
"""Forfeit the current gym battle"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue