summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-12-26 01:13:58 +0100
committerTor Andersson <tor@ccxvii.net>2022-12-26 01:13:58 +0100
commit70658f1d0dd021b7a98dc82559e073cb717c9246 (patch)
tree04be986686fc00eeea878ad610ece6529e3bd330
parentb90061cc9ca2ce29e33a2e6e8347e7ae727f97bd (diff)
downloadrommel-in-the-desert-70658f1d0dd021b7a98dc82559e073cb717c9246.tar.gz
Forbid entering own map edge hexes.
-rw-r--r--rules.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index 7e5fc7a..4e78cd5 100644
--- a/rules.js
+++ b/rules.js
@@ -1622,15 +1622,19 @@ function search_redeploy(start) {
// Breadth First Search
function search_path_bfs(from, cost, start, road, max_cost, retreat, sline, sdist) {
let path_enemy, enemy_sides
+ let exit1, exit2
if (presence_invalid)
update_presence()
if (is_axis_player()) {
path_enemy = presence_allied
enemy_sides = game.allied_sides
+ exit1 = exit2 = 175
} else {
path_enemy = presence_axis
enemy_sides = game.axis_sides
+ exit1 = 99
+ exit2 = 148
}
from.fill(0)
@@ -1655,6 +1659,10 @@ function search_path_bfs(from, cost, start, road, max_cost, retreat, sline, sdis
if (next < first_hex || next > last_hex || !hex_exists[next])
continue
+ // can't enter own map edge
+ if (next === exit1 || next === exit2)
+ continue
+
// already seen
if (cost[next] < 15)
continue
@@ -1718,6 +1726,7 @@ function search_path_bfs(from, cost, start, road, max_cost, retreat, sline, sdis
function search_path_redeploy_bfs(cost, start, road) {
let path_enemy, friendly_network, enemy_network, enemy_sides
+ let exit1, exit2
if (presence_invalid)
update_presence()
@@ -1726,11 +1735,14 @@ function search_path_redeploy_bfs(cost, start, road) {
friendly_network = game.buildup.axis_network
enemy_network = game.buildup.allied_network
enemy_sides = game.allied_sides
+ exit1 = exit2 = 175
} else {
path_enemy = presence_axis
friendly_network = game.buildup.allied_network
enemy_network = game.buildup.axis_network
enemy_sides = game.axis_sides
+ exit1 = 99
+ exit2 = 148
}
cost.fill(63)
@@ -1754,6 +1766,10 @@ function search_path_redeploy_bfs(cost, start, road) {
if (next < first_hex || next > last_hex || !hex_exists[next])
continue
+ // can't enter own map edge
+ if (next === exit1 || next === exit2)
+ continue
+
// already seen
if (cost[next] < 63)
continue