From 121366f15f7cd4e9bb7c64b668742c9b556dd772 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 27 May 2022 20:22:23 +0200 Subject: Pause before game over when it can be undone. --- play.js | 1 + rules.js | 29 ++++++++++++++++++++++++++--- 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() { -- cgit v1.2.3