From 61dd59b33138db47c6f8a45b7439c43d8daf4b21 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 16 Feb 2022 22:56:44 +0100 Subject: Update US score to be 24 - TR score. Also record final score on game over. --- rules.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 891edb8..0042f64 100644 --- a/rules.js +++ b/rules.js @@ -2771,11 +2771,16 @@ function check_frigate_victory() { return false; } +function calculate_tr_score() { + return Math.min(count_american_frigates(TRIPOLITAN_SUPPLY), 4) * 3 + game.tr.gold; +} + function goto_game_over(result, message) { game.where = null; game.state = 'game_over'; game.active = "None"; game.result = result; + game.score = calculate_tr_score(); if (result === TR) game.victory = "Tripolitan victory:\n" + message; else if (result === US) @@ -2925,7 +2930,8 @@ exports.is_checkpoint = (a, b) => a.season !== b.season; exports.view = function(state, current) { game = state; - let tr_score = Math.min(count_american_frigates(TRIPOLITAN_SUPPLY), 4) * 3 + game.tr.gold; + let tr_score = calculate_tr_score(); + let us_score = 24 - tr_score; let view = { log: game.log, @@ -2949,7 +2955,7 @@ exports.view = function(state, current) { draw: game.us.draw.length, discard: game.us.discard.length + (game.us.queue ? game.us.queue.length : 0), hand: game.us.hand.length, - score: 25 - tr_score, + score: us_score, }, card: game.active_card, where: game.where, -- cgit v1.2.3