summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-01-28 16:26:47 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-28 16:26:47 +0100
commit39f63d040a198f0d7e57dc41f4e68576141217e2 (patch)
treec713f04d1c802c3afe33b6bc32f0d2fc422c4357
parent83c39615adacfaaf740fecad916ad9576b4e6e9d (diff)
downloadwaterloo-campaign-1815-master.tar.gz
Fix placement possibility checks for old guard and grand battery.HEADmaster
-rw-r--r--rules.js35
1 files changed, 31 insertions, 4 deletions
diff --git a/rules.js b/rules.js
index 51c71e4..137e3ff 100644
--- a/rules.js
+++ b/rules.js
@@ -923,17 +923,44 @@ function can_place_detachment(p, hq) {
let x = piece_hex(p)
if (x === AVAILABLE_P1 || x === AVAILABLE_P2) {
if (pieces_are_associated(p, hq)) {
- if (p === GRAND_BATTERY || p === OLD_GUARD) {
+
+ if (p === GRAND_BATTERY) {
+ if (hq === NAPOLEON_HQ && piece_mode(NAPOLEON_HQ))
+ return can_place_detachment_grand_battery()
+ return false
+ }
+
+ if (p === OLD_GUARD) {
if (hq === NAPOLEON_HQ && piece_mode(NAPOLEON_HQ))
- return can_place_detachment_anywhere()
- } else {
- return can_place_detachment_anywhere()
+ return can_place_detachment_old_guard()
+ return false
}
+
+ return can_place_detachment_anywhere()
}
}
return false
}
+function can_place_detachment_grand_battery() {
+ for (let p of friendly_units()) {
+ let x = piece_hex(p)
+ if (calc_distance(piece_hex(NAPOLEON_HQ), x) <= 3)
+ if (!hex_has_any_piece(x, p1_det))
+ return true
+ }
+ return false
+}
+
+function can_place_detachment_old_guard() {
+ let result = false
+ for_each_within_x3(piece_hex(NAPOLEON_HQ), (next) => {
+ if (!is_enemy_zoc(next) && is_empty_hex(next))
+ result = true
+ })
+ return result
+}
+
states.place_detachment_hq = {
inactive: "place detachments",
prompt() {