summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-24 01:01:10 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-24 01:01:10 +0200
commit982dda64511b2f827c2d7fac36e29005834b4fae (patch)
tree64b0b4e69f3aa6d798389d8110145dd85402e68d /rules.js
parent0542afc3648576c30a56fdf30fd24a532b51228a (diff)
downloadmaria-982dda64511b2f827c2d7fac36e29005834b4fae.tar.gz
end game scoring
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index 8bf4434..138d5bb 100644
--- a/rules.js
+++ b/rules.js
@@ -2540,7 +2540,27 @@ function end_re_enter_train() {
function goto_winter_turn() {
- // TODO: winter scoring
+ // record winter scores
+ for (let pow of all_major_powers)
+ game.score[pow].push(count_vp_markers_in_pool(pow))
+
+ if (game.turn === 16) {
+ log("Winter Scores")
+ let best_score = 1000
+ let best_power = -1
+ for (let pow of all_major_powers) {
+ log(">" + power_name[pow] + " " + game.score[pow].join(", "))
+ let total = 0
+ for (let n of game.score[pow])
+ total += n
+ if (total <= best_score) {
+ best_score = total
+ best_power = pow
+ }
+ }
+ goto_game_over(player_from_power(best_power), power_name[best] + " won!")
+ return
+ }
game.stage = 0
goto_winter_stage()
@@ -4857,6 +4877,7 @@ exports.setup = function (seed, _scenario, _options) {
turn: 0,
stage: 0,
+ score: [ [], [], [], [] ], // winter scores
vp: [ 0, 0, 0, 0, 0, 0 ], // battle victory points, set-aside VP
saxony: 2, // political track
russia: 6, // political track