Repository navigation
MatchManager class state machine
A match is defined as following:
- The match is a collection of turns.
- In each turn the players activate all their units once and they can respond with their units at maximum once. First goes red player, then blue player.
- When all the figures are activated, the match goes to the next turn and the unit status is reset.
The figure above shows the state transition diagram of the MatchManager class. This class has the main purpose of manage a whole match. The structure of the match is decomposed into a state machine.
An utility function buildMatchManager() is available to setup this object in the correct way: in this function is required to pass as argument the string value of the classes to instantiate. This is a consequence of the web interface and the interaction with humans.
The state machine begin with an initialization step. Then the first action is an update action. After that, the state machine goes in check mode: it checks the current status and decide where to go next. The possible outcomes are four: if there was a Shoot or Move action (but not a response), a response is possible; if there are still figures that can be activated, there will be a round step; if the goal of the scenario is achieved, then the match will end; otherwise, the only possible remaining state is a turn update. All other states step back to check with the exception of the end state.
The class offers some utility methods, as example:
-
nextStep()will move the state-machine forward of one step. -
nextTurn()will move the state-machine forward until the turn change (an update happens). -
play()to run a complete game without interruption or control until a winner is declared.
- Rules Players
- Match Structure
- Game Status
- Line of Fire (LOF) and Line of Sight (LOS)
- Actions
- Game Board