From bc10c7f7766ee322ab34b76bd557f5c5fed390d2 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 9 May 2022 01:30:03 +0200 Subject: Use card numbers in raw log format. --- play.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'play.js') diff --git a/play.js b/play.js index 8b13b10..e38d7f3 100644 --- a/play.js +++ b/play.js @@ -124,6 +124,15 @@ function sub_log_entry_tip(match, p1, offset, string) { return match; } +function sub_log_entry_tip2(match, p1, offset, string) { + let card_number = p1 | 0; + if (card_number < 28) + return `\n${US_CARD_NAMES[card_number-1]}`; + else + return `\n${TR_CARD_NAMES[card_number-28]}`; + return match; +} + let last_log_who = 'st'; function on_log(text) { let p = document.createElement("div"); @@ -131,12 +140,19 @@ function on_log(text) { text = text.replace(//g, ">"); text = text.replace(/\u201c(.*)\u201d/g, sub_log_entry_tip); + text = text.replace(/#(\d+)/g, sub_log_entry_tip2); if (text.match(/^Start of \d+/)) { text = text.substring(9, text.length-1); p.className = 'year'; } else if (text.match(/^Start of /)) { text = text.substring(9, text.length-1); p.className = 'season'; + } else if (text.match(/^.year \d+/)) { + text = text.substring(6); + p.className = 'year'; + } else if (text.match(/^.season /)) { + text = text.substring(8); + p.className = 'season'; } else if (text.match(/^Pirate raid from/)) { p.className = 'raid'; } else if (text.match(/^(Naval|Land) (battle|bombardment) in/)) { -- cgit v1.2.3