diff options
-rw-r--r-- | play.js | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -857,12 +857,23 @@ function update_cards() { } } +function insert_battle_block(root, node, unit) { + for (let i = 0; i < root.children.length; ++i) { + let prev = root.children[i] + if (prev.unit > unit) { + root.insertBefore(node, prev) + return + } + } + root.appendChild(node) +} + function update_battle_line(hex, line, test) { for (let u = 0; u < unit_count; ++u) { let e = ui.battle_units[u] if (unit_hex(u) === hex && test(u)) { if (!line.contains(e)) - line.appendChild(e) + insert_battle_block(line, e, u) let r = unit_lost_steps(u) e.classList.toggle("r0", r === 0) |