Commit f5c4ffae authored by Dennis Willers's avatar Dennis Willers 🏀

Add README.md

parent 62c64d41
Pipeline #441 passed with stages
in 2 minutes and 44 seconds
# README
## Description
The project is the backend for the Openplanet Voting plugin on Trackmania. This stand is still in the early stages. With the plugin a player can give a rating to the currently driven map, see the average rating score and see how many players have voted for the track in total.
## Technical description
The client can connect to the socket server via `willers.digital` on port `3201`. After the first JSON request from the client the passed mapId is mapped on the client. All clients that are also mapped to the map will get all vote changes. The socket server communicates with the express REST server, which in turn communicates with the MySQL database. The socket server can tell from the request which REST service to invoke, so the client does not communicate directly with the REST service. Assuming the JSON request was submitted correctly
## REST Services
There are currently only two REST interfaces.
**POST /getMapInfo**<br>
Returns the current voting status for the current map.<br>
Example Request:
```
{
"mapId": "currentMapUId",
"userId": "UserLogin",
"name": "mapname for example: Summer 2021 - 01"
}
```
Info: I heard that the name is not really relevant, because the API of trackmania.io already provides information about a map. Nevertheless, in the current implementation this field should at least not be null.
**POST /setVote**<br>
Writes the vote of a player to the respective map into the database table.
Example Request:
```
{
"mapId": "currentMapUId",
"userId": "UserLogin",
"name": "mapname for example: Summer 2021 - 01",
"vote": 40
}
```
**POST RESPONSE**<br>
The response is the same in both cases:
```
{
"votes": 3,
"average": 63,
"vote": 80
}
```
If other players only listen to the current voting status on the map, the vote for the respective client is not returned, since this is client-specific and therefore not interesting for everyone. So for them the response will be like:
```
{
"votes": 3,
"average": 63
}
```
## Vote definition
As you can already see, you need to supply a number for the vote. The backend defines the votes as follows:
| Vote | Plugin
| -----|:--:|
| 100 | +++ |
| 80 | ++ |
| 60 | + |
| 40 | - |
| 20 | -- |
| 0 | --- |
## Star definition
The following star scale was defined for the voting plugin:
| Scale | Stars
| -----|:--:|
| 92-100 | 5 |
| 83-91 | 4.5 |
| 74-82 | 4 |
| 64-73 | 3.5 |
| 55-63 | 3 |
| 45-54 | 2.5 |
| 36-44 | 2 |
| 27-35 | 1.5 |
| 18-26 | 1 |
| 9-17 | 0.5 |
| 0-8 | 0 |
## Attention
My backend is really not secure for SQL-Injection and some other secure stuff. If some more people want to use it, I should protect it more.. but that take some time. You are welcome to help me with this. That would be a nice thing if we can introduce a global map vote functionality in a secure and highly available way. :)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment