diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-01-28 16:26:47 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-28 16:26:47 +0100 |
commit | 39f63d040a198f0d7e57dc41f4e68576141217e2 (patch) | |
tree | c713f04d1c802c3afe33b6bc32f0d2fc422c4357 /rules.js | |
parent | 83c39615adacfaaf740fecad916ad9576b4e6e9d (diff) | |
download | waterloo-campaign-1815-39f63d040a198f0d7e57dc41f4e68576141217e2.tar.gz |
Fix placement possibility checks for old guard and grand battery.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -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() { |