Gameserver, as the name suggests, is the game server of the EndangerEd platform. It acts as the mediator between the knowledge base and the game client, and works with the game client to manage scores and sessions. Moreover, the server is easily configurable through its web interface, providing a way for authorized users to edit its settings.
The game server uses Django as its framework and PostgreSQL as its database (on development use SQLite).
The purpose of the server can be divided into two sections.
Gameserver keeps track of players' session, which is a period where a game is currently ongoing. A session is created when a player starts the game, and lasts until it is over. When the latter happens, the client submits the total score to the server. The server then insert said score to the central scoreboard. In addition, the scoreboard data can be requested by the client to be displayed to the player.
The server provides a microgame metadata when the client requests one, so that it can compose it into a playable experience. It does this by using of the knowledge base's API and its own RESTful API. The process happens during a game session and can be described as follows:
- The server receives a request for a new microgame, and starts assembling a metadata.
- The server chooses an appropriate question.
- The server requests data from the knowledge base based on the question.
- The server fits the provided data into an appropriate pattern.
- The server sends the metadata back to the client.
On top of the above features, the server also provides a web interface for managing its settings. An authorized user can add or edit patterns and questions using the corresponding forms.
- Clone the repository to your machine using the following command:
git clone https://github.com/endangered-project/gameserver.git
- Navigate to the project folder.
- Create your own
.envfile based on the provided example. - Setup poetry on your machine by following the tutorial here.
- All poetry files are already provided, the only thing left is to properly setup poetry virtual environment.
- Create a poetry virtual environment:
poetry shell
- Install dependencies:
poetry install
- The project can now be run using the following command:
poetry run python manage.py runserver
Note : To run with knowledge base server, we recommend to run the game server on port 8001 by using the following command:
poetry run python manage.py runserver 8001
The example environment file already config the knowledge base server to run on port 8000.
python -m coverage run --source='.' manage.py test
python -m coverage html
See GitHub Project (or the old board).