import { useState } from 'react';
import { initCells, PLAYER_DEF } from '../utils/constants';

const useGameState = () => {
  const [webPlayer, setWebPlayer] = useState(null);
  const [activePlayer, setActivePlayer] = useState(false);
  const [overlay, setOverlay] = useState(true);
  const [overlayTitle, setOverlayTitle] = useState('');
  const [overlaySubTitle, setOverlaySubTitle] = useState('');
  const [mines, setMines] = useState(51);
  const [bombSelected, setBombSelected] = useState(false);
  const [foundMines, setFoundMines] = useState(false);
  const [red, setRed] = useState({ ...PLAYER_DEF });
  const [blue, setBlue] = useState({ ...PLAYER_DEF });
  const [cells, setCells] = useState(initCells);
  const [gridReady, setGridReady] = useState(false);
  const [connectionLost, setConnectionLost] = useState(false);

  return {
    webPlayer, setWebPlayer,
    activePlayer, setActivePlayer,
    overlay, setOverlay,
    overlayTitle, setOverlayTitle,
    overlaySubTitle, setOverlaySubTitle,
    mines, setMines,
    bombSelected, setBombSelected,
    foundMines, setFoundMines,
    red, setRed,
    blue, setBlue,
    cells, setCells,
    gridReady, setGridReady,
    connectionLost, setConnectionLost,
  };
};

export default useGameState;
