From 8bdcee64dbbfc216a1f66f961a143d488f827f71 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 5 Aug 2021 01:25:18 +0200 Subject: crusader: Add confirmation step when ending move phase with moves left. --- rules.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/rules.js b/rules.js index ae1f7fd..93d6d22 100644 --- a/rules.js +++ b/rules.js @@ -1554,6 +1554,12 @@ function goto_move_phase(moves) { } function end_move_phase() { + if (game.moves > 0) { + push_undo(); + game.state = 'confirm_end_move_phase'; + return; + } + clear_undo(); game.who = null; game.where = null; @@ -1569,6 +1575,25 @@ function end_move_phase() { end_player_turn(); } +states.confirm_end_move_phase = { + prompt: function (view, current) { + if (is_inactive_player(current)) + return view.prompt = "Move Phase: Waiting for " + game.active + "."; + if (game.moves > 1) + view.prompt = "Move Phase: You have " + game.moves + " moves left"; + else + view.prompt = "Move Phase: You have 1 move left"; + view.prompt += " \u2014 are you sure you want to end the move phase?"; + gen_action_undo(view); + gen_action(view, 'end_move_phase'); + }, + end_move_phase: function () { + game.moves = 0; + end_move_phase(); + }, + undo: pop_undo +} + states.move_phase = { prompt: function (view, current) { if (is_inactive_player(current)) -- cgit v1.2.3