feat: sistema de 2 rondas con puntos dobles
Ronda 1: 5 categorías con puntos normales (100-500) Ronda 2: 5 categorías diferentes con puntos x2 (200-1000) Backend: - question_service: soporta excluir categorías y multiplicador de puntos - game_manager: trackea current_round, start_round_2() carga nuevo tablero - game_events: emite round_started al completar ronda 1 Frontend: - useSocket: escucha evento round_started - Game.tsx: muestra indicador de ronda actual - types: GameRoom incluye current_round Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -358,9 +358,28 @@ def register_socket_events(sio: socketio.AsyncServer):
|
||||
points_earned=result["points_earned"]
|
||||
)
|
||||
|
||||
# Verificar si el juego termino (todas las preguntas respondidas)
|
||||
if room_data.get("status") == "finished":
|
||||
# Disparar finalizacion automatica
|
||||
# Verificar si terminó la ronda o el juego
|
||||
if room_data.get("round_finished"):
|
||||
# Ronda 1 terminada - iniciar ronda 2
|
||||
async with await get_db_session() as db:
|
||||
new_room = await game_manager.start_round_2(db, room_code)
|
||||
if new_room:
|
||||
if new_room.get("status") == "finished":
|
||||
# No hay suficientes categorías para ronda 2
|
||||
await finish_game_internal(room_code)
|
||||
else:
|
||||
# Emitir evento de nueva ronda
|
||||
await sio.emit(
|
||||
"round_started",
|
||||
{
|
||||
"room": new_room,
|
||||
"round": 2,
|
||||
"message": "¡Ronda 2! Puntos dobles"
|
||||
},
|
||||
room=room_code
|
||||
)
|
||||
elif room_data.get("status") == "finished":
|
||||
# Juego terminado
|
||||
await finish_game_internal(room_code)
|
||||
|
||||
@sio.event
|
||||
@@ -395,6 +414,26 @@ def register_socket_events(sio: socketio.AsyncServer):
|
||||
team=player["team"],
|
||||
question_id=question_id
|
||||
)
|
||||
|
||||
# Verificar si terminó la ronda o el juego
|
||||
if room.get("round_finished"):
|
||||
async with await get_db_session() as db:
|
||||
new_room = await game_manager.start_round_2(db, room_code)
|
||||
if new_room:
|
||||
if new_room.get("status") == "finished":
|
||||
await finish_game_internal(room_code)
|
||||
else:
|
||||
await sio.emit(
|
||||
"round_started",
|
||||
{
|
||||
"room": new_room,
|
||||
"round": 2,
|
||||
"message": "¡Ronda 2! Puntos dobles"
|
||||
},
|
||||
room=room_code
|
||||
)
|
||||
elif room.get("status") == "finished":
|
||||
await finish_game_internal(room_code)
|
||||
else:
|
||||
# Will attempt steal - just notify, answer comes separately
|
||||
room = await room_manager.get_room(room_code)
|
||||
|
||||
Reference in New Issue
Block a user