From 5710300aab56a761747f79d766bd257116d5287e Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Tue, 13 Sep 2022 00:17:14 +0200
Subject: Log active and assault battles.

And add .h4 subheading type so routs and refused battles don't stand
out as much.
---
 play.html |  3 ++-
 play.js   |  8 +++++---
 rules.js  | 42 +++++++++++++++++++++++++++++++++---------
 3 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/play.html b/play.html
index ee12fed..8ad0308 100644
--- a/play.html
+++ b/play.html
@@ -25,7 +25,8 @@ header.your_turn { background-color: orange; }
 #log { background-color: ghostwhite; }
 #log .h1 { background-color: dimgray; color: ghostwhite; font-weight: bold; padding-top:2px; padding-bottom:2px; text-align: center; }
 #log .h2 { background-color: gainsboro; padding-top:2px; padding-bottom:2px; text-align: center; }
-#log .h3 { background-color: gainsboro; padding-top:2px; padding-bottom:2px; text-align: center; }
+#log .h3 { background-color: gainsboro; text-align: center; }
+#log .h4 { text-decoration: underline; font-style: italic; }
 #log .axis { background-color: hsl(120, 25%, 75%) }
 #log .allied { background-color: hsl(35, 45%, 80%) }
 #log > .i { padding-left: 20px; }
diff --git a/play.js b/play.js
index 33a4dda..ed17112 100644
--- a/play.js
+++ b/play.js
@@ -321,9 +321,7 @@ function for_each_side_in_path(path, fn) {
 }
 
 function on_focus_hex(evt) {
-	let h = evt.target.hex
-	let text = "(" + h + ") " + hex_name[h]
-	document.getElementById("status").textContent = text
+	document.getElementById("status").textContent = hex_name[evt.target.hex]
 }
 
 const unit_description = []
@@ -1095,6 +1093,10 @@ function on_log(text) {
 		text = text.substring(4)
 		p.className = "h3"
 	}
+	if (text.match(/^\.h4/)) {
+		text = text.substring(4)
+		p.className = "h4"
+	}
 
 	if (text.indexOf("\n") < 0) {
 		p.innerHTML = text
diff --git a/rules.js b/rules.js
index 49dea02..f324f35 100644
--- a/rules.js
+++ b/rules.js
@@ -2391,8 +2391,14 @@ function end_player_turn() {
 	// Reveal supply cards
 	if (game.commit[0] + game.commit[1] > 0) {
 		log_br()
-		log(`Supply Cards Revealed`)
-		log(`>${game.commit[0]} real and ${game.commit[1]} dummy.`)
+		if (game.commit[0] === 0 && game.commit[1] === 0)
+			log(`Revealed zero supply.`)
+		else if (game.commit[1] === 0)
+			log(`Revealed ${game.commit[0]} real supply.`)
+		else if (game.commit[0] === 0)
+			log(`Revealed ${game.commit[1]} dummy supply.`)
+		else
+			log(`Revealed ${game.commit[0]} real and ${game.commit[1]} dummy supply.`)
 		log_br()
 	}
 
@@ -4273,7 +4279,7 @@ states.refuse_battle = {
 		gen_action('pass')
 	},
 	hex(x) {
-		log_h3(`Refused battle at #${x}`)
+		log_h4(`Refused battle at #${x}`)
 		game.refuse = x
 		set_delete(game.new_battles, x)
 		goto_pursuit_fire_during_refuse_battle(x)
@@ -4366,7 +4372,7 @@ function goto_rout(from, enemy, after) {
 	if (enemy)
 		set_enemy_player()
 
-	log_h3(`Rout at #${from}`)
+	log_h4(`Rout at #${from}`)
 
 	// RULES: Will be disrupted again, so won't be able to recover.
 	for_each_friendly_unit_in_hex(from, u => {
@@ -4612,6 +4618,21 @@ states.select_assault_battles = {
 
 function goto_select_battle() {
 	if (game.active_battles.length > 0) {
+		if (game.active_battles.length > game.assault_battles.length) {
+			log_br()
+			log("Active battles")
+			for (let x of game.active_battles)
+				if (!set_has(game.assault_battles, x))
+					log(`>#${x}`)
+		}
+
+		if (game.assault_battles.length > 0) {
+			log_br()
+			log("Assault battles")
+			for (let x of game.assault_battles)
+				log(`>#${x}`)
+		}
+
 		if (game.active_battles.length === 1)
 			goto_battle(game.active_battles[0])
 		else
@@ -4736,8 +4757,7 @@ function goto_battle(x) {
 		log_h3(`Battle at #${x}`)
 
 	// goto defensive fire
-	log_br()
-	log(`Defensive Fire`)
+	log_h4(`Defensive Fire`)
 	set_passive_player()
 	game.state = 'battle_fire'
 	game.hits = [ 0, 0, 0, 0 ]
@@ -5006,8 +5026,7 @@ function end_battle_hits() {
 		goto_rout(game.battle, false, end_battle)
 	} else if (game.active === game.phasing && has_friendly_units_in_battle()) {
 		// goto offensive fire
-		log_br()
-		log(`Offensive Fire`)
+		log_h4(`Offensive Fire`)
 		game.state = 'battle_fire'
 		game.hits = [ 0, 0, 0, 0 ]
 	} else {
@@ -5684,7 +5703,7 @@ function print_buildup_summary() {
 			let to = (mm >>> 8 ) & 255
 			let sea = (mm >>> 16) & 255
 			if (sea)
-				log(`>${n} #${from} to #${to}*`)
+				log(`>${n} #${from} to #${to} *`)
 			else
 				log(`>${n} #${from} to #${to}`)
 		}
@@ -7196,6 +7215,11 @@ function log_h3(msg) {
 	log_br()
 }
 
+function log_h4(msg) {
+	log_br()
+	log(".h4 " + msg)
+}
+
 function gen_action(action, argument) {
 	if (argument !== undefined) {
 		if (!(action in view.actions)) {
-- 
cgit v1.2.3