summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-25 18:56:40 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-26 13:03:44 +0200
commitefe7923ebe128ae76cfa597c8e89cd6199a5cab6 (patch)
tree09e49d432fe40d3a4d3f86e245646e330944e419 /rules.js
parent2dadb8de216a3fd46a8f692c66f03336c4f71d00 (diff)
downloadwaterloo-campaign-1815-efe7923ebe128ae76cfa597c8e89cd6199a5cab6.tar.gz
Fix forbidden hex lists and label which overlay is visible.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/rules.js b/rules.js
index f5367c4..a1782d3 100644
--- a/rules.js
+++ b/rules.js
@@ -26,8 +26,8 @@ const TURN_NAME = [
const last_hex = 1000 + (data.map.rows - 1) * 100 + (data.map.cols - 1)
-const p1_forbidden = data.map.forbidden[0]
-const p2_forbidden = data.map.forbidden[1]
+const p1_forbidden_entry = data.map.forbidden[0]
+const p2_forbidden_entry = data.map.forbidden[1]
var move_seen = new Array(last_hex - 999).fill(0)
var move_cost = new Array(last_hex - 999).fill(0)
@@ -162,6 +162,27 @@ for (let road_id = 0; road_id < data.map.roads.length; ++road_id) {
}
}
+const p1_forbidden = []
+const p2_forbidden = []
+
+function calc_forbidden(set, a) {
+ set_add(set, a)
+ for_each_adjacent(a, b => {
+ if (!is_river(a, b)) {
+ set_add(set, b)
+ for_each_adjacent(b, c => {
+ if (!is_river(b, c))
+ set_add(set, c)
+ })
+ }
+ })
+}
+
+for (let entry of p1_forbidden_entry)
+ calc_forbidden(p1_forbidden, entry)
+for (let entry of p2_forbidden_entry)
+ calc_forbidden(p2_forbidden, entry)
+
function make_piece_list(f) {
let list = []
for (let p = 0; p < data.pieces.length; ++p)