diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-01-17 19:02:17 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:39 +0100 |
commit | 48c8d494e2467ffb69b3bc6c42bc832f6474419c (patch) | |
tree | de97c79f93955b54f0d5542059a3c79fa57247bb /play.js | |
parent | ed0e937ab1e53afcd16a98f74e7a6be76fee2553 (diff) | |
download | nevsky-48c8d494e2467ffb69b3bc6c42bc832f6474419c.tar.gz |
Lord Events (battle).
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -25,6 +25,18 @@ const LORD_HERMANN = find_lord("Hermann") const LORD_ALEKSANDR = find_lord("Aleksandr") const LORD_ANDREY = find_lord("Andrey") +function find_card(name) { + return data.cards.findIndex((x) => x.name === name) +} + +const R1 = find_card("R1") +const T4 = find_card("T4") +const T10 = find_card("T10") + +const EVENT_RUSSIAN_BRIDGE = R1 +const EVENT_TEUTONIC_BRIDGE = T4 +const EVENT_TEUTONIC_FIELD_ORGAN = T10 + const MAP_DPI = 75 const VASSAL_UNAVAILABLE = 0 @@ -41,6 +53,11 @@ const round = Math.round const floor = Math.floor const ceil = Math.ceil +const first_p1_lord = 0 +const last_p1_lord = 5 +const first_p2_lord = 6 +const last_p2_lord = 11 + const first_p1_card = 0 const last_p1_card = 20 const first_p2_card = 21 @@ -204,6 +221,14 @@ function is_lord_besieged(lord) { return besieged } +function is_teutonic_lord(lord) { + return lord >= first_p1_lord && lord <= last_p1_lord +} + +function is_russian_lord(lord) { + return lord >= first_p2_lord && lord <= last_p2_lord +} + function is_lord_moved(lord) { return pack2_get(view.pieces.moved, lord) > 0 } @@ -488,6 +513,7 @@ const ui = { ready_vassals: [], mustered_vassals: [], lord_capabilities: [], + lord_events: [], cards: [], boxes: {}, ways: [], @@ -1360,6 +1386,16 @@ function update_cards() { c = view.pieces.capabilities[(ix << 1) + 1] if (c >= 0) ui.lord_capabilities[ix].appendChild(ui.cards[c]) + + ui.lord_events[ix].replaceChildren() + if (view.battle && view.battle.field_organ === ix) + ui.lord_events[ix].appendChild(ui.cards[EVENT_TEUTONIC_FIELD_ORGAN]) + if (view.battle && view.battle.bridge && set_has(view.battle.bridge, ix)) { + if (is_teutonic_lord(ix)) + ui.lord_events[ix].appendChild(ui.cards[EVENT_RUSSIAN_BRIDGE]) + else + ui.lord_events[ix].appendChild(ui.cards[EVENT_TEUTONIC_BRIDGE]) + } } } @@ -1624,6 +1660,7 @@ function build_lord_mat(lord, ix, side, name) { ui.mustered_vassals[ix] = build_div(bg, "mustered_vassals") ui.lord_buttons[ix] = build_div(bg, "shield", ix, on_click_cylinder) ui.lord_capabilities[ix] = build_div(mat, "capabilities") + ui.lord_events[ix] = build_div(mat, "events") ui.lord_mat[ix] = mat } |