import React from 'react'; import { useGame } from './hooks/useGame'; import { Landing } from './components/Landing'; import { Lobby } from './components/Lobby'; import { GameScreen } from './components/GameScreen'; import { Scoreboard } from './components/Scoreboard'; import { Podium } from './components/Podium'; import { QuizCreator } from './components/QuizCreator'; import { RevealScreen } from './components/RevealScreen'; const FloatingShapes = () => { // Deterministic "random" for SSR safety if needed, but client-side is fine here const shapes = [...Array(15)].map((_, i) => ({ left: `${Math.random() * 100}%`, width: `${Math.random() * 100 + 40}px`, height: `${Math.random() * 100 + 40}px`, animationDuration: `${Math.random() * 20 + 15}s`, animationDelay: `-${Math.random() * 20}s`, borderRadius: Math.random() > 0.5 ? '50%' : '20%', // Mix of circles and rounded squares background: 'rgba(255, 255, 255, 0.05)', })); return ( <> {shapes.map((style, i) => (
))} ); }; function App() { const { role, gameState, quiz, players, currentQuestionIndex, timeLeft, error, gamePin, startQuizGen, startManualCreation, finalizeManualQuiz, joinGame, startGame, handleAnswer, hasAnswered, lastPointsEarned, nextQuestion, currentCorrectShape } = useGame(); const currentQ = quiz?.questions[currentQuestionIndex]; // Logic to find correct option, handling both Host (has isCorrect flag) and Client (masked, needs shape) const correctOpt = currentQ?.options.find(o => { if (role === 'HOST') return o.isCorrect; return o.shape === currentCorrectShape; }); return (
{gameState === 'LANDING' || gameState === 'GENERATING' ? ( ) : null} {gameState === 'CREATING' ? ( window.location.reload()} /> ) : null} {gameState === 'LOBBY' ? ( ) : null} {(gameState === 'COUNTDOWN' || gameState === 'QUESTION') && quiz ? ( gameState === 'COUNTDOWN' ? (
Get Ready!
{timeLeft}
) : ( ) ) : null} {gameState === 'REVEAL' && correctOpt ? ( 0} pointsEarned={lastPointsEarned || 0} newScore={0} streak={0} correctOption={correctOpt} role={role} /> ) : null} {gameState === 'SCOREBOARD' ? ( ) : null} {gameState === 'PODIUM' ? ( window.location.reload()} /> ) : null}
); } export default App;