From efe7923ebe128ae76cfa597c8e89cd6199a5cab6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 25 Oct 2023 18:56:40 +0200 Subject: Fix forbidden hex lists and label which overlay is visible. --- rules.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'rules.js') 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) -- cgit v1.2.3