|
@@ -1,6 +1,6 @@
|
|
|
import { PRE_GAME, PRE_ROUND, IN_ROUND, POST_ROUND, POST_GAME } from "./GameState";
|
|
|
import { createStore } from "../store";
|
|
|
-import { createGame, joinGame, sendGuess, getCurrentRound } from "./apiMethods";
|
|
|
+import { createGame, joinGame, sendGuess } from "./apiMethods";
|
|
|
|
|
|
export const [
|
|
|
{
|
|
@@ -20,8 +20,6 @@ export const [
|
|
|
lat: 0,
|
|
|
lng: 0,
|
|
|
},
|
|
|
- score: -1,
|
|
|
- totalScore: -1,
|
|
|
},
|
|
|
gameJoined: false,
|
|
|
gameState: PRE_GAME,
|
|
@@ -40,22 +38,19 @@ export const [
|
|
|
set({ gameJoined: true });
|
|
|
},
|
|
|
startRound: ([set]) => set({ gameState: IN_ROUND }),
|
|
|
- submitGuess: async ([set, get], selectedPoint) => {
|
|
|
+ submitGuess: async ([set, get], selectedPoint, roundNum, targetPoint) => {
|
|
|
const gameId = get.gameId();
|
|
|
const name = get.playerName();
|
|
|
- const { currentRound, coord } = await getCurrentRound(gameId, name);
|
|
|
- const { score, totalScore } = await sendGuess(
|
|
|
+ await sendGuess(
|
|
|
gameId,
|
|
|
name,
|
|
|
- currentRound,
|
|
|
+ roundNum,
|
|
|
selectedPoint || { timeout: true }
|
|
|
);
|
|
|
set({
|
|
|
lastRound: {
|
|
|
- roundNum: currentRound,
|
|
|
- targetPoint: coord,
|
|
|
- score,
|
|
|
- totalScore,
|
|
|
+ roundNum,
|
|
|
+ targetPoint,
|
|
|
},
|
|
|
gameState: POST_ROUND,
|
|
|
});
|