diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-10-27 17:16:20 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-27 17:16:20 +0100 |
commit | fcc02419550fdda22abacd91b2196f9481efd2c7 (patch) | |
tree | 5c069f39537240aa405af6dbde49c24777c3e968 /rules.js | |
parent | 3e9f0e02ed19ca23970f540bca93906e9c615991 (diff) | |
download | maria-fcc02419550fdda22abacd91b2196f9481efd2c7.tar.gz |
Force March incrementally (to allow stomping hussars).
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -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() }, } |