summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js39
1 files changed, 26 insertions, 13 deletions
diff --git a/rules.js b/rules.js
index c8e75ac..c25e4f7 100644
--- a/rules.js
+++ b/rules.js
@@ -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()
},