瀏覽代碼

Looking up score from the player list we're already fetching

Kirk Trombley 5 年之前
父節點
當前提交
d5bdbd333f
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      client/src/components/screens/RoundSummary/RoundSummary.jsx

+ 6 - 2
client/src/components/screens/RoundSummary/RoundSummary.jsx

@@ -122,7 +122,7 @@ const playerColors = {};
 
 export default () => {
   // get the info about the last round
-  const { roundNum, targetPoint, score, totalScore } = useLastRound();
+  const { roundNum, targetPoint } = useLastRound();
 
   // draw the map
   // TODO dynamically determine this zoom level?
@@ -140,7 +140,7 @@ export default () => {
 
   // live update the player scores
   const players = usePlayerScores()
-    ?.filter(({ guesses }) => guesses[roundNum] && guesses[roundNum].score);
+    ?.filter(({ guesses }) => guesses[roundNum] && guesses[roundNum].score !== null);
   useEffect(() => {
     if (!players) return;
     const drawings = [];
@@ -165,6 +165,10 @@ export default () => {
 
   // whether or not the game is done
   const [gameFinished] = useRoundInfo()
+
+  const playerInfo = players?.find(({ name }) => name === playerName);
+  const score = playerInfo?.guesses?.[roundNum]?.score ?? 0;
+  const totalScore = playerInfo?.totalScore ?? 0;
   
   return (
     <Container>