Wargame Project Design
The wargame is driven by mouse events.
The map mouse move event return a hexagon name on the hexagon map. The counter mouse move event returns the counter identifier and its status. The hexagon name is calculated from the hexagon point location with the hexagon name calculator.
The map and counter mouse down events send data to the command generator. The data contains an object identifier and a hexagon location. The hexagon point location is calculated from the screen coordinates with the hexagon point calculator. The hexagon location is a x,y coordinate on the hexagon grid.
The command generator converts the event data into a game command according to the wargames game turn, phase and game mode. This is the sequence of play.
map click → units are moving → move
counter click → units are not moving → start moving
counter click → units are moving and moving unit → stop moving
counter click → units are moving and not moving unit → move over
button click → no units moving → next phase
counter click → defender → start combat
counter click → attacker and defender selected → join combat
counter click → attacker and attacking → undo combat join
counter click → defender with attackers → resolve combat
button click → no combat → next phase
Move rules process: start move, move, move over and stop move. Move rules use a move calculator to compute : calculate move cost, get entrance move cost, move is in range, move is traverse, move is valid, move will cause stop, retreat is valid, retreat is stopped, terrain is prohibited, unit has move amount available, unit will use max move.
Combat rules process: setup defender, setup attacker, combat resolution. Combat rules use a combat results table to resolve combat and a combat calculator to apply combat results.
Victory rules process: check victory conditions and use a victory calculator.
Rules use wargame calculators:
line of sight calculator to calculate range, facing, target angle and los
grid point calculator to calculate adjacent hexagons and hexsides
zone of control calculator to calculate enemy zones of control
stacking calculator to calculate unit stacking requirements in a hexagons
loc calculator to calculate lines of communication
Data is managed by the wargame, force and terrain objects.
Counter are drawn using a SVG (scalable vector graphics) counter generator.