Environment Server - LSFN/Design GitHub Wiki

The environment server manages all of the game's state. It knows about everything in the universe and is responsible for its simulation. I/O is mainly received from / sent to ship servers, the remainder being through the environment's CLI.

Game States

The first game format we support is session based games. At the highest level, the game consists of four states:

  1. Lobby
  2. Setup
  3. Play
  4. Wind-down

Lobby

In this state, the environment will listen for new connections from ships and add them to the lobby. The environment will receive from ships information about how the ships and the game universe are to be set up before play begins. Once all ships have sent a signal to indicate their readiness, the game may begin.

Setup

In this phase, the environment performs all setup of the game universe that it needs to perform and sends any information that the ships require to them. If connections to ships are lost in this phase, the environment shall listen for their reconnection and resume at the setup phase. Only once all ships have indicated that they have received all the information they require in this phase does the game begin. If disconnected ships remain disconnected for too long, then the game returns to the lobby state.

Play

The game is played in this phase. The game can end on any condition specified in the lobby phase. If connections to ships are lost in this phase, the environment shall pause the game and listen for their reconnection. If disconnected ships remain disconnected for too long, the remaining ships are asked if the game should proceed without them. All ships must agree to either continue or return to the lobby phase before anything happens. If during this decision, the disconnected SHIP(s) reconnect, the game of course proceeds.

Cleanup

The results of the game are passed to the ships, and system resources used by the game are cleared up for the next game. Once this is done, the environment automatically enters the lobby phase and with all the still connected ships.