From d1dd9316d41cf86ccf4739355d88afd10ad27e05 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 18 Jan 2022 14:42:05 +0100 Subject: Improve log formatting. --- play.css | 6 ++++-- play.js | 10 ++++++++-- rules.js | 37 ++++++++++++++++++++++++------------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/play.css b/play.css index befdd04..2e4dfb3 100644 --- a/play.css +++ b/play.css @@ -8,8 +8,10 @@ body.United_States header.your_turn { background-color: skyblue; } #role_Tripolitania .role_name { background-color: salmon; } #log { background-color: #eee; } -#log .st { background-color: #777; color: white; font-weight: bold; padding:3px; text-align: center; } -#log .ss { background-color: #ccc; color: #444; font-weight: bold; padding:3px; text-align: center; } +#log .year { background-color: #777; color: white; font-weight: bold; padding:3px; text-align: center; } +#log .season { background-color: #ccc; color: #444; font-weight: bold; padding:3px; text-align: center; } +#log .raid, .battle { text-decoration: underline; font-style: italic; font-weight: bold; } +#log .round { text-decoration: underline; font-style: italic; } #log .end { font-style: italic; } #log .us_tip { color: blue; text-decoration: dotted underline; cursor: help; } #log .tr_tip { color: #d00; text-decoration: dotted underline; cursor: help; } diff --git a/play.js b/play.js index 277145e..f9fd829 100644 --- a/play.js +++ b/play.js @@ -133,10 +133,16 @@ create_log_entry = function (text) { text = text.replace(/\u201c(.*)\u201d/g, sub_log_entry_tip); if (text.match(/^Start of \d+/)) { text = text.substring(9, text.length-1); - p.className = 'st'; + p.className = 'year'; } else if (text.match(/^Start of /)) { text = text.substring(9, text.length-1); - p.className = 'ss'; + p.className = 'season'; + } else if (text.match(/^Pirate raid from/)) { + p.className = 'raid'; + } else if (text.match(/^(Naval|Land) (battle|bombardment) in/)) { + p.className = 'battle'; + } else if (text.match(/^(Naval|Land) battle (round)/)) { + p.className = 'round'; } else if (text.match(/(victory:|ends in a draw)/)) { p.className = 'end'; } diff --git a/rules.js b/rules.js index cd5af15..06445a9 100644 --- a/rules.js +++ b/rules.js @@ -272,6 +272,10 @@ function log(...args) { game.log.push(s); } +function log_blank() { + game.log.push(""); +} + function flush_summary(text, add_plural_s=false) { game.summary.sort(); let last = game.summary[0]; @@ -595,7 +599,7 @@ function can_pirate_raid_from_tripoli() { function start_of_year() { log("Start of " + game.year + "."); - log(""); + log_blank(); game.season = SPRING; @@ -732,16 +736,16 @@ states.hand_size = { } function goto_american_play() { - log(""); + log_blank(); log("Start of " + SEASON_NAMES[game.season] + "."); - log(""); + log_blank(); game.active = US; game.state = 'american_play'; } function end_american_play() { - log(""); + log_blank(); clear_undo(); game.where = null; game.active = TR; @@ -749,7 +753,7 @@ function end_american_play() { } function end_tripolitan_play() { - log(""); + log_blank(); clear_undo(); game.where = null; end_of_season(); @@ -1172,7 +1176,8 @@ function naval_bombardment_round() { if (n_frigates + n_gunboats > 0) { let n_infantry = count_tripolitan_infantry(game.where); let n_hits = 0; - log("Naval Bombardment in " + SPACES[game.where] + "."); + log_blank(); + log("Naval bombardment in " + SPACES[game.where] + "."); n_hits += roll_many_dice("American frigates:\n", n_frigates * 2, 6); n_hits += roll_many_dice("American gunboats:\n", n_gunboats, 6); if (n_hits > n_infantry) @@ -1209,6 +1214,7 @@ function goto_naval_battle(space) { game.save_active = game.active; game.where = space; game.round = 0; + log_blank(); log("Naval battle in " + SPACES[game.where] + "."); goto_naval_battle_american_card(); } @@ -1277,6 +1283,11 @@ function goto_naval_battle_round() { game.active = game.save_active; game.round ++; + if (game.active_card === ASSAULT_ON_TRIPOLI) { + log_blank(); + log("Naval battle round " + game.round + "."); + } + let n_us_frigates = count_american_frigates(game.where); let n_us_gunboats = count_american_gunboats(game.where); let n_tr_frigates = count_tripolitan_frigates(game.where); @@ -1479,8 +1490,6 @@ function resume_naval_battle() { log("The American fleet has been eliminated."); return goto_game_over(TR, "Assault on Tripoli failed."); } - log(""); - log("Naval battle continues..."); return goto_naval_battle_round(); } @@ -1557,7 +1566,8 @@ states.land_battle_bombardment_results = { next() { delete game.flash; - log("Land Battle in " + SPACES[game.where] + "."); + log_blank(); + log("Land battle in " + SPACES[game.where] + "."); goto_land_battle(); }, @@ -1692,7 +1702,8 @@ function goto_land_battle_round() { return end_american_play(); } - log("Land battle round."); + log_blank(); + log("Land battle round " + game.round + "."); let n_tr_hits = 0; if (game.lieutenant_obannon_leads_the_charge && n_us_mar > 0) { @@ -1855,8 +1866,8 @@ states.yusuf_qaramanli = { gen_action(view, 'space', space); }, space(space) { - log(""); - log("Pirate Raid from " + SPACES[space] + "."); + log_blank(); + log("Pirate raid from " + SPACES[space] + "."); remove_from_array(game.raids, space); switch (space) { case ALGIERS: return goto_pirate_raid(ALGIERS); @@ -2769,7 +2780,7 @@ function goto_game_over(result, message) { game.victory = "United States victory:\n" + message; else game.victory = message; - log(""); + log_blank(); log(game.victory); return true; } -- cgit v1.2.3