From 07916b0d9360ececff6829c06c2f198f08222722 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tobias=20=C3=98rstad?= <tobiasio@ntnu.no>
Date: Fri, 17 Apr 2020 14:42:39 +0200
Subject: [PATCH] Fixed an issue where games werent progressing as planned

---
 backend/api/rounds.js     | 5 +++--
 backend/api/tournament.js | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/backend/api/rounds.js b/backend/api/rounds.js
index 5845172..0099185 100644
--- a/backend/api/rounds.js
+++ b/backend/api/rounds.js
@@ -449,7 +449,7 @@ function roundcheck(client, tournament, roundid) {
         // fetched the round objects of the active round
         let activePlayer;
         for (let i = 0; i < rounds.length; i++) {
-          if (rounds[i]._id === roundid) {
+          if (rounds[i]._id.str == roundid.str) {
             activePlayer = rounds[i].playerId;
             break;
           }
@@ -526,7 +526,8 @@ function roundcheck(client, tournament, roundid) {
                               tourny = result.value;
                               const game =
                                 tourny.games[
-                                  tourny.currentRound % tourny.games.length
+                                  (tourny.currentRound % tourny.games.length) -
+                                    1
                                 ];
                               const date = new Date();
                               date.setTime(
diff --git a/backend/api/tournament.js b/backend/api/tournament.js
index 18fba71..1a19561 100644
--- a/backend/api/tournament.js
+++ b/backend/api/tournament.js
@@ -512,7 +512,8 @@ function roundcheck(client, tournament) {
                               tourny = result.value;
                               const game = // Finds the next game of the round
                                 tourny.games[
-                                  tourny.currentRound % tourny.games.length
+                                  (tourny.currentRound % tourny.games.length) -
+                                    1
                                 ];
                               const date = new Date();
                               date.setTime(
-- 
GitLab