// --------------------------------------------------------------------------------------------------------------------- //! Imports // --------------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------ React -------------------------------------------------------- import { useState } from 'react'; // --------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------- Context ------------------------------------------------------- import { useRecoilState } from 'recoil'; import { gameStateAtom } from '../../contexts/gameState'; // --------------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------ Hooks -------------------------------------------------------- import { useActions } from './hooks/useActions'; // --------------------------------------------------------------------------------------------------------------------- // ------------------------------------------------------ Utils -------------------------------------------------------- import { genGrid } from '../../utils/generation'; import { getCellDisplayContent } from '../../utils/gameInteractions'; // --------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------- Assets -------------------------------------------------------- import Podium from '../../assets/podium'; import './styles.scss'; // --------------------------------------------------------------------------------------------------------------------- const Grid = () => { const [gameState, setGameState] = useRecoilState(gameStateAtom); const [grid, setGrid] = useState(genGrid(gameState.gridSize)); const { handleLeftClick, handleRightClick } = useActions(grid, setGrid, gameState, setGameState); return (
{grid.map((row, rowIndex) => (
{row.map((cell, cellIndex) => { return ( ); })}
))} {gameState.endType !== '' && (

{gameState.endType === 'win' ? 'Gagné !' : 'Perdu !'}

)}
); }; export default Grid;