From 7d4f6e7a27d32f487b850b8b85a7e2753c1471ac Mon Sep 17 00:00:00 2001 From: iainp5 Date: Mon, 11 Nov 2024 17:49:19 +0000 Subject: Fixing adjacency not counting space 0 --- rules.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/rules.js b/rules.js index a5802f6..9b8cb6f 100644 --- a/rules.js +++ b/rules.js @@ -2447,17 +2447,15 @@ function count_adj(id) { let adjacent_spaces = get_adjusted_adjacency(space.space_id) for (let adj_space_id of adjacent_spaces) { - if (adj_space_id) { - const adj_piece = spaces.find(piece => piece && piece.space_id === adj_space_id); - if (adj_piece && adj_piece.space_id !== space.space_id) { - if (check_dem_control(adj_piece.space_id)) { - dem_adj++ - } - if (check_com_control(adj_piece.space_id)) { - com_adj++ - } - } - } + const adj_piece = spaces.find(piece => piece.space_id === adj_space_id); + if (adj_piece.space_id !== space.space_id) { + if (check_dem_control(adj_piece.space_id)) { + dem_adj++ + } + if (check_com_control(adj_piece.space_id)) { + com_adj++ + } + } } return {dem_adj, com_adj} } @@ -4775,14 +4773,10 @@ function vm_eliminate(space_id) { // Eliminate the democrat influence and move t } } - function get_adjusted_adjacency(space_id) { let adjacent_spaces = spaces[space_id].adjacent; if (adjacent_spaces.includes(game.systematization)) { - } - if (game.systematization !== 0) { let eliminated_space_id = game.systematization; - return adjacent_spaces.map(adj_space_id => { if (adj_space_id === eliminated_space_id) { return spaces[eliminated_space_id].adjacent; -- cgit v1.2.3