From dc0b24c616bcf6b494b1cb8763480d3d13cab750 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 20 Sep 2022 00:24:39 +0200 Subject: Confirm before ending movement phase if unused moves remain. --- play.js | 4 ++-- rules.js | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/play.js b/play.js index a20a7b2..c6475f1 100644 --- a/play.js +++ b/play.js @@ -1028,8 +1028,8 @@ function on_update() { action_button("end_buildup", "End buildup") action_button("end_turn", "End turn") - confirm_action_button("confirm_end_turn", "End turn", - "End turn without performing any moves?") + confirm_action_button("confirm_end_move", "End movement?", + "You have unused moves remaining. End movement anyway?") action_button("undo", "Undo") } diff --git a/rules.js b/rules.js index 5458cdc..2301087 100644 --- a/rules.js +++ b/rules.js @@ -2904,6 +2904,7 @@ function flush_withdraw_summary() { function goto_move_phase() { set_clear(game.fired) + game.used = 0 game.forced = [] game.state = 'select_moves' @@ -3012,9 +3013,6 @@ states.select_moves = { game.withdraw = null goto_final_supply_check() }, - confirm_end_turn() { - this.end_turn() - } } function list_valid_group_moves() { @@ -3291,6 +3289,20 @@ function can_end_move() { } } +function gen_action_end_move() { + if (game.turn_option === 'offensive') { + if (game.used !== 3) + gen_action('confirm_end_move') + else + gen_action('end_move') + } else { + if (game.used !== 1) + gen_action('confirm_end_move') + else + gen_action('end_move') + } +} + states.move = { inactive: "movement", prompt() { @@ -3378,14 +3390,14 @@ states.move = { view.prompt = `Movement: You may retreat.` gen_action('retreat') if (can_end_move()) - gen_action('end_move') + gen_action_end_move() } else { if (can_end_move()) { if (can_move) view.prompt = `Movement: Select unit to move.` else view.prompt = `Movement: Done.` - gen_action('end_move') + gen_action_end_move() } } } @@ -3437,6 +3449,9 @@ states.move = { return goto_overrun(where) } }, + confirm_end_move() { + this.end_move() + }, end_move() { end_movement() } @@ -3644,6 +3659,8 @@ function move_via(who, to, speed, move) { function move_unit(who, to, speed, move) { let from = unit_hex(who) + game.used |= move + if (is_forced_march_move(from, to, speed) || has_enemy_unit(to)) { if (move_via(who, to, speed, move)) { if (game.hexside.forced[0]) @@ -4698,6 +4715,7 @@ function end_combat_phase() { function goto_blitz_turn() { log_h2(`Blitz Turn`) + game.used = 0 if (game.rommel) game.rommel = 3 game.turn_option = 'second blitz' @@ -6980,6 +6998,7 @@ exports.setup = function (seed, scenario, options) { turn_option: null, passed: 0, side_limit: {}, + used: 0, forced: null, rommel: 0, from1: 0, -- cgit v1.2.3