summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-07-06 18:49:50 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 19:05:52 +0200
commitb1f87e0acdaf88d7759f8293598d42edd303be65 (patch)
treeddaa0627df65d194d9758fcefc0ce0bf1c4ff028
parent593a5fb24156af994ab0a37b5bd3dc13a99c8e78 (diff)
downloadtime-of-crisis-b1f87e0acdaf88d7759f8293598d42edd303be65.tar.gz
Fix Militia + Capital action layout.
-rw-r--r--play.css1
-rw-r--r--play.js14
-rw-r--r--rules.js5
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