summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-09-30 22:12:12 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-01 16:11:22 +0200
commit3e21ce78e400306dddf8ab0c90ac9fb86fe55094 (patch)
tree99220d9437fca9981b676dac00fd1fcd3ceb6a8c /rules.js
parent9bc1b871555682d201983c54a4d644b59f9853ae (diff)
downloadwaterloo-campaign-1815-3e21ce78e400306dddf8ab0c90ac9fb86fe55094.tar.gz
Clean up play.js and show running VP totals.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js50
1 files changed, 29 insertions, 21 deletions
diff --git a/rules.js b/rules.js
index b72bb10..cc3ef0d 100644
--- a/rules.js
+++ b/rules.js
@@ -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)