fix(botagent): auto-rejoin lobby if player avatar was dropped due to a board layout reset
This commit is contained in:
parent
5dd6c84352
commit
e570d888e5
|
|
@ -271,8 +271,15 @@ class SmartBotAgent:
|
||||||
while True:
|
while True:
|
||||||
turn_info = requests.get(f"{self.base_url}/turn").json()
|
turn_info = requests.get(f"{self.base_url}/turn").json()
|
||||||
if not turn_info.get("game_started", False):
|
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)
|
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
|
continue
|
||||||
|
|
||||||
curr_player_id = turn_info.get("current_player_id")
|
curr_player_id = turn_info.get("current_player_id")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue