summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/rules.js b/rules.js
index 1e01c09..5fcc9a2 100644
--- a/rules.js
+++ b/rules.js
@@ -1061,7 +1061,7 @@ function can_train_move_anywhere(p) {
function can_general_move_anywhere(p) {
let from = game.pos[p]
for (let to of data.cities.adjacent[from])
- if (can_move_general_in_theory(p, to))
+ if (can_move_general_to(from, to))
return true
return false
}
@@ -1158,26 +1158,25 @@ function can_move_train_to(to) {
return !has_any_piece(to)
}
-function can_move_general_in_theory(_p, to) {
- if (has_friendly_supply_train(to))
- return false
- if (has_non_cooperative_general(to))
- return false
- if (has_enemy_supply_train(to))
- return false
- if (count_generals(to) >= 2)
- return false
- return true
+function is_illegal_cross_map_move(from, to) {
+ return (
+ game.power !== P_FRANCE && game.power !== P_AUSTRIA && (
+ (is_flanders_space(from) && is_bohemia_space(to)) ||
+ (is_flanders_space(to) && is_bohemia_space(from))
+ )
+ )
}
-function can_move_general_to(to) {
+function can_move_general_to(from, to) {
+ if (is_illegal_cross_map_move(from, to))
+ return false
if (has_friendly_supply_train(to))
return false
if (has_non_cooperative_general(to))
return false
if (has_enemy_supply_train(to))
return false
- if (game.selected.length + count_generals(to) > 2)
+ if (count_generals(to) >= 2)
return false
return true
}
@@ -1335,12 +1334,12 @@ states.move_general = {
if (game.count < movement_range() + game.main)
for (let next of data.cities.main_roads[here])
- if (can_move_general_to(next))
+ if (can_move_general_to(here, next))
gen_action_space_or_piece(next)
if (game.count < movement_range())
for (let next of data.cities.roads[here])
- if (can_move_general_to(next))
+ if (can_move_general_to(here, next))
gen_action_space_or_piece(next)
},
take() {
@@ -1400,10 +1399,12 @@ function search_force_march(came_from, start) {
continue
if (is_enemy_controlled_fortress(next))
continue
- if (has_any_piece(next))
+ if (has_enemy_piece(next))
continue
if (is_adjacent_to_enemy_piece(next))
continue
+ if (!can_move_general_to(here, next))
+ continue
if (came_from)
map_set(came_from, next, here)
set_add(seen, next)