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 PhaseWargame ModeGame Event from Mouse Down event
MovingReady to start movingclick on units starts moving
MovingMovingclick on map moves unit
MovingMovingclick on unit stops moving
MovingReady to start movingclick on Next Phase button changes wargame phase
CombatCombat setupclick on defending unit starts combat
CombatCombat setupclick on attacking unit sets up combat
CombatCombat setupclick on defending unit starts combat
CombatCombat setupclick on Next Phase button changes wargame phase
Combat ResolutionCombat resolutionclick on defending unit resolves combat
Combat ResolutionCombat resolutionclick on Next Phase button changes wargame phase
RetreatingReady to start retreatingclick on defending unit starts retreat
RetreatingRetreatingclick on map, unit retreats
AdvancingReady to start advancingclick on attacking unit
AdvancingAdvancingclick 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.