From 1b1c20931c8b48ff107dd176c7206ebbbad398a8 Mon Sep 17 00:00:00 2001 From: Eric Zhang Date: Thu, 4 Feb 2021 10:37:33 -0500 Subject: [PATCH] Fix finishGame function bug for pre-update games --- functions/src/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index d9939b0..7b5777e 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -41,12 +41,11 @@ export const finishGame = functions.https.onCall(async (data, context) => { .database() .ref(`games/${gameId}/mode`) .once("value"); - const { lastSet, deck, finalTime } = replayEvents( - gameData, - gameModeRef.val() - ); + const gameMode = gameModeRef.val() || "normal"; + + const { lastSet, deck, finalTime } = replayEvents(gameData, gameMode); - if (findSet(Array.from(deck), gameModeRef.val(), lastSet)) { + if (findSet(Array.from(deck), gameMode, lastSet)) { throw new functions.https.HttpsError( "failed-precondition", "The requested game has not yet ended."