diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-12-19 17:03:16 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-16 19:08:56 +0100 |
commit | bbbd35a5e828a9f19b44544a80af9c1e7daf0299 (patch) | |
tree | 45c80857bd7c97d59534c5fc4cc51f043fc20422 | |
parent | 861c83b63547c9538dda5716bba2113ae458a3ff (diff) | |
download | julius-caesar-bbbd35a5e828a9f19b44544a80af9c1e7daf0299.tar.gz |
Prettier logs with formatting and colors.
-rw-r--r-- | play.html | 14 | ||||
-rw-r--r-- | rules.js | 7 | ||||
-rw-r--r-- | ui.js | 29 |
3 files changed, 42 insertions, 8 deletions
@@ -18,13 +18,19 @@ .grid_center { background-color: #461145; } .grid_role { background-color: tan; } -.grid_log { background-color: wheat; } .grid_top { background-color: tan; } .grid_top.your_turn { background-color: orange; } .one .role_name { background-color: salmon; } .two .role_name { background-color: #eb5; } .turn_info { background-color: burlywood; } +#log { background-color: wheat; } +#log .st { background-color: brown; color: gold; font-weight: bold; } +#log .C { background-color: salmon; } +#log .P { background-color: #eb5; } +#log .bs { background-color: tan; } +#log .br { font-style: italic; text-decoration: underline; } + /* CARDS */ .card_back { background-image: url('cards/card_back.webp'); } @@ -80,7 +86,7 @@ .battle { background-color: tan; } .battle .battle_message { background-color: wheat; } -.battle .battle_header { background-color: brown; color: white; font-weight: bold; } +.battle .battle_header { background-color: brown; color: wheat; font-weight: bold; } .battle .battle_separator { background-color: brown; } .battle_line.enemy .battle_menu_list { min-height: 0; } @@ -319,9 +325,7 @@ body.Observer .columbia-labels .known.jupiter.Cleopatra { border: 3px solid #822 <div class="turn_info">-</div> </div> - <div class="grid_log"> - <div class="log" id="log"></div> - </div> + <div id="log"></div> <div class="grid_center"> @@ -997,6 +997,7 @@ function reveal_cards() { delete game.neptune; delete game.pluto; + log(""); log("Caesar plays ", CARDS[game.c_card].name, "."); log("Pompeius plays ", CARDS[game.p_card].name, "."); @@ -1684,10 +1685,9 @@ function start_battle() { game.battle_round = 0; game.flash = ""; log(""); + log("Battle in ", game.where, "."); if (game.surprise === game.where) - log("Surprise attack in ", game.where, "."); - else - log("Battle in ", game.where, "."); + log("Surprise attack."); game.state = 'battle_round'; start_battle_round(); } @@ -2177,6 +2177,7 @@ function check_victory() { } else { log(""); log("Start Winter Turn of Year " + game.year); + log(""); start_navis_to_port(); } } @@ -74,6 +74,35 @@ let ui = { cards: {}, }; +create_log_entry = function (text) { + let p = document.createElement("div"); + text = text.replace(/&/g, "&"); + text = text.replace(/</g, "<"); + text = text.replace(/>/g, ">"); + + text = text.replace(/\u2192 /g, "\u2192\xa0"); + text = text.replace(/Mare /g, "Mare\xa0"); + + text = text.replace(/^([A-Z]):/, '<span class="$1"> $1 </span>'); + + if (text.match(/^~ .* ~$/)) + p.className = 'br', text = text.substring(2, text.length-2); + else if (text.match(/^Start Caesar turn/)) + p.className = 'C'; + else if (text.match(/^Start Pompeius turn/)) + p.className = 'P'; + else if (text.match(/^Start /)) + p.className = 'st'; + else if (text.match(/^Battle in/)) + p.className = 'bs'; + + if (text.match(/^Start /)) + text = text.substring(6); + + p.innerHTML = text; + return p; +} + const STEPS = [ 0, "I", "II", "III", "IIII" ]; function block_description(b) { |