diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -1,6 +1,7 @@ "use strict" // TODO: battle dialog popup for rolling and assigning hits! +// TODO: move barbarian dice to current homeland // === SYNC with rules.js === @@ -612,7 +613,7 @@ function create_support_buttons(region) { for (let i = 0; i <= 4; ++i) { let x = Math.floor(-1 + x0 + i * 51.6666) let y = (-1 + y0) - let e = create_thing({ className: "support s" + i, my_action: "support", my_id: (region << 3) + i }) + let e = create_thing({ className: "support s" + i, my_action: i > 0 ? "support" : "recall", my_id: i > 0 ? (region << 3) + i : region }) e.style.top = y + "px" e.style.left = x + "px" } @@ -698,10 +699,8 @@ function on_init() { let stack_count = new Array(21).fill(0) -function layout_stack(id, list, region, in_capital) { +function layout_stack(id, list, region, in_capital, dx, dy) { let [ x, y, w, h ] = LAYOUT_XY[region] - let dx = 8 - let dy = 8 let z = 1 x += w >> 1 @@ -724,16 +723,6 @@ function layout_stack(id, list, region, in_capital) { stack_count[region] += 1 } - if (list.length > 6) { - dx = 4 - dy = 4 - } - - if (id >= 0) { - dx = 16 - dy = 16 - } - for (let i = list.length - 1; i >= 0; --i) { let item = list[i] item.style.left = x + "px" @@ -910,9 +899,12 @@ function on_update() { } } if (inactive_barbarians.length > 0) - layout_stack(-1, inactive_barbarians, region, false) + if (region >= 12) + layout_stack(-1, inactive_barbarians, region, false, 4, 4) + else + layout_stack(-1, inactive_barbarians, region, false, 8, 8) if (active_barbarians.length > 0) - layout_stack(-1, active_barbarians, region, false) + layout_stack(-1, active_barbarians, region, false, 8, 8) } } @@ -935,10 +927,10 @@ function on_update() { let mcastra = has_militia_castra(region) if (mcastra) { show(ui.mcastra[region]) - layout_stack(-1, [ ui.mcastra[region], ui.militia[region] ], region, true) + layout_stack(-1, [ ui.mcastra[region], ui.militia[region] ], region, true, 16, 16) } else { hide(ui.mcastra[region]) - layout_stack(-1, [ ui.militia[region] ], region, true) + layout_stack(-1, [ ui.militia[region] ], region, true, 16, 16) } } } @@ -994,9 +986,9 @@ function on_update() { stack.push(ui.militia[region]) if (inside) - layout_stack(pi * 6 + ai, stack, region, true) + layout_stack(pi * 6 + ai, stack, region, true, 16, 16) else - layout_stack(pi * 6 + ai, stack, region, false) + layout_stack(pi * 6 + ai, stack, region, false, 16, 16) } else { avail_stack.push(e) } |