You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

4 years ago
## scoreboard
### Objectives
You must follow the same [principles](../README.md) as the first subject.
4 years ago
For this project you must implement:
4 years ago
- **scoreboards**
- **go API service** that allows saving the data from the game in JSON format
- The API should accept POST and GET requests from the client side for the scoreboard data
4 years ago
### Instructions
Just like with the first subject you must respect performance.
4 years ago
In order to tell scores apart the player's name should be requested before submitting the score after the game has ended.
4 years ago
After every game, whether the player wins or loses, a scoreboard should be shown with the five highest scores.
4 years ago
For each score, the scoreboard must display **position**, **name**, **score**, **time** in minutes. Scores must be paginated. For the submitted score, the position percentile must be displayed.
4 years ago
For example:
```console
Congrats O.J, you are in the top 6%, on the 2nd position.
4 years ago
Rank| Name | Score | time
---------------------------
1st | Kave | 233254 | 12:01
2nd | A.J. | 222555 | 03:00
3rd | O.J. | 14356 | 05:40
4th | -.- | 13663 | 02:34
5th | iris | 2354 | 00:40
<- Page 1/50 ->
```
The scores should be displayed in descending order, so that the player with the most points appears on the first place.
4 years ago
You will have to create a **go API service**, where you can load the data (POST), and request it (GET). This service will store the information of each play (name, score, and time) in JSON format and return all the information when requested.
The data can be organized in JSON as you wish.
4 years ago
Here is an example:
```json
[
{
"name": "O.j.",
"Rank": 3,
"Score": 14356,
"time": "05:40"
},
{
"name": "Kave",
"Rank": 1,
"Score": 233254,
"time": "12:01"
},
....
]
```
### Allowed Packages
- Only [standard Go](https://golang.org/pkg/) packages are allowed.
- [Gorilla](https://pkg.go.dev/github.com/gorilla/websocket) websocket
4 years ago
This project will help you learn about:
4 years ago
- Creating and using an API
- POST requests
- GET requests
- JSON
- Sorting algorithms