You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

4 years ago
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';
type GameProps = {
onExitGame: () => void,
};
const GamePage: React.FC<GameProps> = (props) => {
const {onExitGame} = props;
const clickAtWitch = (guid: string) => {
apiStore.turn(guid)
.then((result) => console.log('check whether witch is lucky: ' + guid + ' // ' + result));
}
return (
<header className="App-header">
<div className='game'>
<div>Score: {apiStore.currentGame?.score}</div>
<div>Version: {apiStore.version}</div>
<div className="witch-row">
4 years ago
{
_.map(apiStore.currentGame?.witches, (item: Witch, index: number) => {
const left = item.position * 100;
return (
<div key={index} className='witch' style={{ left }}>
4 years ago
<img src={witch} alt={`witch-${index}`} onClick={() => clickAtWitch(item.guid)}/>
</div>
)
})
}
</div>
</div>
<h1 onClick={() => onExitGame()}> Стоп игра! </h1>
<div>
<label htmlFor='hasServer'>У меня, кажется, есть свой сервер!</label>
<input
type='checkbox'
id='hasServer'
checked={!apiStore.mockMode}
value='1'
onChange={(e) => apiStore.tryToSetMockMode(e.target.checked) }
/> </div>
4 years ago
</header>
);
}
export default GamePage;