diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-08-30 00:05:07 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:26 +0100 |
commit | a2e6df7b4b0428ed59f732541a3f7b3f0c98f183 (patch) | |
tree | 348281fe79d275b3e9ad168fd618939fb72e6832 | |
parent | cd4a4fc13562d51fbfc2806141f2df808d24388f (diff) | |
download | rommel-in-the-desert-a2e6df7b4b0428ed59f732541a3f7b3f0c98f183.tar.gz |
Don't regroup retreat to enemy hex!
Auto-target non-artillery.
-rw-r--r-- | rules.js | 39 |
1 files changed, 26 insertions, 13 deletions
@@ -3863,20 +3863,20 @@ function can_select_retreat_hex() { if (is_valid_retreat_hex(game.from2)) return true - if (game.to1) { + if (game.to1 && !has_undisrupted_enemy_unit(game.to1)) { let result = false for_each_hex_and_adjacent_hex(game.from1, x => { - if (result === false && is_valid_retreat_hex(x)) + if (result === false && x !== game.to1 && is_valid_retreat_hex(x)) result = true }) if (result) return true } - if (game.to2) { + if (game.to2 && !has_undisrupted_enemy_unit(game.to2)) { let result = false for_each_hex_and_adjacent_hex(game.from2, x => { - if (result === false && is_valid_retreat_hex(x)) + if (result === false && x !== game.to2 && is_valid_retreat_hex(x)) result = true }) if (result) @@ -4747,14 +4747,27 @@ function apply_auto_target() { return apply_battle_fire(INFANTRY) // only one class remains - if (hp[ARMOR] > 0 && hp[INFANTRY] === 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] === 0) - return apply_battle_fire(ARMOR) - if (hp[ARMOR] === 0 && hp[INFANTRY] > 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] === 0) - return apply_battle_fire(INFANTRY) - if (hp[ARMOR] === 0 && hp[INFANTRY] === 0 && hp[ANTITANK] > 0 && hp[ARTILLERY] === 0) - return apply_battle_fire(ANTITANK) - if (hp[ARMOR] === 0 && hp[INFANTRY] === 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] > 0) - return apply_battle_fire(ARTILLERY) + if (fc === ARTILLERY) { + // Artillery may always target anything + if (hp[ARMOR] > 0 && hp[INFANTRY] === 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] === 0) + return apply_battle_fire(ARMOR) + if (hp[ARMOR] === 0 && hp[INFANTRY] > 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] === 0) + return apply_battle_fire(INFANTRY) + if (hp[ARMOR] === 0 && hp[INFANTRY] === 0 && hp[ANTITANK] > 0 && hp[ARTILLERY] === 0) + return apply_battle_fire(ANTITANK) + if (hp[ARMOR] === 0 && hp[INFANTRY] === 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] > 0) + return apply_battle_fire(ARTILLERY) + } else { + // Non-artillery may only target artillery if no other targets remain + if (hp[ARMOR] > 0 && hp[INFANTRY] === 0 && hp[ANTITANK] === 0) + return apply_battle_fire(ARMOR) + if (hp[ARMOR] === 0 && hp[INFANTRY] > 0 && hp[ANTITANK] === 0) + return apply_battle_fire(INFANTRY) + if (hp[ARMOR] === 0 && hp[INFANTRY] === 0 && hp[ANTITANK] > 0) + return apply_battle_fire(ANTITANK) + if (hp[ARMOR] === 0 && hp[INFANTRY] === 0 && hp[ANTITANK] === 0 && hp[ARTILLERY] > 0) + return apply_battle_fire(ARTILLERY) + } } function gen_battle_hits() { @@ -5336,7 +5349,7 @@ states.buildup_eliminate_unsupplied = { }) }, unit(u) { - log(`Eliminated at #${unit_hex(u)}`) + log(`Eliminated at #${unit_hex(u)}.`) eliminate_unit(u) resume_buildup_eliminate_unsupplied() }, |