From b1f87e0acdaf88d7759f8293598d42edd303be65 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 6 Jul 2023 18:49:50 +0200 Subject: Fix Militia + Capital action layout. --- play.css | 1 - play.js | 14 +++++++++++--- rules.js | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/play.css b/play.css index 0275752..0dc2ad0 100644 --- a/play.css +++ b/play.css @@ -245,7 +245,6 @@ body svg .sea.action { display: block; border: 5px solid white; box-shadow: 0 0 6px white, inset 0 0 6px black; - z-index: 2; } body.p3 #npg_hispania { display: block } diff --git a/play.js b/play.js index f240f08..7814414 100644 --- a/play.js +++ b/play.js @@ -972,6 +972,11 @@ function layout_stack(id, list, region, in_capital, dx, dy, z = 1) { stack_count[region] += 1 } + if (in_capital === 2) { + x += 36 + y += 18 + } + for (let i = list.length - 1; i >= 0; --i) { let item = list[i] item.style.left = x + "px" @@ -1283,10 +1288,13 @@ function on_update() { else layout_battle_stack(view.combat.attacker < 0, [ ui.militia[region] ], region, true) } else { + let inside = 1 + if (is_action("capital", region)) + inside = 2 if (has_militia_castra(region)) - layout_stack(-1, [ ui.mcastra[region], ui.militia[region] ], region, true, 16, 16) + layout_stack(-1, [ ui.mcastra[region], ui.militia[region] ], region, inside, 16, 16) else - layout_stack(-1, [ ui.militia[region] ], region, true, 16, 16) + layout_stack(-1, [ ui.militia[region] ], region, inside, 16, 16) } } } @@ -1357,7 +1365,7 @@ function on_update() { if (is_battle_stack(region, "general", pi * 6 + ai)) layout_battle_stack(pi * 6 + ai === view.combat.attacker, stack, region) else - layout_stack(pi * 6 + ai, stack, region, inside, 16, 16) + layout_stack(pi * 6 + ai, stack, region, inside ? 1 : 0, 16, 16) } else { avail_stack.push(e) } diff --git a/rules.js b/rules.js index 28638e1..fa9306d 100644 --- a/rules.js +++ b/rules.js @@ -1773,7 +1773,7 @@ states.take_actions = { // Select Militia (if can Disperse Mobs or Initiate Battle) let loc = get_governor_location(id) if (is_province(loc) && has_lone_militia(loc) && loc !== game.selected_militia) { - if (game.mip >= 1 && (get_mobs(loc)) || can_militia_initiate_battle(loc)) + if (game.mip >= 1 && (get_mobs(loc) || can_militia_initiate_battle(loc))) gen_action_militia(loc) } } @@ -1908,7 +1908,8 @@ states.take_actions = { // Militia Actions if (game.selected_militia >= 0) { view.actions.disperse_mob = 0 - if (game.mip >= 1) + + if (game.mip >= 1 && get_mobs(where)) view.actions.disperse_mob = 1 // Initiate Battle with Militia not stacked with General -- cgit v1.2.3