summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-01-25 23:42:40 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:39 +0100
commit11e1d172acbddb520419e458b51190e20d2c5755 (patch)
treeecbfaaf4ec1f848343d3c1b76579857d68f69511
parent08eed041748e9e64c175d09e8877f6d4afd0cfd6 (diff)
downloadnevsky-11e1d172acbddb520419e458b51190e20d2c5755.tar.gz
Fix Yaroslav shield. Fade ambushed lord mats.
-rw-r--r--play.html17
-rw-r--r--play.js50
2 files changed, 61 insertions, 6 deletions
diff --git a/play.html b/play.html
index a7add68..3f3e662 100644
--- a/play.html
+++ b/play.html
@@ -304,6 +304,10 @@ body.Teutons #plan_actions .russian { display: none }
filter: grayscale(50%)
}
+#battle_grid .mat.ambushed .background {
+ filter: grayscale(50%)
+}
+
.court_body .mat.hidden .background {
filter: grayscale(100%)
}
@@ -430,7 +434,10 @@ body.shift .mustered_vassals {
margin-top: -38px;
}
-.mat .shield { position: absolute; }
+.mat .shield {
+ position: absolute;
+ background-repeat: no-repeat;
+}
.mat.teutonic .shield {
top: 10px; left: 6px;
@@ -447,13 +454,13 @@ body.shift .mustered_vassals {
filter: drop-shadow(0 0 3px white);
}
-.mat.russian .shield.action, .mat.yaroslav .shield.action {
- background-image: url(images/shield_russian.svg);
+.mat.teutonic .shield.action {
+ background-image: url(images/shield_teutonic.svg);
filter: drop-shadow(0 0 3px white);
}
-.mat.teutonic .shield.action {
- background-image: url(images/shield_teutonic.svg);
+.mat.russian .shield.action, .mat.yaroslav .shield.action {
+ background-image: url(images/shield_russian.svg);
filter: drop-shadow(0 0 3px white);
}
diff --git a/play.js b/play.js
index 99030e8..bb25d4c 100644
--- a/play.js
+++ b/play.js
@@ -27,8 +27,18 @@ const EVENT_TEUTONIC_FIELD_ORGAN = T10
const AOW_TEUTONIC_TREBUCHETS = T14
-const RG2 = 10
+const A1 = 0 // attackers
+const A2 = 1
+const A3 = 2
+const D1 = 3 // defenders
+const D2 = 4
+const D3 = 5
+const SA1 = 6 // relief sally: attackers
const SA2 = 7
+const SA3 = 8
+const RG1 = 9 // relief sally: rearguard
+const RG2 = 10
+const RG3 = 11
const MAP_DPI = 75
@@ -234,6 +244,14 @@ function pack4_get(word, n) {
return (word >>> n) & 15
}
+function is_p1_lord(lord) {
+ return lord >= first_p1_lord && lord <= last_p1_lord
+}
+
+function is_p2_lord(lord) {
+ return lord >= first_p2_lord && lord <= last_p2_lord
+}
+
function is_lord_besieged(lord) {
let besieged = pack1_get(view.pieces.besieged, lord)
// show sallying lords as not besieged
@@ -242,6 +260,35 @@ function is_lord_besieged(lord) {
return besieged
}
+function is_lord_on_left_or_right(lord) {
+ if (view.battle.array[A1] === lord) return true
+ if (view.battle.array[A3] === lord) return true
+ if (view.battle.array[D1] === lord) return true
+ if (view.battle.array[D3] === lord) return true
+ if (view.battle.array[SA1] === lord) return true
+ if (view.battle.array[SA3] === lord) return true
+ if (view.battle.array[RG1] === lord) return true
+ if (view.battle.array[RG3] === lord) return true
+ return false
+}
+
+function is_lord_ambushed(lord) {
+ if (view.battle) {
+ if (view.battle.attacker === "Teutons") {
+ if ((view.battle.ambush & 2) && is_p1_lord(lord))
+ return is_lord_on_left_or_right(lord)
+ if ((view.battle.ambush & 1) && is_p2_lord(lord))
+ return is_lord_on_left_or_right(lord)
+ } else {
+ if ((view.battle.ambush & 2) && is_p2_lord(lord))
+ return is_lord_on_left_or_right(lord)
+ if ((view.battle.ambush & 1) && is_p1_lord(lord))
+ return is_lord_on_left_or_right(lord)
+ }
+ }
+ return false
+}
+
function is_teutonic_lord(lord) {
return lord >= first_p1_lord && lord <= last_p1_lord
}
@@ -1203,6 +1250,7 @@ function update_lord(ix) {
ui.lord_mat[ix].classList.toggle("command", is_lord_command(ix))
ui.lord_mat[ix].classList.toggle("besieged", is_lord_besieged(ix))
+ ui.lord_mat[ix].classList.toggle("ambushed", is_lord_ambushed(ix))
}
function update_legate() {