diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-05-27 20:22:23 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 12:31:29 +0100 |
commit | 121366f15f7cd4e9bb7c64b668742c9b556dd772 (patch) | |
tree | ccd7358f73c1b98faae695239d599e9a4c98569a /rules.js | |
parent | 006c34ed997c8aeb9836ad6a41d5ab3fe4a44a33 (diff) | |
download | pax-pamir-121366f15f7cd4e9bb7c64b668742c9b556dd772.tar.gz |
Pause before game over when it can be undone.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -2916,10 +2916,10 @@ function do_dominance_check(reason) { // Check instant victory let vps = game.players.map(pp => pp.vp).sort((a,b)=>b-a); if (vps[0] >= vps[1] + 4) - return goto_game_over(); + return goto_pause_game_over(); if (final) - return goto_game_over(); + return goto_pause_game_over(); game.events = {}; for (let p = 0; p < game.players.length; ++p) @@ -2955,7 +2955,7 @@ function vp_tie(pp) { return pp.vp * 10000 + stars * 100 + pp.coins; } -function goto_game_over() { +function compute_victory() { let vps = game.players.map((pp,i) => [vp_tie(pp),i]).sort((a,b)=>b[0]-a[0]); let result = []; for (let i = 0; i < vps.length; ++i) @@ -2965,9 +2965,32 @@ function goto_game_over() { game.victory = result.join(" and ") + " won!"; logbr(); log(game.victory); +} + +function goto_pause_game_over() { + compute_victory(); + if (game.undo && game.undo.length > 0) + game.state = 'pause_game_over'; + else + game.state = 'game_over'; +} + +function goto_game_over() { + compute_victory(); game.state = 'game_over'; } +states.pause_game_over = { + inactive: "game over", + prompt() { + view.prompt = game.victory; + gen_action('end_game'); + }, + end_game() { + game.state = 'game_over'; + } +} + // SETUP function prepare_deck() { |