Program Design
Event Driven
The wargame program is event driven.
Mouse events are processed as a game event according to the wargame's current phase and mode.
Wargame Event Table processing events in javascript
| Wargame Phase | Wargame Mode | Game Event from Mouse Down event |
|---|---|---|
| Moving | Ready to start moving | click on units starts moving |
| Moving | Moving | click on map moves unit |
| Moving | Moving | click on unit stops moving |
| Moving | Ready to start moving | click on Next Phase button changes wargame phase |
| Combat | Combat setup | click on defending unit starts combat |
| Combat | Combat setup | click on attacking unit sets up combat |
| Combat | Combat setup | click on defending unit starts combat |
| Combat | Combat setup | click on Next Phase button changes wargame phase |
| Combat Resolution | Combat resolution | click on defending unit resolves combat |
| Combat Resolution | Combat resolution | click on Next Phase button changes wargame phase |
| Retreating | Ready to start retreating | click on defending unit starts retreat |
| Retreating | Retreating | click on map, unit retreats |
| Advancing | Ready to start advancing | click on attacking unit |
| Advancing | Advancing | click on map, unit advances |
Wargame map and counters
Images are used to display the wargame map and counters. Each counter has an unique id.
Terrain and Force Objects
The wargame program contains 2 objects ( Terrain and Force ) to store wargame data and functionality.
3 additional objects ( GameRules, MoveRules, and CombatRules ) contain the sequence of play and rules of play.
Note: the MAP is the image, the TERRAIN is the data ( a hexpart number links the two )
A mouse click on the map image will resolve to a hexpart number, which will be used by the Terrain object to return terrain information, terrain effects on movement and combat.
Note: COUNTERS are images, FORCE is the data ( a unit id links the two )
A mouse click on a counter image will return the id of the image, which will be used by the Force object to return unit information, movement and combat methods.