import { motion } from 'framer-motion'; import { Link } from 'react-router-dom'; import GlitchText from '@/components/GlitchText'; import { useState, useEffect } from 'react'; const HIGHSCORE_KEYS = { tetris: 'tetris-highscore', pacman: 'pacman-highscore', snake: 'snake-highscore', breakout: 'breakout-highscore', }; const MAX_SCORE = 4294967296; const Leaderboard = () => { const [scores, setScores] = useState({ tetris: 0, pacman: 0, snake: 0, breakout: 0, }); useEffect(() => { const tetrisScore = localStorage.getItem(HIGHSCORE_KEYS.tetris); const pacmanScore = localStorage.getItem(HIGHSCORE_KEYS.pacman); const snakeScore = localStorage.getItem(HIGHSCORE_KEYS.snake); const breakoutScore = localStorage.getItem(HIGHSCORE_KEYS.breakout); setScores({ tetris: tetrisScore ? Math.min(parseInt(tetrisScore, 10), MAX_SCORE) : 0, pacman: pacmanScore ? Math.min(parseInt(pacmanScore, 10), MAX_SCORE) : 0, snake: snakeScore ? Math.min(parseInt(snakeScore, 10), MAX_SCORE) : 0, breakout: breakoutScore ? Math.min(parseInt(breakoutScore, 10), MAX_SCORE) : 0, }); }, []); const totalScore = scores.tetris + scores.pacman + scores.snake + scores.breakout; const gameCards = [ { id: 'tetris', name: 'Tetris', score: scores.tetris, icon: `▓▓ ▓▓██ ████`, }, { id: 'pacman', name: 'Pac-Man', score: scores.pacman, icon: `◗ ᗣ · ·`, }, { id: 'snake', name: 'Snake', score: scores.snake, icon: `●■■ ■◆`, }, { id: 'breakout', name: 'Breakout', score: scores.breakout, icon: `████ ● ═══`, }, ]; return (
{'<'} Back

{/* Total Score */}

COMBINED TOTAL

{totalScore.toLocaleString()}

Target: 4,294,967,296 × 4 = 17,179,869,184

{/* Game Scores */}
{gameCards.map((game, index) => (
                  {game.icon}
                

{game.name}

HIGH SCORE

{game.score.toLocaleString()}

{((game.score / MAX_SCORE) * 100).toFixed(6)}% to max

))}

{'>'} Click a game to play and improve your score

); }; export default Leaderboard;