summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-12-28 17:36:34 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:38 +0100
commit3c8c0e53100ad8abe575b923e5d0f1f5474e40af (patch)
tree385d8d87da7bf515fea592ac3e44aecdd38d47ec
parent298695de12eac0884e1aa6b416b1300694e0ae70 (diff)
downloadnevsky-3c8c0e53100ad8abe575b923e5d0f1f5474e40af.tar.gz
Lift siege after retreat.
-rw-r--r--play.html9
-rw-r--r--play.js18
-rw-r--r--rules.js13
3 files changed, 36 insertions, 4 deletions
diff --git a/play.html b/play.html
index 360e114..a6c2d94 100644
--- a/play.html
+++ b/play.html
@@ -343,6 +343,10 @@ body.Teutons #plan_actions .russian { display: none }
z-index: 4;
}
+.mat.besieged .background {
+ filter: grayscale(50%)
+}
+
.mat.selected .background {
box-shadow: 0 0 0 1px #584800, 0 0 0 3px yellow;
}
@@ -935,6 +939,11 @@ body.shift .mustered_vassals {
filter: drop-shadow(0px 2px 4px #0004);
}
+#map .cylinder.besieged {
+ filter: grayscale(50%);
+ transform: translateY(8px)
+}
+
.cylinder.action {
filter:
drop-shadow(2px 0px 0px white)
diff --git a/play.js b/play.js
index e9c0b17..8e9c523 100644
--- a/play.js
+++ b/play.js
@@ -180,11 +180,24 @@ function pack1_get(word, n) {
return (word >>> n) & 1
}
+function pack2_get(word, n) {
+ n = n << 1
+ return (word >>> n) & 3
+}
+
function pack4_get(word, n) {
n = n << 2
return (word >>> n) & 15
}
+function is_lord_besieged(lord) {
+ return pack1_get(view.pieces.besieged, lord)
+}
+
+function is_lord_moved(lord) {
+ return pack2_get(view.pieces.moved, lord) > 0
+}
+
function is_veche_action() {
return !!(view.actions && view.actions.veche === 1)
}
@@ -1079,6 +1092,8 @@ function update_lord(ix) {
ui.lord_cylinder[ix].classList.remove("hide")
ui.lord_service[ix].classList.add("hide")
}
+ ui.lord_cylinder[ix].classList.toggle("besieged", is_lord_besieged(ix))
+ ui.lord_cylinder[ix].classList.toggle("moved", is_lord_moved(ix))
ui.lord_buttons[ix].classList.toggle("action", is_lord_action(ix))
ui.lord_cylinder[ix].classList.toggle("action", is_lord_action(ix))
ui.lord_service[ix].classList.toggle("action", is_service_action(ix))
@@ -1093,6 +1108,9 @@ function update_lord(ix) {
else
ui.lord_cylinder[ix].classList.toggle("selected", is_cylinder_selected(ix))
ui.lord_mat[ix].classList.toggle("selected", is_lord_mat_selected(ix))
+
+ ui.lord_mat[ix].classList.toggle("besieged", is_lord_besieged(ix))
+ ui.lord_mat[ix].classList.toggle("moved", is_lord_moved(ix))
}
function update_legate() {
diff --git a/rules.js b/rules.js
index 628d228..f1cfdec 100644
--- a/rules.js
+++ b/rules.js
@@ -1,6 +1,5 @@
"use strict"
-// NEXT: choose left/right when center flanking
// NEXT: hit remainders
// TODO: SALLY
// TODO: STORM
@@ -3393,10 +3392,10 @@ function lift_siege(from) {
if (has_siege_marker(from)) {
log(`Lifted siege at %${from}.`)
remove_all_siege_markers(from)
- for (let lord = first_lord; lord <= last_lord; ++lord)
- if (get_lord_locale(lord) === from && is_lord_besieged(lord))
- set_lord_besieged(lord, 0)
}
+ for (let lord = first_lord; lord <= last_lord; ++lord)
+ if (get_lord_locale(lord) === from && is_lord_besieged(lord))
+ set_lord_besieged(lord, 0)
}
function group_has_teutonic_converts() {
@@ -3574,6 +3573,7 @@ function march_with_group_3() {
remove_legate_if_endangered(here)
if (is_besieged_friendly_stronghold(here)) {
+ // TODO if (is_besieged_enemy_stronghold(from) && !has_friendly_lord(from))
lift_siege(here)
}
@@ -4614,6 +4614,7 @@ states.sail = {
game.pieces.legate = to
if (is_enemy_stronghold(from))
+ // TODO if (is_besieged_enemy_stronghold(from) && !has_friendly_lord(from))
lift_siege(from)
remove_legate_if_endangered(from)
@@ -6112,6 +6113,10 @@ function goto_retreat() {
}
function end_retreat() {
+ let from = game.battle.where
+ if (is_enemy_stronghold(from) && !has_friendly_lord(from))
+ lift_siege(from)
+
goto_battle_remove()
}