fix(botagent): auto-rejoin lobby if player avatar was dropped due to a board layout reset

This commit is contained in:
Isaac Johnson 2026-09-06 08:50:21 -05:00
parent 5dd6c84352
commit e570d888e5
1 changed files with 9 additions and 2 deletions

View File

@ -271,8 +271,15 @@ class SmartBotAgent:
while True:
turn_info = requests.get(f"{self.base_url}/turn").json()
if not turn_info.get("game_started", False):
# Check if bot was removed (e.g., board was reset)
if self.bot_id:
res = requests.get(f"{self.base_url}/players/{self.bot_id}")
if res.status_code == 404:
print("\n⚠️ [RESET] Board was regenerated. Rejoining lobby...")
self.register()
print("⏳ [LOBBY] Waiting for game to start via 'Start Game' in UI... ", end="\r", flush=True)
time.sleep(0.5)
time.sleep(1.0)
continue
curr_player_id = turn_info.get("current_player_id")