From 3d46ab20a3a060ba377f5312b6acb46183f44b47 Mon Sep 17 00:00:00 2001 From: Carlos Lugo Date: Wed, 13 May 2026 15:51:13 +0000 Subject: [PATCH] Update templates/player.html --- templates/player.html | 1079 +++++++++++++---------------------------- 1 file changed, 346 insertions(+), 733 deletions(-) diff --git a/templates/player.html b/templates/player.html index 2f3024b..42a3555 100644 --- a/templates/player.html +++ b/templates/player.html @@ -1,771 +1,384 @@ - - - - - -Route Rush - - - - - -
- -
// NETWORK ROUTING GAME
-
- - -
-
- - -
-
- - -
- -
- - -
-
CONNECTED AS
-
-
-
- -
-
AWAITING HOST...
-
-
- - -
-
- RND 1/3 - 30 - 0 PTS -
-
- ROUTE FROM -
?
- ——▶ -
?
-
-
- -
- -
-
NORMAL
-
SLOW ×2
-
BOOST ×0.5
-
DOWN
-
-
- - -
-
-
-
-
-
-
WAITING FOR HOST...
-
- - -
-

GAME OVER

-
// FINAL STANDINGS
-
- -
- - - - \ No newline at end of file + async for raw in ws.iter_text(): + msg = json.loads(raw) + + if msg["type"] == "start_game": + existing_players = dict(game.players) # preserve joined players + game.reset() + game.players = existing_players # restore them + # Reset scores and state for a fresh game + for p in game.players.values(): + p["score"] = 0 + p["answered"] = False + await mgr.broadcast_all({"type": "phase", "phase": "lobby"}) + + elif msg["type"] == "next_question": + game.current_q += 1 + if game.current_q >= len(QUESTIONS): + lb = get_leaderboard() + save_session(list(game.players.values())) # ← persist to SQLite + game.phase = "podium" + await mgr.broadcast_all({"type": "podium", "leaderboard": lb}) + continue + + game.phase = "question" + game.q_start_time = time.time() + game.answers_this_round = [] + for p in game.players.values(): + p["answered"] = False + + q_idx = game.question_order[game.current_q] + q = QUESTIONS[q_idx] + await mgr.broadcast_all({ + "type": "question", + "number": game.current_q + 1, + "total": len(QUESTIONS), + "q": q["q"], + "options": q["options"], + "time_limit": 15, + "correct_idx_hint": -1 # not revealed until show_results + }) + + elif msg["type"] == "show_results": + game.phase = "results" + q_idx = game.question_order[game.current_q] + q = QUESTIONS[q_idx] + await mgr.broadcast_all({ + "type": "results", + "correct_idx": q["correct"], + "fun_fact": q["fun_fact"], + "leaderboard": get_leaderboard() + }) + + elif msg["type"] == "reset": + # Kick all players back to join screen, then wipe state + await mgr.broadcast_players({"type": "kicked"}) + game.reset() + await mgr.broadcast_hosts({"type": "lobby_update", "players": [], "count": 0}) + + except WebSocketDisconnect: + mgr.disconnect_host(ws) \ No newline at end of file