Merge pull request #4 from jhalitaksoy/feature/random-user-turn

add random user turn when game started
This commit is contained in:
Halit Aksoy 2022-07-09 17:12:36 +03:00 committed by GitHub
commit f0d36a9095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,6 +112,9 @@ const deleteGame = (game: MancalaGame) => {
function createMancalaGame(userKey1: string, userKey2: string) {
const game = new CommonMancalaGame(generateKey(), userKey1, userKey2);
const random = Math.random();
game.turnPlayerId = random > 0.5 ? userKey1 : userKey2;
gameStore.set(userKey1, game);
gameStore.set(userKey2, game);
return game;