Skip to content
Snippets Groups Projects
Commit ac21d8c2 authored by Tobias Ørstad's avatar Tobias Ørstad
Browse files

Fixed bug where roundnr of new rounds were 1 higher than actual. Added extra validation

parent 906c2560
No related branches found
No related tags found
No related merge requests found
...@@ -411,7 +411,7 @@ router.put("/:roundid/:tournamentid", (req, res) => { ...@@ -411,7 +411,7 @@ router.put("/:roundid/:tournamentid", (req, res) => {
db.collection(collection) db.collection(collection)
.findOneAndUpdate( .findOneAndUpdate(
{ _id: id }, { _id: id, scoreValue: 0, hasPlayed: false },
{ $set: { scoreValue: scoreValue, hasPlayed: true } }, { $set: { scoreValue: scoreValue, hasPlayed: true } },
{ returnOriginal: false } { returnOriginal: false }
) )
...@@ -451,7 +451,7 @@ function roundcheck(tournament) { ...@@ -451,7 +451,7 @@ function roundcheck(tournament) {
checkRounds(tournament, active).then(result => { checkRounds(tournament, active).then(result => {
if (!result) { if (!result) {
resolve("Round " + active + " in progress"); //1. check if other rounds are done resolve("Score updated. Round " + active + " in progress"); //1. check if other rounds are done
} else { } else {
fetchRounds(tournament, active).then(rounds => { fetchRounds(tournament, active).then(rounds => {
players = rounds.length; players = rounds.length;
...@@ -473,13 +473,13 @@ function roundcheck(tournament) { ...@@ -473,13 +473,13 @@ function roundcheck(tournament) {
tournament, tournament,
tourny.players[i], tourny.players[i],
game, game,
tourny.currentRound + 1, tourny.currentRound,
date date
); );
} }
resolve(tourny); resolve(tourny);
} else { } else {
resolve("Tournament over"); resolve("Score updated. Tournament over");
} }
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment