summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-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() {