Просмотр исходного кода

Removing everything that's not actually needed from the lastRound object

Kirk Trombley 5 лет назад
Родитель
Сommit
cf5cf12d76

+ 1 - 1
client/src/components/screens/GamePanel/GamePanel.jsx

@@ -46,7 +46,7 @@ const GamePanelContainer = () => {
 
   const handleSubmitGuess = async () => {
     setSubmitDisabled(true);
-    await dispatch.submitGuess(selectedPoint);
+    await dispatch.submitGuess(selectedPoint, currentRound, targetPoint);
   }
 
   return (

+ 1 - 1
client/src/components/screens/RoundSummary/RoundSummary.jsx

@@ -125,7 +125,6 @@ export default () => {
   const { roundNum, targetPoint } = useLastRound();
 
   // draw the map
-  // TODO dynamically determine this zoom level?
   const mapDivRef = useRef(null);
   const mapRef = useMap(mapDivRef, targetPoint.lat, targetPoint.lng, 4);
 
@@ -166,6 +165,7 @@ export default () => {
   // whether or not the game is done
   const [gameFinished] = useRoundInfo()
 
+  // look up the score for last round and the total score
   const playerInfo = players?.find(({ name }) => name === playerName);
   const score = playerInfo?.guesses?.[roundNum]?.score ?? 0;
   const totalScore = playerInfo?.totalScore ?? 0;

+ 6 - 11
client/src/domain/gameStore.js

@@ -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,
     });