summaryrefslogtreecommitdiff
path: root/play.js
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 /play.js
parent08eed041748e9e64c175d09e8877f6d4afd0cfd6 (diff)
downloadnevsky-11e1d172acbddb520419e458b51190e20d2c5755.tar.gz
Fix Yaroslav shield. Fade ambushed lord mats.
Diffstat (limited to 'play.js')
-rw-r--r--play.js50
1 files changed, 49 insertions, 1 deletions
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() {