summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/rules.js b/rules.js
index 5a8e9d8..e361702 100644
--- a/rules.js
+++ b/rules.js
@@ -2367,7 +2367,7 @@ function is_adjacent_to_enemy_piece(here) {
return false
}
-function search_force_march(p, came_from, start) {
+function search_force_march(p, came_from, start, range) {
let seen = [ start ]
let queue = [ start << 4 ]
while (queue.length > 0) {
@@ -2388,7 +2388,7 @@ function search_force_march(p, came_from, start) {
if (came_from)
map_set(came_from, next, here)
set_add(seen, next)
- if (dist < 8)
+ if (dist < range && !has_any_piece(next))
queue.push((next << 4) | dist)
}
}
@@ -2396,22 +2396,25 @@ function search_force_march(p, came_from, start) {
return seen
}
-// WONTFIX: choose not-shortest path to capture hussars during force march?
states.force_march = {
inactive: "move",
prompt() {
- prompt("Force March " + format_selected() + ".")
+ prompt(`Force March ${format_selected()} up to ${8-game.count} cities.`)
view.selected = game.selected
let here = game.pos[game.selected]
- for (let s of search_force_march(game.selected, null, here))
- gen_action_space(s)
+ if (game.count < 8)
+ for (let s of search_force_march(game.selected, null, here, 8 - game.count))
+ gen_action_space(s)
+ if (game.count > 0)
+ view.actions.stop = 1
},
space(to) {
let here = game.pos[game.selected]
let came_from = []
+ let stop = false
- search_force_march(game.selected, came_from, here)
+ search_force_march(game.selected, came_from, here, 8 - game.count)
let path = []
while (to !== here) {
@@ -2421,9 +2424,14 @@ states.force_march = {
for (let s of path) {
game.move_path.push(s)
- move_general_to(s, true)
+ stop = move_general_to(s, true)
+ ++game.count
}
+ if (game.count === 8 || stop)
+ end_move_piece()
+ },
+ stop() {
end_move_piece()
},
}