import React, { useEffect, useState } from 'react'; import { motion, useSpring, useTransform } from 'framer-motion'; import { Check, X, Flame, ChevronRight } from 'lucide-react'; import { AnswerOption, Player, GameRole } from '../types'; import { SHAPES, COLORS } from '../constants'; import confetti from 'canvas-confetti'; const AnimatedCounter: React.FC<{ from: number; to: number }> = ({ from, to }) => { const springValue = useSpring(from, { stiffness: 50, damping: 20, }); const [displayValue, setDisplayValue] = useState(from); useEffect(() => { springValue.set(to); }, [to, springValue]); useEffect(() => { const unsubscribe = springValue.on('change', (latest) => { setDisplayValue(Math.round(Number(latest))); }); return unsubscribe; }, [springValue]); return {displayValue}; }; interface RevealScreenProps { isCorrect: boolean; pointsEarned: number; newScore: number; streak: number; correctOption: AnswerOption; selectedOption?: AnswerOption | null; role: GameRole; onNext?: () => void; isPresenter?: boolean; onPresenterAdvance?: () => void; hostParticipates?: boolean; } export const RevealScreen: React.FC = ({ isCorrect, pointsEarned, newScore, streak, correctOption, selectedOption, role, onNext, isPresenter = false, onPresenterAdvance, hostParticipates = false }) => { const isHost = role === 'HOST'; const canAdvance = isHost || isPresenter; // When host is participating, show client-style feedback view instead of presentation view const showPlayerFeedback = !isHost || hostParticipates; // Trigger confetti for correct answers useEffect(() => { if (isCorrect && !isHost) { confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 }, colors: ['#22c55e', '#ffffff', '#fbbf24'] }); } }, [isCorrect, isHost]); // Host spectating (not participating) - show presentation view with big answer card if (isHost && !hostParticipates) { const ShapeIcon = SHAPES[correctOption.shape]; const colorClass = COLORS[correctOption.color]; return (
The correct answer is

{correctOption.text}

{correctOption.reason && ( {correctOption.reason} )}
{onNext && ( Continue to Scoreboard )}
); } // -- CLIENT VIEW -- const bgColor = isCorrect ? 'bg-[#22c55e]' : 'bg-[#ef4444]'; const darkerColor = isCorrect ? 'bg-[#15803d]' : 'bg-[#b91c1c]'; const ShapeIcon = SHAPES[correctOption.shape]; return (
{/* Dynamic Background Circles */}
{isCorrect ? ( ) : ( )}

{isCorrect ? "Correct!" : "Incorrect"}

{isCorrect ? (
+{pointsEarned} Points
{correctOption.reason && (

{correctOption.reason}

)}
) : (
Don't worry, you can catch up in the next round!
)} {/* Streak Indicator */} {streak > 1 && isCorrect && (
Answer Streak: {streak}
)}
Total Score:
{!isCorrect && (
{selectedOption && selectedOption.reason && (

Why your answer was wrong

{selectedOption.reason}

)}

The correct answer was

{correctOption.text}
{correctOption.reason && (

{correctOption.reason}

)}
)} {/* Host participating gets the continue button */} {isHost && onNext && ( Continue to Scoreboard )} {/* Presenter (non-host) gets the continue button */} {!isHost && isPresenter && onPresenterAdvance && ( Continue to Scoreboard )}
); };