diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-09-30 22:12:12 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-01 16:11:22 +0200 |
commit | 3e21ce78e400306dddf8ab0c90ac9fb86fe55094 (patch) | |
tree | 99220d9437fca9981b676dac00fd1fcd3ceb6a8c /rules.js | |
parent | 9bc1b871555682d201983c54a4d644b59f9853ae (diff) | |
download | waterloo-campaign-1815-3e21ce78e400306dddf8ab0c90ac9fb86fe55094.tar.gz |
Clean up play.js and show running VP totals.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 50 |
1 files changed, 29 insertions, 21 deletions
@@ -1,7 +1,5 @@ "use strict" -// TODO: show VP in player list - const P1 = "French" const P2 = "Coalition" @@ -2382,42 +2380,52 @@ function goto_end_phase() { goto_command_phase() } -function goto_victory_conditions() { - game.active = P1 - - log_h1("End of Game") - - let vp1 = 0 - let vp2 = 0 +function count_french_vp() { + let vp = 0 + for (let p of p2_corps) + if (piece_hex(p) === ELIMINATED) + vp += 3 + for (let p of p2_det) + if (piece_hex(p) === ELIMINATED) + vp += 1 + return vp +} +function count_coalition_vp() { + let vp = 0 for (let p of p1_corps) { if (piece_hex(p) === ELIMINATED) { if (p === IMPERIAL_GUARD || p === IMPERIAL_GUARD_CAV) - vp2 += 5 + vp += 5 else - vp2 += 3 + vp += 3 } } for (let p of p1_det) { if (piece_hex(p) === ELIMINATED) { if (p === GRAND_BATTERY || p === OLD_GUARD) - vp2 += 2 + vp += 2 else - vp2 += 1 + vp += 1 } } + return vp +} - for (let p of p2_corps) - if (piece_hex(p) === ELIMINATED) - vp1 += 3 - for (let p of p2_det) - if (piece_hex(p) === ELIMINATED) - vp1 += 1 +function goto_victory_conditions() { + game.active = P1 + + log_h1("End of Game") - if (search_brussels_path()) + let vp1 = count_french_vp() + if (search_brussels_path()) { + log(P1 + " " + vp1 + " + 5 VP.") vp1 += 5 + } else { + log(P1 + " " + vp1 + " + 0 VP.") + } - log(P1 + " " + vp1 + " VP.") + let vp2 = count_coalition_vp() log(P2 + " " + vp2 + " VP.") if (vp1 >= vp2 + 12) |