summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-08-05 00:39:35 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-21 00:28:20 +0200
commit19baf7f25bd23361f84f348396d525cc88a06e68 (patch)
tree85a8676157380bdfbeed7177712b7943a9b47346 /play.js
parenteaadc13a3b267eb75dfe2e4871fc9d78030472d2 (diff)
downloadwashingtons-war-19baf7f25bd23361f84f348396d525cc88a06e68.tar.gz
lotsa logging
Diffstat (limited to 'play.js')
-rw-r--r--play.js45
1 files changed, 36 insertions, 9 deletions
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, "&amp;")
- text = text.replace(/</g, "&lt;")
- text = text.replace(/>/g, "&gt;")
- 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, "&amp;")
+ text = text.replace(/</g, "&lt;")
+ text = text.replace(/>/g, "&gt;")
+
text = text.replace(/C(\d+)/g, sub_card)
text = text.replace(/S(\d+)/g, sub_space)
text = text.replace(/G(\d+)/g, sub_general)