diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-25 18:56:40 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-26 13:03:44 +0200 |
commit | efe7923ebe128ae76cfa597c8e89cd6199a5cab6 (patch) | |
tree | 09e49d432fe40d3a4d3f86e245646e330944e419 /rules.js | |
parent | 2dadb8de216a3fd46a8f692c66f03336c4f71d00 (diff) | |
download | waterloo-campaign-1815-efe7923ebe128ae76cfa597c8e89cd6199a5cab6.tar.gz |
Fix forbidden hex lists and label which overlay is visible.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -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) |