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:12:55 +0100 |
commit | d92e88b9d413fc11a39a249b539b38c6d4122997 (patch) | |
tree | 0d58a24b2cd3504ba5d5d599b89f7c454c7631ec | |
parent | 6d081770ec81e431a050d9d7feac6ece4ba87d14 (diff) | |
download | richard-iii-d92e88b9d413fc11a39a249b539b38c6d4122997.tar.gz |
Prettier logs with formatting and colors.
-rw-r--r-- | play.html | 12 | ||||
-rw-r--r-- | rules.js | 12 | ||||
-rw-r--r-- | ui.js | 28 |
3 files changed, 47 insertions, 5 deletions
@@ -16,13 +16,19 @@ .grid_center { background-color: #788; } .grid_role { background-color: silver; } -.grid_log { background-color: ghostwhite; } .grid_top { background-color: silver; } .grid_top.your_turn { background-color: orange; } .one .role_name { background-color: salmon; } .two .role_name { background-color: ghostwhite; } .turn_info { background-color: gainsboro; } +#log { background-color: ghostwhite; } +#log .st { background-color: steelblue; color: white; font-weight: bold; } +#log .L { background-color: pink; } +#log .Y { background-color: gainsboro; } +#log .bs { background-color: lightsteelblue; } +#log .br { font-style: italic; text-decoration: underline; } + .battle_header { background-color: silver; } .battle_message { background-color: silver; } .battle_separator { background-color: silver; } @@ -390,9 +396,7 @@ div.block { </div> - <div class="grid_log"> - <div class="log" id="log"></div> - </div> + <div id="log"></div> <div class="grid_center"> @@ -1428,6 +1428,7 @@ states.play_card = { } function reveal_cards() { + log(""); log("Lancaster plays " + CARDS[game.l_card].name + "."); log("York plays " + CARDS[game.y_card].name + "."); game.show_cards = true; @@ -1748,6 +1749,9 @@ states.action_phase = { } }, end_action_phase: function () { + if (game.moves > 0 && game.turn_log.length === 0 && game.recruit_log.length === 0) + logp("does nothing."); + if (game.turn_log.length > 0) print_turn_log(game.active + " moves:"); game.turn_log = game.recruit_log; @@ -2659,6 +2663,8 @@ states.regroup_to = { }, area: function (to) { if (is_sea_area(to)) { + log_move_start(game.where); + log_move_continue(to); game.location[game.who] = to; game.state = 'sea_regroup_to'; } else { @@ -2684,7 +2690,8 @@ states.sea_regroup_to = { gen_action(view, 'area', to); }, area: function (to) { - logp("sea regroups to " + to + "."); + log_move_continue(to); + log_move_end(); game.location[game.who] = to; game.who = null; game.state = 'regroup' @@ -2797,6 +2804,7 @@ states.enter_pretender_heir = { game.who = null; }, area: function (to) { + log(""); log(block_name(game.who) + " comes of age in " + to + "."); --game.killed_heirs[game.active]; game.location[game.who] = to; @@ -2879,6 +2887,7 @@ states.enter_royal_heir = { game.who = null; }, area: function (to) { + log(""); log(block_name(game.who) + " comes of age in " + to + "."); --game.killed_heirs[game.active]; game.location[game.who] = to; @@ -2940,6 +2949,7 @@ states.supply_limits_king = { function goto_political_turn() { log(""); log("Start Political Turn."); + log(""); game.turn_log = []; @@ -58,6 +58,34 @@ let ui = { present: new Set(), } +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(/^([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 Lancaster turn/)) + p.className = 'L'; + else if (text.match(/^Start York turn/)) + p.className = 'Y'; + 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; +} + function on_focus_area(evt) { let where = evt.target.area; let text = where; |