Located under server/Mafia
All of the game logic and the bulk of the project work is encapsulated in the game engine code.
Encapsulate logic and maintain separation of concerns.
In-depth gameplay and extensible game mechanics.
Consistent and balanced gameplay.
Narrow connection with Socket.IO
Automatic placement of players into open games.
The key components of the game engine are diagrammed below.
Responsible for managing open games and connected players. Creates new game lobby if a player connects and there is no open game. Spawns Game Lobbies.
Responsible for managing all connected users, generating their names, and mapping sockets to user objects.
Responsible for managing unique Socket.io namespace for the game, and for adding/removing players. One instance per game.
Spawned by Game Lobby. Responsible for game state, player states, and game mechanics resolution.
Responsible for interfacing with Socket.io and relaying commands/chat messages within the game's namespace to GameEngine instance.
Responsible for containing player info and state. Initialized with role. Exposes interface for action interaction.
Responsible for maintaining the public state for each player. The public state is the data that will be pushed out to each player's client when the state changes.
Responsible for the actions priority queue. Queues up actions as they occur at night, then resolves actions at end of turn. Actions called during day with "immediate" flag will be resolved immediately.
Role objects are located under ./roles They serve to define the state, win conditions, and actions of a role.
An object for defining configuration parameters, can be instantiated for each game to configure the game. This class needs work.