import React, { useState, useEffect } from 'react'; import { ChevronLeft, ChevronRight, SkipBack, SkipForward, Play, Pause, RotateCw, Columns, Rows } from 'lucide-react'; import { LotomaniaGame } from '../types'; import EnhancedLotomaniaGrid from './EnhancedLotomaniaGrid'; interface DualGameViewerProps { verticalGames: LotomaniaGame[]; horizontalGames: LotomaniaGame[]; currentVerticalGameId: number; currentHorizontalGameId: number; onVerticalGameChange: (gameId: number) => void; onHorizontalGameChange: (gameId: number) => void; matchedNumbers?: { vertical: number[]; horizontal: number[]; }; } const DualGameViewer: React.FC = ({ verticalGames, horizontalGames, currentVerticalGameId, currentHorizontalGameId, onVerticalGameChange, onHorizontalGameChange, matchedNumbers }) => { const [activeTab, setActiveTab] = useState<'vertical' | 'horizontal'>('vertical'); const [isAutoPlay, setIsAutoPlay] = useState(false); const [autoPlaySpeed, setAutoPlaySpeed] = useState(1000); const [syncMode, setSyncMode] = useState(false); const currentVerticalGame = verticalGames.find(game => game.id === currentVerticalGameId); const currentHorizontalGame = horizontalGames.find(game => game.id === currentHorizontalGameId); const verticalIndex = verticalGames.findIndex(game => game.id === currentVerticalGameId); const horizontalIndex = horizontalGames.findIndex(game => game.id === currentHorizontalGameId); // Auto-play functionality useEffect(() => { if (!isAutoPlay) return; const interval = setInterval(() => { if (activeTab === 'vertical' && verticalIndex < verticalGames.length - 1) { onVerticalGameChange(verticalGames[verticalIndex + 1].id); } else if (activeTab === 'horizontal' && horizontalIndex < horizontalGames.length - 1) { onHorizontalGameChange(horizontalGames[horizontalIndex + 1].id); } else { setIsAutoPlay(false); } }, autoPlaySpeed); return () => clearInterval(interval); }, [isAutoPlay, activeTab, verticalIndex, horizontalIndex, verticalGames, horizontalGames, onVerticalGameChange, onHorizontalGameChange, autoPlaySpeed]); // Sync mode - when one changes, change the other to same relative position useEffect(() => { if (!syncMode) return; const verticalProgress = verticalIndex / (verticalGames.length - 1); const horizontalTargetIndex = Math.round(verticalProgress * (horizontalGames.length - 1)); if (horizontalTargetIndex >= 0 && horizontalTargetIndex < horizontalGames.length) { onHorizontalGameChange(horizontalGames[horizontalTargetIndex].id); } }, [syncMode, verticalIndex, verticalGames.length, horizontalGames, onHorizontalGameChange]); const currentGames = activeTab === 'vertical' ? verticalGames : horizontalGames; const currentGame = activeTab === 'vertical' ? currentVerticalGame : currentHorizontalGame; const currentIndex = activeTab === 'vertical' ? verticalIndex : horizontalIndex; const onGameChange = activeTab === 'vertical' ? onVerticalGameChange : onHorizontalGameChange; const goToFirstGame = () => { if (currentGames.length > 0) { onGameChange(currentGames[0].id); } }; const goToLastGame = () => { if (currentGames.length > 0) { onGameChange(currentGames[currentGames.length - 1].id); } }; const goToPreviousGame = () => { if (currentIndex > 0) { onGameChange(currentGames[currentIndex - 1].id); } }; const goToNextGame = () => { if (currentIndex < currentGames.length - 1) { onGameChange(currentGames[currentIndex + 1].id); } }; const jumpToGame = (gameId: number) => { onGameChange(gameId); }; if (!currentGame) { return (
Jogo não encontrado
); } const TabButton: React.FC<{ type: 'vertical' | 'horizontal'; icon: React.ReactNode; label: string; count: number; }> = ({ type, icon, label, count }) => ( ); return (
{/* Header com tabs */}

Visualizador de Jogos

Navegue pelos jogos verticais e horizontais da sua estratégia

{/* Controle de sincronização */}
{/* Tabs */}
} label="Jogos Verticais" count={verticalGames.length} /> } label="Jogos Horizontais" count={horizontalGames.length} />
{/* Informações do jogo atual */}

Jogo {activeTab === 'vertical' ? 'Vertical' : 'Horizontal'} #{currentGame.id}

Fase {currentGame.phase} • Ciclo {currentGame.cycle}
Posição: {currentIndex + 1} de {currentGames.length} jogos
Progresso: {Math.round(((currentIndex + 1) / currentGames.length) * 100)}%

{activeTab === 'vertical' ? 'Colunas' : 'Linhas'} Marcadas

{(activeTab === 'vertical' ? currentGame.markedColumns : currentGame.markedRows!).map(pos => ( {pos} ))}
{/* Controles de navegação */}
{/* Barra de progresso */}
Progresso dos Jogos {activeTab === 'vertical' ? 'Verticais' : 'Horizontais'} {currentIndex + 1} / {currentGames.length}
{/* Controles avançados */}
{ const position = parseInt(e.target.value); if (position >= 1 && position <= currentGames.length) { const targetGame = currentGames[position - 1]; if (targetGame) { jumpToGame(targetGame.id); } } }} className="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent" placeholder={`1 a ${currentGames.length}`} />
{/* Grid do jogo atual */} {/* Comparação lado a lado (quando sync mode ativo) */} {syncMode && currentVerticalGame && currentHorizontalGame && (

Comparação: Vertical vs Horizontal

Jogo Vertical #{currentVerticalGame.id}

Jogo Horizontal #{currentHorizontalGame.id}

)}
); }; export default DualGameViewer;