import { Button } from "./Button"; import Timer from "./Timer"; import explosion from "./sound/explosion.mp3"; import useGameStore from "./GameState"; import { useEffect, useState } from "react"; import useSound from "use-sound"; import { loseGame } from "./ws"; import toast, { useToasterStore } from "react-hot-toast"; interface Score { user: string; stage: number; } function useMaxToasts(max: number) { const { toasts } = useToasterStore(); useEffect(() => { toasts .filter((t) => t.visible) // Only consider visible toasts .filter((_, i) => i >= max) // Is toast index over limit? .forEach((t) => toast.dismiss(t.id)); // Dismiss – Use toast.remove(t.id) for no exit animation }, [toasts, max]); } function App() { const game = useGameStore(); const [scores, setScores] = useState([]); const [playSound] = useSound(explosion, { volume: 0.5, }); useEffect(() => { if (game.isGameOver) { playSound(); loseGame(game.name, game.stage); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [game.isGameOver]); useEffect(() => { game.resetGame(4, 4, 2); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { fetch("https://mb.gordon.business") .then((res) => res.json()) .then((data) => { setScores(data); }); const i = setInterval(() => { fetch("https://mb.gordon.business") .then((res) => res.json()) .then((data) => { setScores(data); }); }, 2000); return () => clearInterval(i); }, []); useMaxToasts(5); return (
{import.meta.env.DEV && ( )}

Minesweeper Endless{" "}

Name:{" "} game.setName(e.target.value)} />

Feed:{" "}

{scores.slice(0, 10).map((score) => (

{score.user} - {score.stage}

))}
{game.mines[0].map((_, y) => game.mines.map((_, x) => (
Version: 1.1.6
          Made by MasterGordon -{" "}
          
            Source Code
          
        
); } export default App;