summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-05-27 20:22:23 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:31:29 +0100
commit121366f15f7cd4e9bb7c64b668742c9b556dd772 (patch)
treeccd7358f73c1b98faae695239d599e9a4c98569a
parent006c34ed997c8aeb9836ad6a41d5ab3fe4a44a33 (diff)
downloadpax-pamir-121366f15f7cd4e9bb7c64b668742c9b556dd772.tar.gz
Pause before game over when it can be undone.
-rw-r--r--play.js1
-rw-r--r--rules.js29
2 files changed, 27 insertions, 3 deletions
diff --git a/play.js b/play.js
index 379c810..7d6a391 100644
--- a/play.js
+++ b/play.js
@@ -536,6 +536,7 @@ function on_update() {
action_button("pass", "Pass");
action_button("next", "Next");
+ action_button("end_game", "End game");
confirm_action_button("end_turn_pass", "End turn",
"Are you sure you want to END TURN while you still have actions?");
action_button("end_turn", "End turn");
diff --git a/rules.js b/rules.js
index 5862763..64e035e 100644
--- a/rules.js
+++ b/rules.js
@@ -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() {