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:
@@ -65,12 +65,20 @@ class QuestionService:
|
||||
async def get_board_for_game(
|
||||
self,
|
||||
db: AsyncSession,
|
||||
target_date: Optional[date] = None
|
||||
target_date: Optional[date] = None,
|
||||
exclude_categories: Optional[List[int]] = None,
|
||||
point_multiplier: int = 1
|
||||
) -> Dict[str, List[dict]]:
|
||||
"""
|
||||
Genera el tablero 5×5 para el juego.
|
||||
Selecciona 5 categorías aleatorias y 1 pregunta por dificultad.
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
target_date: Date for questions (default: today)
|
||||
exclude_categories: Category IDs to exclude (for round 2)
|
||||
point_multiplier: Multiply points by this value (for round 2)
|
||||
|
||||
Returns:
|
||||
Dict con category_id como string (para JSON) -> lista de preguntas
|
||||
"""
|
||||
@@ -82,6 +90,15 @@ class QuestionService:
|
||||
# Get available category IDs that have questions
|
||||
available_categories = list(full_board.keys())
|
||||
|
||||
# Exclude categories from previous round
|
||||
if exclude_categories:
|
||||
available_categories = [
|
||||
c for c in available_categories if c not in exclude_categories
|
||||
]
|
||||
|
||||
if not available_categories:
|
||||
return {}
|
||||
|
||||
# Select random categories (up to CATEGORIES_PER_GAME)
|
||||
num_categories = min(CATEGORIES_PER_GAME, len(available_categories))
|
||||
selected_categories = random.sample(available_categories, num_categories)
|
||||
@@ -104,7 +121,10 @@ class QuestionService:
|
||||
for difficulty in range(1, 6): # 1-5
|
||||
if difficulty in questions_by_difficulty:
|
||||
questions = questions_by_difficulty[difficulty]
|
||||
selected_q = random.choice(questions)
|
||||
selected_q = random.choice(questions).copy()
|
||||
# Apply point multiplier for round 2
|
||||
if point_multiplier > 1:
|
||||
selected_q["points"] = selected_q["points"] * point_multiplier
|
||||
selected_questions.append(selected_q)
|
||||
|
||||
if selected_questions:
|
||||
|
||||
Reference in New Issue
Block a user