import React, { useEffect, useState } from 'react'; import { useGame } from '../hooks/GameContext'; import { motion } from 'framer-motion'; const Game: React.FC = () => { const { room, currentPlayer, sendGameAction } = useGame(); const [timeLeft, setTimeLeft] = useState(0); if (!room || !currentPlayer) return null; const currentTeam = room.teams[room.currentTeamIndex]; // Determine who is describing: // The `nextDescriberIndex` points to the NEXT player to describe, or the CURRENT one if the round is active? // In `finishRound` (backend), we increment it. So during the round, it points to the CURRENT describer. const describerId = currentTeam.playerIds[currentTeam.nextDescriberIndex]; const isMyTurn = currentPlayer.sessionId === describerId; const isMyTeam = currentPlayer.teamId === currentTeam.id; useEffect(() => { if (room.roundEndTime) { const interval = setInterval(() => { const remaining = Math.max(0, Math.ceil((room.roundEndTime! - Date.now()) / 1000)); setTimeLeft(remaining); // If time is up, we could trigger something, but backend controls the flow usually. // However, to be responsive, we can show "Time's up" or similar. }, 500); return () => clearInterval(interval); } }, [room.roundEndTime]); const handleAction = (action: 'GUESS' | 'SKIP') => { sendGameAction(action); // Add haptic feedback here if using Telegram SDK }; return (
Объясняй
Свайпы скоро будут доступны
{room.players[describerId]?.name || 'Игрок'} объясняет слово.
Текущий счет за раунд
???
Сейчас играет команда противников.
{t.name}
{t.score}