Open fendor opened 6 years ago
How to implement that? There are 2 options:
I would aim at making illegal states impossible, as much as possible
Then, a description of the Model is reqired in plain text. From that, a suitable data structure can be derived
About making illegal states impossible: It seems hard and kind of impossible to actually do that since the state is determined at runtime. However, the identified states are as follow:
gameTicks
the state transition to Warmup is triggered.
First step of the refactoring has been implemented by #16
Explicit State
The
EventLoop.hs
is the core file for the Server Application. It manages multiple connections, it manages the communication, server updates, also whether the game has started, when a game is over, et cetera...These are a lot of responsibilities, and a lot of the message handling is dependent on the current state. However, the current state of the server and the various client connections are only present through implicit conversion of the current state variables.
My proposal would be, to refactor the server variables to include a more explicit state machine. Hence, messages should have it easier to determine the current state. It should even improve performance by avoiding costly variable analysis during handling a message.