summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-21 11:07:12 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-21 11:07:12 +0200
commitdc5f239a7a4fef1547aae175b1d1a0105b748ca9 (patch)
treed5dc25a688be7406502b041373470b4c69863075 /rules.js
parent64ce021aa5567937f06ce8df350368b32faacdec (diff)
downloadfriedrich-dc5f239a7a4fef1547aae175b1d1a0105b748ca9.tar.gz
Fix missing argument in recruitment possibility checks.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/rules.js b/rules.js
index 5a7cf75..6280bbe 100644
--- a/rules.js
+++ b/rules.js
@@ -1961,12 +1961,20 @@ states.re_enter_choose_city = {
},
}
-function has_re_entry_space(p) {
- let can_re_enter_at = is_general(p) ? can_re_enter_general : can_re_enter_supply_train
+function has_re_entry_space_for_general() {
if (game.recruit.re_enter < ELIMINATED)
- return can_re_enter_at(game.recruit.re_enter)
+ return can_re_enter_general(game.recruit.re_enter)
for (let s of all_power_depots[game.power])
- if (can_re_enter_at(s))
+ if (can_re_enter_general(s))
+ return true
+ return false
+}
+
+function has_re_entry_space_for_supply_train() {
+ if (game.recruit.re_enter < ELIMINATED)
+ return can_re_enter_supply_train(game.recruit.re_enter)
+ for (let s of all_power_depots[game.power])
+ if (can_re_enter_supply_train(s))
return true
return false
}
@@ -1992,10 +2000,10 @@ function can_recruit_anything() {
if (unused_everywhere > 0 && unused_on_map > 0)
return true
// can re-enter eliminated generals
- if (unused_everywhere > 0 && elim_generals > 0 && has_re_entry_space())
+ if (unused_everywhere > 0 && elim_generals > 0 && has_re_entry_space_for_general())
return true
// can re-enter eliminated supply trains
- if (elim_trains > 0 && has_re_entry_space())
+ if (elim_trains > 0 && has_re_entry_space_for_supply_train())
return true
return false
}
@@ -2050,13 +2058,13 @@ states.recruit = {
continue
gen_action_supreme_commander(s)
}
- else if (game.pos[p] === ELIMINATED && has_re_entry_space(p))
+ else if (game.pos[p] === ELIMINATED && has_re_entry_space_for_general())
gen_action_piece(p)
}
}
if (av_trains > 0) {
for (let p of all_power_trains[game.power]) {
- if (game.pos[p] === ELIMINATED && has_re_entry_space(p))
+ if (game.pos[p] === ELIMINATED && has_re_entry_space_for_supply_train())
gen_action_piece(p)
}
}