diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-11-26 14:37:43 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:37 +0100 |
commit | 1eb2d8cd1c5ea7615dde76e7352df1f0a14b71ab (patch) | |
tree | d1252afec40a97c415d35ef3daf2823199be78ae | |
parent | 9c3cb0ded87e15d4eb6524f299b8ca0ce47f1eea (diff) | |
download | nevsky-1eb2d8cd1c5ea7615dde76e7352df1f0a14b71ab.tar.gz |
Lieutenants.
-rw-r--r-- | play.html | 3 | ||||
-rw-r--r-- | play.js | 75 | ||||
-rw-r--r-- | rules.js | 7 |
3 files changed, 78 insertions, 7 deletions
@@ -739,6 +739,9 @@ body.shift .mustered_vassals { width: 44px; height: 48px; background-size: 44px 48px; +} + +.cylinder:not(.lieutenant) { filter: drop-shadow(0px 2px 4px #0004); } @@ -56,6 +56,38 @@ function max_plan_length() { } } +function map_has(map, key) { + let a = 0 + let b = (map.length >> 1) - 1 + while (a <= b) { + let m = (a + b) >> 1 + let x = map[m<<1] + if (key < x) + b = m - 1 + else if (key > x) + a = m + 1 + else + return true + } + return false +} + +function map_get(map, key, missing) { + let a = 0 + let b = (map.length >> 1) - 1 + while (a <= b) { + let m = (a + b) >> 1 + let x = map[m<<1] + if (key < x) + b = m - 1 + else if (key > x) + a = m + 1 + else + return map[(m<<1)+1] + } + return missing +} + function set_has(set, item) { let a = 0 let b = set.length - 1 @@ -203,6 +235,21 @@ function for_each_russian_card(fn) { fn(i) } +function is_upper_lord(lord) { + return map_has(view.lords.lieutenants, lord) +} + +function is_lower_lord(lord) { + for (let i = 1; i < view.lords.lieutenants.length; i += 2) + if (view.lords.lieutenants[i] === lord) + return true + return false +} + +function get_lower_lord(upper) { + return map_get(view.lords.lieutenants, upper, -1) +} + function for_each_friendly_card(fn) { if (player === "Teutons") for_each_teutonic_card(fn) @@ -545,12 +592,20 @@ function on_log(text) { return p } -function layout_locale_item(loc, e) { +function layout_locale_item(loc, e, is_upper) { let [x, y] = locale_xy[loc] + let z = 0 + if (is_upper) { + y -= 18 + z = 1 + } x += locale_layout[loc] * 44 + e.classList.toggle("lieutenant", is_upper) e.style.top = (y - 23) + "px" e.style.left = (x - 23) + "px" - locale_layout[loc] ++ + e.style.zIndex = z + if (!is_upper) + locale_layout[loc] ++ } function layout_calendar() { @@ -691,7 +746,21 @@ function update_lord(ix) { } if (locale < 100) { calendar_layout_service[service].push(ui.lord_service[ix]) - layout_locale_item(locale, ui.lord_cylinder[ix]) + + if (!is_lower_lord(ix)) { + if (is_upper_lord(ix)) { + let lo = get_lower_lord(ix) + if (view.lords.locale[lo] === locale) { + layout_locale_item(locale, ui.lord_cylinder[ix], 1) + layout_locale_item(locale, ui.lord_cylinder[lo], 0) + } else { + layout_locale_item(locale, ui.lord_cylinder[ix], 0) + } + } else { + layout_locale_item(locale, ui.lord_cylinder[ix], 0) + } + } + ui.lord_cylinder[ix].classList.remove("hide") ui.lord_service[ix].classList.remove("hide") ui.lord_mat[ix].classList.remove("hide") @@ -397,9 +397,9 @@ function count_cards_in_plan(plan, lord) { function is_marshal(lord) { switch (lord) { case LORD_ANDREAS: return true - case LORD_HERMANN: return is_lord_on_map(LORD_ANDREAS) + case LORD_HERMANN: return !is_lord_on_map(LORD_ANDREAS) case LORD_ALEKSANDR: return true - case LORD_ANDREY: return is_lord_on_map(LORD_ALEKSANDR) + case LORD_ANDREY: return !is_lord_on_map(LORD_ALEKSANDR) default: return false } } @@ -1524,8 +1524,7 @@ states.campaign_plan = { gen_action_plan(NOBODY) for (let lord = first; lord <= last; ++lord) { if (is_lord_on_map(lord) && count_cards_in_plan(plan, lord) < 3) - if (!is_lower_lord(lord)) - gen_action_plan(lord) + gen_action_plan(lord) } } else { if (upper === NOBODY) |