diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-12-25 12:25:26 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-12-25 12:26:13 +0100 |
commit | 388c289bb646db0d95e6c4e40bd08e998201268b (patch) | |
tree | 5349cf8d2a0664eb9092d2c1a264ca470f37d9d1 | |
parent | 102f18e2c48e513e8172d85a19145d9a1bd769a4 (diff) | |
download | maria-388c289bb646db0d95e6c4e40bd08e998201268b.tar.gz |
separate flipped generals in stack
-rw-r--r-- | play.js | 36 |
1 files changed, 31 insertions, 5 deletions
@@ -986,10 +986,14 @@ function on_blur_city() { function on_focus_piece(evt) { let p = evt.target.my_id - if (p < 20 && view.troops[p] > 0) - ui.status.textContent = piece_log_name[evt.target.my_id] + " (" + view.troops[p] + " troops)" - else - ui.status.textContent = piece_log_name[evt.target.my_id] + let text = piece_log_name[p] + if (p < 20 && view.troops[p] > 0) { + text += " (" + view.troops[p] + " troops" + if (view.oos & (1 << p)) + text += " \u2013 flipped" + text += ")" + } + ui.status.textContent = text } function on_blur_piece() { @@ -1023,6 +1027,23 @@ function layout_general_offset(who, here) { return 0 } +function is_other_general_on_top(who, here) { + let other = -1 + for (let p = 0; p < 20; ++p) + if (view.pos[p] === here && who !== p) + other = p + // no other general! + if (other < 0) + return false // alone + if ((view.supreme & (1 << who)) || view.selected === who) + return false // on top + if ((view.supreme & (1 << other)) || view.selected === other) + return true // on bottom + if (piece_rank[who] < piece_rank[other]) + return false // on top + return true // on bottom +} + function layout_general_offset_elim(g) { let n = 0 let p = get_cylinder_power(g) @@ -1082,6 +1103,11 @@ function layout_general(id, s) { y = data.cities.y[s] } + if (is_other_general_on_top(id, s)) { + if (view.oos & (1 << id)) + n = -2/3 + } + let selected = set_has(view.selected, id) let e = ui.pieces[id] @@ -1091,7 +1117,7 @@ function layout_general(id, s) { e.style.top = (y - 29 - 15 * n) + "px" e.style.zIndex = y + n e.classList.toggle("selected", selected) - e.classList.toggle("oos", (view.oos & (1 <<id)) !== 0) + e.classList.toggle("oos", (view.oos & (1 << id)) !== 0) e = ui.troops[id] if (e.parentElement !== ui.pieces_element) |