import React from 'react'; import { Question, AnswerOption, GameState, GameRole } from '../types'; import { COLORS, SHAPES } from '../constants'; import { motion, AnimatePresence } from 'framer-motion'; interface GameScreenProps { question?: Question; timeLeft: number; totalQuestions: number; currentQuestionIndex: number; gameState: GameState; role: GameRole; onAnswer: (isCorrect: boolean) => void; hasAnswered: boolean; lastPointsEarned: number | null; hostPlays?: boolean; } export const GameScreen: React.FC = ({ question, timeLeft, totalQuestions, currentQuestionIndex, gameState, role, onAnswer, hasAnswered, hostPlays = true, }) => { const isClient = role === 'CLIENT'; const isSpectator = role === 'HOST' && !hostPlays; const displayOptions = question?.options || []; const timeLeftSeconds = Math.ceil(timeLeft / 1000); const isUrgent = timeLeftSeconds <= 5 && timeLeftSeconds > 0; const timerBorderColor = isUrgent ? 'border-red-500' : 'border-white'; const timerTextColor = isUrgent ? 'text-red-500' : 'text-theme-primary'; const timerAnimation = isUrgent ? 'animate-ping' : ''; return (
{/* Header */}
{currentQuestionIndex + 1} / {totalQuestions}
{timeLeftSeconds}
{isClient ? 'Player' : isSpectator ? 'Spectator' : 'Host'}
{/* Question Area */}
{question && (

{question.text}

)}
{/* Answer Grid */}
{displayOptions.map((option, idx) => { const ShapeIcon = SHAPES[option.shape]; const colorClass = COLORS[option.color]; let opacityClass = "opacity-100"; let scaleClass = "scale-100"; let cursorClass = ""; if (isSpectator) { cursorClass = "cursor-default"; } else if (hasAnswered) { opacityClass = "opacity-50 cursor-not-allowed grayscale"; scaleClass = "scale-95"; } return ( !isSpectator && onAnswer(option as any)} className={` ${colorClass} ${opacityClass} ${scaleClass} ${cursorClass} rounded-3xl shadow-[0_8px_0_rgba(0,0,0,0.2)] flex flex-col md:flex-row items-center justify-center md:justify-start p-4 md:p-8 ${!isSpectator ? 'active:shadow-none active:translate-y-[8px] active:scale-95' : ''} transition-all duration-300 relative group overflow-hidden border-b-8 border-black/10 `} >
{option.text}
); })}
{/* "Answer Sent" Overlay */} {isClient && hasAnswered && ( 🚀

Answer Sent!

Cross your fingers...

)}
); };