summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-01-17 19:02:17 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:39 +0100
commit48c8d494e2467ffb69b3bc6c42bc832f6474419c (patch)
treede97c79f93955b54f0d5542059a3c79fa57247bb
parented0e937ab1e53afcd16a98f74e7a6be76fee2553 (diff)
downloadnevsky-48c8d494e2467ffb69b3bc6c42bc832f6474419c.tar.gz
Lord Events (battle).
-rw-r--r--play.html37
-rw-r--r--play.js37
-rw-r--r--rules.js2
3 files changed, 68 insertions, 8 deletions
diff --git a/play.html b/play.html
index 0053be3..2498ae6 100644
--- a/play.html
+++ b/play.html
@@ -137,11 +137,10 @@ body.Teutons #plan_actions .russian { display: none }
#battle_grid #grid_ga {
width: 376px;
- height: 48px;
-}
-
-#battle_grid #grid_ga > div {
- margin: 0 auto;
+ height: 60px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
}
#grid_rd1:empty:not(.action), #grid_rd2:empty:not(.action), #grid_rd3:empty:not(.action),
@@ -281,11 +280,33 @@ body.Teutons #plan_actions .russian { display: none }
gap: 0px;
}
-body.shift .capabilities {
- z-index: 200;
+.mat .events {
+ position: absolute;
+ z-index: 3;
+ width: 372px;
+ height: 260px;
+ left: 2px;
+ top: -36px;
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ gap: 0px;
+ transition-property: top;
+ transition-duration: 100ms;
+}
+
+.mat .events:hover {
+ top: -130px;
+}
+
+.mat .events:empty {
+ display: none;
}
-body.shift #capabilities1, body.shift #capabilities2 {
+body.shift .capabilities,
+body.shift .events,
+body.shift #capabilities1,
+body.shift #capabilities2 {
z-index: 200;
}
diff --git a/play.js b/play.js
index a30a8a7..be1c458 100644
--- a/play.js
+++ b/play.js
@@ -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
}
diff --git a/rules.js b/rules.js
index 4e9cda8..3e5e5f3 100644
--- a/rules.js
+++ b/rules.js
@@ -6638,6 +6638,7 @@ function action_battle_events(c) {
states.bridge = {
prompt() {
view.prompt = "Bridge: Play on a Center Lord."
+ view.what = game.what
let array = game.battle.array
if (is_attacker()) {
if (array[D2] !== NOBODY)
@@ -6662,6 +6663,7 @@ states.bridge = {
states.field_organ = {
prompt() {
view.prompt = "Field Organ: Play on a Lord."
+ view.what = game.what
let array = game.battle.array
if (is_attacker()) {
for (let pos of battle_attacking_positions)