summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-07-04 23:44:02 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-21 00:28:20 +0200
commit9b946d07851f337176ca62a634108c64a95b3ae0 (patch)
tree994529e800a41f1e1bbdec988b2b7ec9bac59b44 /play.js
parent0eaed15c92906fe4faa53f248bebba12f9c737e2 (diff)
downloadwashingtons-war-9b946d07851f337176ca62a634108c64a95b3ae0.tar.gz
fix layout
Diffstat (limited to 'play.js')
-rw-r--r--play.js37
1 files changed, 26 insertions, 11 deletions
diff --git a/play.js b/play.js
index 4b6e7ce..bf99bee 100644
--- a/play.js
+++ b/play.js
@@ -403,16 +403,24 @@ function general_total(g) {
}
function get_army_xy_lerp(s1, s2) {
+ if (s1 === s2)
+ return get_army_xy(s2)
+
+ let dx = data.spaces[s2].x - data.spaces[s1].x
+ let dy = data.spaces[s2].y - data.spaces[s1].y
+
let x, y
if (s1 >= 66) {
x = data.spaces[s1].x
y = data.spaces[s1].y - 40
} else {
- x = (data.spaces[s1].x + data.spaces[s2].x) >> 1
- y = (data.spaces[s1].y + data.spaces[s2].y) >> 1
+ x = data.spaces[s1].x + (dx * 1/2) | 0
+ y = data.spaces[s1].y + (dy * 1/2) | 0
}
- if (s1 === s2)
- y -= 40
+
+ if (Math.abs(dx) < 180 && Math.abs(dy) < 60)
+ y -= 20
+
return [ x, y ]
}
@@ -483,6 +491,7 @@ function on_update() {
fcu -= view.react.carry_french
bcu -= view.react.carry_british
}
+
toggle_marker_with_number(ui.a_cu[s], acu)
toggle_marker_with_number(ui.f_cu[s], fcu)
toggle_marker_with_number(ui.b_cu[s], bcu)
@@ -490,7 +499,6 @@ function on_update() {
if (view.move) {
let [ x, y ] = get_army_xy_lerp(view.move.from, view.move.to)
-
if (view.move.carry_american > 0 && view.move.carry_french > 0) {
toggle_marker_with_number_at(ui.a_mcu, view.move.carry_american, x-15, y)
toggle_marker_with_number_at(ui.f_mcu, view.move.carry_french, x+15, y)
@@ -528,17 +536,24 @@ function on_update() {
if (view.move && view.move.who === g) {
ui.generals[g].classList.add("selected")
if (view.move.carry_french > 0 && view.move.carry_american > 0)
- x += 30
- x += 30
+ x += 15
+ x += 20
} else if (view.react && view.react.who === g) {
ui.generals[g].classList.add("selected")
if (view.react.carry_french > 0 && view.react.carry_american > 0)
- x += 30
- x += 30
+ x += 15
+ x += 20
} else {
ui.generals[g].classList.remove("selected")
- if (count_french_cu(s) > 0 && count_american_cu(s) > 0)
- x += 30
+
+ let fcu = count_french_cu(s)
+ if (view.move && view.move.to === s)
+ fcu -= view.move.carry_french
+ if (view.react && view.react.from === s)
+ fcu -= view.react.carry_french
+ if (fcu > 0)
+ x += 15
+
if (s < 66) {
let offset = general_offset(g)
x += offset * (45 + 9)