import _ from 'lodash'; // @ts-ignore import witch from '../../resources/witch.svg'; import './GamePage.css'; import { Witch } from '../../model/Witch'; import apiStore from '../../store/apiStore/apiStore'; import { useState } from 'react'; type GameProps = { onExitGame: () => void, }; const GamePage: React.FC = (props) => { const {onExitGame} = props; const [state, setState] = useState(0); const clickAtWitch = (guid: string) => { apiStore.turn(guid) .then((result) => { setState(result ? 1 : 2); setTimeout(() => { setState(0); }, 300); }); }; return (
Score: {apiStore.currentGame?.score}
{ _.map(apiStore.currentGame?.witches, (item: Witch, index: number) => { const left = item.position * 100; const top = 100; return (
{`witch-${index}`} clickAtWitch(item.guid)}/>
) }) }
Version: {apiStore.version}

onExitGame()}> Стоп игра!

apiStore.tryToSetMockMode(e.target.checked)} />
); } export default GamePage;