Implementation details.

This commit is contained in:
Marvin Blum
2022-11-22 15:13:31 +01:00
parent 95829378f6
commit b4baf65997
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# Implementation
This document goes into detail about the implementation of the game and the tech-stack used.
## Tech-Stack
* Vue for the frontend (except for the tilemap)
* Go for the backend
* gorilla/websocket for real time connections
* Postgres
## Architecture and Networking
Ecosim uses a simple client-server architecture where the client runs in the browser and is connected to the server using a web socket. The client only connects to running games using a web socket. A REST API is used for everything else, like the registration, login, setting up a game, and so on.
Should a player join a running game, for example after losing the connection, the game will be paused until the client has catched up to the current state of the game. The state is simply represented by the current ingame date and time (timestamp).
Games are started by a player and automatically closed and saved when the last player leaves. It's possible to configure this behavior. When a new game is created the player can decide whether he would like to wait for all players to be present, pause the game when someone loses the connection, or make it open so that player can hot join and leave whenever they want. Games can be protected by passwords and are browsed on a global list.
The server and client communicate through a simple TCP (web socket) and JSON protocol. The client receives updates to the game state and sents commands that are validated on the server. This will prevent anyone from cheating. The state updates contain the current ingame date and time (timestamp), that can be used to validate that no state updates are missing. While the game is running a new state will only be produced once a tick has been calculated. The game speed can be configured when creating a game. The default will be set to one ingame hour = one second, so 24 seconds represent a ingame single day.
### Authentication
For authentication oAuth with a refresh token will be used. Clients need to authenticate themselves when connecting to a game.