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

Merge branch '95-backend-cleanup' into 'dev'

Made sure players can only join tournaments that have not gone past the starttime

Closes #95

See merge request !103
parents e5af89e0 b76fd9a7
No related branches found
No related tags found
2 merge requests!104Dev,!103Made sure players can only join tournaments that have not gone past the starttime
...@@ -220,6 +220,8 @@ router.post("/join", (req, res) => { ...@@ -220,6 +220,8 @@ router.post("/join", (req, res) => {
active: true, active: true,
// the array of players cannot already contain the player // the array of players cannot already contain the player
players: { $nin: [playerId] }, players: { $nin: [playerId] },
// we dont want tournaments that have gone past their starttime
startTime: { $gte: new Date() },
}, },
// Add the player to the array // Add the player to the array
{ {
...@@ -500,6 +502,17 @@ function roundcheck(client, tournament) { ...@@ -500,6 +502,17 @@ function roundcheck(client, tournament) {
//if there are less then two people left in the first round, or zero people left in the first round //if there are less then two people left in the first round, or zero people left in the first round
//the tournament ends //the tournament ends
} }
if (rounds.length > 0) {
// If there is only one player in the tournaments first round and the starttime
// has expired, we end the tournament
if (
left.length < 2 &&
active == 1 &&
new Date(start) < new Date()
) {
end = true;
}
}
functions functions
.timeOut(client, tournament, timedOut, timedOutRounds) .timeOut(client, tournament, timedOut, timedOutRounds)
.then( .then(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment