diff options
-rw-r--r-- | play.js | 16 | ||||
-rw-r--r-- | rules.js | 12 |
2 files changed, 22 insertions, 6 deletions
@@ -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<span class="us_tip" onmouseenter="on_focus_card_tip('us_card_${card_number}')" onmouseleave="on_blur_card_tip()">${US_CARD_NAMES[card_number-1]}</span>`; + else + return `\n<span class="tr_tip" onmouseenter="on_focus_card_tip('tr_card_${card_number-27}')" onmouseleave="on_blur_card_tip()">${TR_CARD_NAMES[card_number-28]}</span>`; + 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(/>/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/)) { @@ -428,7 +428,7 @@ function discard_card(player, card, reason = "") { } function play_card(player, card) { - log(game.active + " played \u{201c}" + CARD_NAMES[card] + "\u{201d}."); + log(game.active + " played #" + card + "."); remove_from_array(player.core, card); remove_from_array(player.hand, card); remove_from_array(player.discard, card); @@ -438,7 +438,7 @@ function play_card(player, card) { } function play_battle_card(player, card) { - log(game.active + " played \u{201c}" + CARD_NAMES[card] + "\u{201d}."); + log(game.active + " played #" + card + "."); remove_from_array(player.hand, card); } @@ -600,7 +600,7 @@ function can_pirate_raid_from_tripoli() { } function start_of_year() { - log("Start of " + game.year + "."); + log(".year " + game.year); log_blank(); game.season = SPRING; @@ -739,7 +739,7 @@ states.hand_size = { function goto_american_play() { log_blank(); - log("Start of " + SEASON_NAMES[game.season] + "."); + log(".season " + SEASON_NAMES[game.season]); log_blank(); game.active = US; @@ -925,7 +925,7 @@ states.raid_before_hunt = { play_battle_card(game.tr, card); if (card === US_SIGNAL_BOOKS_OVERBOARD) { let c = discard_random_card(game.us.hand, game.us.discard); - log("United States discarded \u{201c}" + CARD_NAMES[c] + "\u{201d}."); + log("United States discarded #" + c + "\."); } if (card === HAPPY_HUNTING) { game.happy_hunting = true; @@ -1939,7 +1939,7 @@ states.murad_reis_overboard = { card_event(card) { play_battle_card(game.tr, card); let c = discard_random_card(game.us.hand, game.us.discard); - log("United States discarded \u{201c}" + CARD_NAMES[c] + "\u{201d}."); + log("United States discarded #" + c + "."); end_tripolitan_play(); }, next() { |