From 19baf7f25bd23361f84f348396d525cc88a06e68 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 5 Aug 2024 00:39:35 +0200 Subject: lotsa logging --- play.js | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index c317507..70279fa 100644 --- a/play.js +++ b/play.js @@ -4,6 +4,8 @@ global view, data, roles, send_action, action_button */ +// TODO: show "reshuffle" flag next to card deck display + /* COMMON */ function set_has(set, item) { @@ -294,8 +296,8 @@ function lerp(a, b, t) { } function show_combat_marker() { - let x = Math.round(lerp(data.spaces[view.move.from].x, data.spaces[view.move.to].x, 0.75)) - let y = Math.round(lerp(data.spaces[view.move.from].y, data.spaces[view.move.to].y, 0.75)) + let x = Math.round(lerp(data.spaces[view.move.from].x, data.spaces[view.move.to].x, 0.67)) + let y = Math.round(lerp(data.spaces[view.move.from].y, data.spaces[view.move.to].y, 0.67)) ui.combat.style.left = x - 20 + "px" ui.combat.style.top = y - 20 + "px" ui.pieces_element.appendChild(ui.combat) @@ -383,8 +385,8 @@ function get_army_xy_lerp(s1, s2) { y = data.spaces[s1].y + (dy * 1/2) | 0 } - if (Math.abs(dx) < 180 && Math.abs(dy) < 60) - y -= 20 + if (Math.abs(dx) < 180 && Math.abs(dy) < 60) y -= 20 + if (Math.abs(dx) < 180 && Math.abs(dy) < 40) y -= 20 return [ x - 15, y ] } @@ -550,7 +552,9 @@ function on_update() { continue let [ x, y ] = (s < 66) ? ui.layout_static[s] : get_static_xy(s) - if (s >= 66) + if (s === 68) + y -= 20 + else if (s >= 66) y -= 60 if (view.move && view.move.who === g) @@ -797,11 +801,14 @@ function on_blur_card_tip() { function on_log(text) { let p = document.createElement("div") - text = text.replace(/&/g, "&") - text = text.replace(//g, ">") - if (text.startsWith("=t")) { + if (text.startsWith(">>")) { + p.className = "ii" + text = text.substring(2) + } else if (text.startsWith(">")) { + p.className = "i" + text = text.substring(1) + } else if (text.startsWith("=t")) { p.className = "h turn" text = text.substring(2) } else if (text.startsWith("=a")) { @@ -810,8 +817,28 @@ function on_log(text) { } else if (text.startsWith("=b")) { p.className = "h britain" text = text.substring(3) + } else if (text.startsWith("=!")) { + p.className = "h" + text = text.substring(3) } + if ( + text.startsWith("Played ") || + text.startsWith("Discarded ") || + text.startsWith("Exchanged ") || + text.startsWith("Retreated ") || + text.startsWith("Surrendered ") || + text === "Removed card." + ) + p.className = "n" + + if (text.startsWith("Moved G")) + p.className = "m" + + text = text.replace(/&/g, "&") + text = text.replace(//g, ">") + text = text.replace(/C(\d+)/g, sub_card) text = text.replace(/S(\d+)/g, sub_space) text = text.replace(/G(\d+)/g, sub_general) -- cgit v1.2.3