From d7054787a94fd333eafb2bacbe8387ee117e5d80 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Sun, 4 Sep 2022 00:13:37 +0200
Subject: Separate buttons for Rommel moves.

---
 play.js  |  2 ++
 rules.js | 81 ++++++++++++++++++++++++++++++++--------------------------------
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/play.js b/play.js
index 1756db7..bc763de 100644
--- a/play.js
+++ b/play.js
@@ -936,6 +936,8 @@ function on_update() {
 	action_button("dismantle", "Dismantle")
 	action_button("extra_supply_card", "Card")
 
+	action_button("group_rommel", "Group (R)")
+	action_button("regroup_rommel", "Regroup (R)")
 	action_button("group", "Group")
 	action_button("regroup", "Regroup")
 
diff --git a/rules.js b/rules.js
index 1d4f31c..d9e0d52 100644
--- a/rules.js
+++ b/rules.js
@@ -2991,11 +2991,10 @@ function goto_move_phase() {
 	game.forced = []
 	game.state = 'select_moves'
 	init_move_summary()
-	if (game.phasing === AXIS) {
-		// Automatically select Rommel Move for 1-move turn options
-		if (game.turn_option !== 'offensive' && game.turn_option !== 'blitz' && game.scenario !== "1940")
+
+	if (game.phasing === AXIS && game.scenario !== "1940" && game.rommel === 0)
+		if (game.turn_option !== 'offensive' && game.turn_option !== 'blitz')
 			game.rommel = 1
-	}
 }
 
 function show_move_commands() {
@@ -3014,31 +3013,48 @@ states.select_moves = {
 				view.prompt = `Designate second offensive move.`
 			else
 				view.prompt = `Designate first offensive move.`
+		} else if (game.turn_option === 'blitz') {
+			view.prompt = `Designate first blitz move.`
 		} else {
 			view.prompt = `Designate ${game.turn_option} move.`
 		}
-		gen_action('group')
-		gen_action('regroup')
+
+		if (game.phasing === AXIS && game.scenario !== "1940" && game.rommel === 0) {
+			if (game.turn_option === 'offensive' || game.turn_option === 'blitz') {
+				gen_action('group')
+				gen_action('regroup')
+			}
+			gen_action('group_rommel')
+			gen_action('regroup_rommel')
+		} else {
+			gen_action('group')
+			gen_action('regroup')
+		}
+
 		if (game.turn_option === 'pass')
 			gen_action('end_turn')
 	},
+	group_rommel() {
+		push_undo()
+		game.rommel = (game.from1 === 0) ? 1 : 2
+		goto_group()
+	},
 	group() {
 		push_undo()
 		game.state = 'group_move_from'
 	},
+	regroup_rommel() {
+		push_undo()
+		game.rommel = (game.from1 === 0) ? 1 : 2
+		goto_regroup()
+	},
 	regroup() {
 		push_undo()
-		game.state = 'regroup_move_command_point'
-		if (game.turn_option === 'pass') {
-			game.withdraw = list_valid_withdrawal_regroup_command_points()
-			save_withdrawal_supply_lines()
-		}
+		goto_regroup()
 	},
 	end_turn() {
 		clear_undo()
-		flush_move_summary()
 		game.summary = null
-		reveal_visited_minefields()
 		goto_final_supply_check()
 	},
 	confirm_end_turn() {
@@ -3046,9 +3062,16 @@ states.select_moves = {
 	}
 }
 
-function gen_rommel_move() {
-	if (game.phasing === AXIS && game.scenario !== "1940")
-		view.actions.rommel = game.rommel ? 0 : 1
+function goto_group() {
+	game.state = 'group_move_from'
+}
+
+function goto_regroup() {
+	game.state = 'regroup_move_command_point'
+	if (game.turn_option === 'pass') {
+		game.withdraw = list_valid_withdrawal_regroup_command_points()
+		save_withdrawal_supply_lines()
+	}
 }
 
 states.group_move_from = {
@@ -3056,7 +3079,6 @@ states.group_move_from = {
 	prompt() {
 		show_move_commands()
 		view.prompt = `Group Move: Select hex to move from.`
-		gen_rommel_move()
 		if (game.turn_option !== 'pass') {
 			for (let x of all_hexes) {
 				if (x === game.from1 && !game.to1)
@@ -3091,13 +3113,6 @@ states.group_move_from = {
 			}
 		}
 	},
-	rommel() {
-		push_undo()
-		if (game.from1 === 0)
-			game.rommel = 1
-		else
-			game.rommel = 2
-	},
 	hex(x) {
 		push_undo()
 		if (game.from1 === 0)
@@ -3144,7 +3159,6 @@ states.regroup_move_command_point = {
 	prompt() {
 		show_move_commands()
 		view.prompt = `Regroup Move: Designate the command point hex.`
-		gen_rommel_move()
 		if (game.turn_option !== 'pass') {
 			for (let x of all_hexes) {
 				if (!is_enemy_hex(x)) {
@@ -3158,13 +3172,6 @@ states.regroup_move_command_point = {
 			gen_withdrawal_regroup_command_point()
 		}
 	},
-	rommel() {
-		push_undo()
-		if (game.from1 === 0)
-			game.rommel = 1
-		else
-			game.rommel = 2
-	},
 	hex(x) {
 		push_undo()
 		if (game.from1 === 0)
@@ -3182,8 +3189,7 @@ states.regroup_move_destination = {
 	prompt() {
 		show_move_commands()
 		view.prompt = `Regroup Move: Select destination hex.`
-		gen_rommel_move()
-		let cp, rommel = false
+		let cp, rommel
 		if (game.from2 === 0)
 			cp = game.from1, rommel = (game.rommel === 1 ? 1 : 0)
 		else
@@ -3201,13 +3207,6 @@ states.regroup_move_destination = {
 			gen_withdrawal_regroup_destination()
 		}
 	},
-	rommel() {
-		push_undo()
-		if (game.from2 === 0)
-			game.rommel = 1
-		else
-			game.rommel = 2
-	},
 	hex(x) {
 		push_undo()
 		if (game.from2 === 0)
-- 
cgit v1.2.3