summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-02-16 22:56:44 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:12:42 +0100
commit61dd59b33138db47c6f8a45b7439c43d8daf4b21 (patch)
treeac70e0129c5683a3e35fd962695c705da70d66d6 /rules.js
parent16fa2b730bc38b4de0d0efac4635aa4541bb7a9d (diff)
downloadshores-of-tripoli-61dd59b33138db47c6f8a45b7439c43d8daf4b21.tar.gz
Update US score to be 24 - TR score.
Also record final score on game over.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js10
1 files changed, 8 insertions, 2 deletions
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,