summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-06-21 15:49:27 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 18:39:37 +0200
commitf0ad2d92162d5faab8a5537a50f778febc442e9c (patch)
tree74928175d4746a7d7da96718485fe9d7134cbee2 /play.js
parent8b075ffb322b7f885aebe67d4712ffd008cb4878 (diff)
downloadtime-of-crisis-f0ad2d92162d5faab8a5537a50f778febc442e9c.tar.gz
Mobs (place and display).
Diffstat (limited to 'play.js')
-rw-r--r--play.js29
1 files changed, 27 insertions, 2 deletions
diff --git a/play.js b/play.js
index da6f215..18550e4 100644
--- a/play.js
+++ b/play.js
@@ -535,6 +535,7 @@ let ui = {
governors: [ [], [], [], [] ],
castra: [ [], [], [], [] ],
mcastra: [],
+ mobs: [],
}
function get_province_governor_player(where) {
@@ -602,6 +603,8 @@ function on_click_action(evt, target) {
function create_building(region, className, xoff, yoff) {
let [ x, y, w, h ] = LAYOUT_SUPPORT[region]
+ if (region === ITALIA)
+ y += 52
let e = create_thing({ className })
e.style.left = x + (w >> 1) + xoff - 46 + "px"
e.style.top = y + h + yoff + "px"
@@ -675,6 +678,11 @@ function on_init() {
ui.capital[region] = document.getElementById(REGION_NAME[region] + "_Capital")
ui.quaestor[region] = document.getElementById(REGION_NAME[region] + "_Quaestor")
+ // at most 3 mobs per province
+ ui.mobs[region * 3 + 0] = create_piece(region, "mob", "mob")
+ ui.mobs[region * 3 + 1] = create_piece(region, "mob", "mob")
+ ui.mobs[region * 3 + 2] = create_piece(region, "mob", "mob")
+
if (true) {
ui.amphitheater[region] = create_building(region, "amphitheater hide", -48 - 3, 6)
ui.basilica[region] = create_building(region, "basilica hide", 48 + 3, 6)
@@ -761,6 +769,17 @@ function layout_governor_unavailable(e, color, ix) {
e.className = color + " governor n" + ix
}
+function layout_mob(region, i, e, visible, x2) {
+ if (visible) {
+ let [ x, y, w ,h ] = LAYOUT_SUPPORT[region]
+ e.className = x2 ? "mob_x2" : "mob"
+ e.style.top = (y - 36) + "px"
+ e.style.left = (x + 26 + 26 * i) + "px"
+ } else {
+ e.className = "hide"
+ }
+}
+
function on_update() {
let player_count = view.legacy.length
@@ -945,6 +964,11 @@ function on_update() {
hide(ui.neutral_governors[region])
}
}
+
+ let n = view.mobs[region]
+ layout_mob(region, 0, ui.mobs[region * 3 + 0], n >= 1, n >= 2)
+ layout_mob(region, 1, ui.mobs[region * 3 + 1], n >= 3, n >= 4)
+ layout_mob(region, 2, ui.mobs[region * 3 + 2], n >= 5, n >= 6)
}
for (let pi = 0; pi < player_count; ++pi) {
@@ -1018,8 +1042,9 @@ function on_update() {
layout_available(avail_stack, avail_stack.length > 5 ? 43 : 58, pi * 625 + 325, 27)
}
- ui.body.classList.toggle("sel_governor", typeof view.selected_governor === "number")
- ui.body.classList.toggle("sel_general", typeof view.selected_general === "number")
+ ui.body.classList.toggle("military", view.color === 0)
+ ui.body.classList.toggle("senate", view.color === 1)
+ ui.body.classList.toggle("populace", view.color === 2)
ui.dice[0].className = "dice black d" + view.dice[0]
ui.dice[1].className = "dice white d" + view.dice[1]