Hi there,
(post edited to not hijack the thread)
TL;DR: Let pieces and module calculate odds and resolve combats automatically.
Edit: From a users perspective: Select attacking and defending pieces (Ctrl-click) and then press Ctrl-X
- places battle marker (number) and odds marker. Select odds marker and then Ctrl-Y
to resolve the battle - replaces odds marker with result marker. Users implement result. If you want to see it in action, I suggest you take BattleForMoscow-ch-1.0.vmod
and try it out - perhaps via the tutorial.
For some of the modules I did, I chose a somewhat different strategy for battle resolutions. See
The first two has tutorials that show the usage. I plan to add a tutorial to D-Day - Smithsonian Edition soon.
The strategy is to have the module calculate odds and combat results automatically while taking the rules of the game into account.
The strategy is roughly as follows
- Individual “battle pieces” have static properties (
MarkTrait
) CF
and DF
for Combat (or attack) and Defend factors.
- They have the prototype
BattleUnit
.
- This prototype has
GlobalPropertiesTrait
s to add their CF
or DF
to the total CF
or DF
, respectively, via TriggerTrait
s.
- The prototype has a
DynamicPropertyTrait
s to set the current battle number
- It can also place a Battle marker on the unit (
PlaceTrait
)
TriggerTrait
to set global odds shift
- and other infrastructure traits
- Each “battle piece” can also calculate, via
CalculatedPropertyTrait
its effective CF
and DF
. For example, a unit in an escarpment in Afrika Korps has it’s DF doubled, or a reduced unit in Battle for Moscow
has both its CF and DF halved.
- Each unit can also determine if there’s an odds shift. For example, in Battle for Moscow if all attackers are attacking over a river hex-side, then the odds are reduced by one.
- When a faction (player) selects attacking and defending units and trigger the
GlobalKey
“declare battle” - tied to the key Ctrl-X
, then all selected units will get a battle marker (PlaceTrait
which places a battle marker piece).
- This then triggers each of the selected units to update the total
CF
and DF
. Which one to update for a given piece is decided by comparing the pieces Faction
property (MarkTrait
) to the current phase name (via the TurnTracker
). For example, in D-Day - Smithsonian Edition, Allied pieces are considered attackers if the phase name contains the (sub)string Allied
, and German units are then considered defenders.
- At the same time, any
CF
or DF
modifiers are determined (CalculatedTrait
). For example, in Afrika Korps if a defending piece is in an escarpment hex, its EffectiveDF
is twice the base DF
. To determine if a unit is in an escarpment, the modulle checks if the units current LocationName
is in the GlobalProperty
EscarpmentHexes
(hex names in that string are separated by :
, and the module checks if ":"+LocationName+":"
appears in the GlobalProperty
)
- Odd shifts are also calculated. In Battle for Moscow, the current defending hex and current attacker hex is compared against a fixed list (
GlobalProperty
) of hex-to-hex edges that have a river. The module assumes an “across-river” attack, but if any attacking unit is not attacking across a river hex side, then the attack is no “across-river” (i.e., no odds shift).
- At the end of this process, the odds are calculated and any odds shift applied. This is done by a “hidden” piece (a piece with size 1x1 with a transparent image placed at pixel coordinates
(0,0)
).
- The first of the selected “battle units” then gets an odds marker added to it (
PlaceTrait
of an odds piece).
- If the faction then selects the odds marker and trigger the Resolve action (tied to
Ctrl-Y
), then the battle marker rolls a die (or two for D-Day - Smithsonian Edition) via a GlobalKeyCommandTrait
, takes the die roll and current odds and determines the combat result (CalculatedTrait
).
- The odds marker then replaces it self with a result marker
It is now up to the factions (players) to implement the result of the battle - the modules does not do that on its own.
If you want to see how the calculations goes, you can turn on Debug messages
in the games preferences (File → Preferences → Game name). One can also turn off these features from the same place, in which case factions can place odds and result markers themselves.
With this strategy, the factions do not need to calculate total CF and DF themselves, and the battles results are resolved on request. The strategy can be somewhat generalised so that the underlying code can be reused across modules.
What it requires is that
- units have proper
CF
and DF
MarkTrait
- Prototypes that can modify these according to the game rules. For example, in D-Day - Smithsonian Edition, the prototype
armoured
adjusts the CF
by -1 if attacking a woods hex.
- Global properties to look up hex features (terrain, etc.)
- Judicial use of the the
TurnTracker
.
This can all be a bit challenging when using the VASSAL editor because one often needs somewhat complicated BeanShell expressions. I therefore use my Python module pywargame
to do all this. In fact, since I have generally first made a Print’n’Play version of the game using LaTeX, I already have much of the information (Edit: in a machine readable format), such as unit CF and DF, unit types (infantry
, armoured
, artillery
, etc), unit echelon (brigade
, platoon
, army
,etc), and so on. If you want to see how I do that, you can find the sources at the below URLs
The order above is not only alphabetic but also reflects the complexity of the code (Afrika Korps is the least complicated, and D-Day - Smithsonian Edition the most. The latter has two kinds of attacks - strategic bombing, which directly effects the other kind of attack: land combat).
Sorry it got a bit long. The strategy is relatively straight forward, but the implementation does requires a bit of jumping through hoops. I’m not sure I entirely captured the thinking in the above. Anyways, take a look at one of the module above, and if you have questions, do not hesitate to ask 
Edit:
I have yet to play a wargame where I wasn’t able to calculate battle odds within about 3-5 seconds in my head
I’m sure people have made mistakes in calculating odds (I certainly have) giving themselves or the opponent a benefit at a crucial moment in the game. This minimizes the chance or risk of that. Also, I believe, it helps novice players get started since they need not remember all the various modifiers.
… or worth the effort to implement it.
As I say above, the whole thing can be generalised somewhat, and so the effort to implement it for a given game is really not that big - not least because I go via Python to generate the modules. However, some games (e.g., Port Stanley) has rather complex rules that will be a little more tricky to capture. But I guess if one is used to playing SPI mammoth games, calculating odds, etc. isn’t a big issue 
Yours,
Christian