|
|
Endpoint: POST url/api/tournament/new
|
|
|
### POST url/api/tournament/new
|
|
|
|
|
|
Creates a new tournament.
|
|
|
|
|
|
body:
|
|
|
```json
|
|
|
{
|
|
|
"playerId": (String, must be a valid MongoDB ID),
|
|
|
"games": (String, on the form: "[gameId1,gameId2,...]"),
|
|
|
"name": (String),
|
|
|
"timePerRound": (Int),
|
|
|
"maxPlayers": (Int),
|
|
|
"roundsPerGame": (Int)
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### POST url/api/tournament/join
|
|
|
|
|
|
Joins the oldest tournament stil active and on round 1.
|
|
|
|
|
|
body:
|
|
|
```json
|
|
|
{
|
|
|
"userid": userid,
|
|
|
"games": [gameids],
|
|
|
"name": name,
|
|
|
"timePerRound": timePerRound,
|
|
|
"maxPlayers": maxPlayers,
|
|
|
"roundsPerGame": roundsPerGame
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
"playerId": (String, must be a valid MongoDB ID)
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### GET uri/api/tournaments/playeractive/:playerId
|
|
|
|
|
|
Parameters:
|
|
|
* playerId (String, must be a valid MongoDB ID)
|
|
|
|
|
|
Returns all the tournaments a player is a part of on the form:
|
|
|
```json
|
|
|
[
|
|
|
{
|
|
|
"_id": (String, valid MongoID),
|
|
|
"players": (Array[String, valid MongoID]),
|
|
|
"games": (Array[String, valid MongoID]),
|
|
|
"name": (String),
|
|
|
"timePerRound": (Int),
|
|
|
"maxPlayers": (Int),
|
|
|
"roundsPerGame": (Int),
|
|
|
"currentRound": (Int),
|
|
|
"dateCreated": (String, valid date),
|
|
|
"active": (Boolean),
|
|
|
"currentPlayers": (Int),
|
|
|
"totalGames":(Int)
|
|
|
}
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### GET uri/api/tournaments/playeractive/:playerId/:active
|
|
|
|
|
|
Parameters:
|
|
|
* playerId (String, must be a valid MongoDB ID)
|
|
|
* active (Boolean)
|
|
|
|
|
|
Returns all the tournaments a player is a part of with an active field that matches the active-parameter:
|
|
|
```json
|
|
|
[
|
|
|
{
|
|
|
"_id": (String, valid MongoID),
|
|
|
"players": (Array[String, valid MongoID]),
|
|
|
"games": (Array[String, valid MongoID]),
|
|
|
"name": (String),
|
|
|
"timePerRound": (Int),
|
|
|
"maxPlayers": (Int),
|
|
|
"roundsPerGame": (Int),
|
|
|
"currentRound": (Int),
|
|
|
"dateCreated": (String, valid date),
|
|
|
"active": (Boolean),
|
|
|
"currentPlayers": (Int),
|
|
|
"totalGames":(Int)
|
|
|
}
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### POST url/api/tournament/roundcheck
|
|
|
|
|
|
Updates the state of the tournament with matching ID.
|
|
|
Does the following:
|
|
|
* Checks if all rounds are done.
|
|
|
* If rounds are not done, returns a 204 statusmessage.
|
|
|
* If rounds are done, tournamentPoints are updated for all players.¨
|
|
|
* If tournament is done, returns a 200 statusmessage.
|
|
|
* If not new rounds are created for all players, the tournaments active round is increased, the OLD tournament object is then returned.
|
|
|
|
|
|
|
|
|
body:
|
|
|
```json
|
|
|
{
|
|
|
"tournamentId": (String, valid Mongo ID)
|
|
|
}
|
|
|
```
|
|
|
|