diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-06-19 22:17:16 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-16 19:19:38 +0100 |
commit | ce43a7e11f7d69427fb397c14b332e96ab47cef8 (patch) | |
tree | ff31ea0f9bf2ed7361934e63dcd199636b2c420a /rules.js | |
parent | 56b024da4ed65214b4190ec487b68bcca9092dd2 (diff) | |
download | crusader-rex-ce43a7e11f7d69427fb397c14b332e96ab47cef8.tar.gz |
crusader: optimize muster checks
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 24 |
1 files changed, 6 insertions, 18 deletions
@@ -437,12 +437,8 @@ function can_block_muster_with_3_moves(n0, muster) { if (can_block_use_road_to_muster(n1, n2)) { if (n2 == muster) return true; - for (let n3 of TOWNS[n2].exits) { - if (can_block_use_road_to_muster(n2, n3)) { - if (n3 == muster) - return true; - } - } + if (TOWNS[n2].exits.includes(muster)) + return can_block_use_road_to_muster(n2, muster); } } } @@ -455,24 +451,16 @@ function can_block_muster_with_2_moves(n0, muster) { if (can_block_use_road_to_muster(n0, n1)) { if (n1 == muster) return true; - for (let n2 of TOWNS[n1].exits) { - if (can_block_use_road_to_muster(n1, n2)) { - if (n2 == muster) - return true; - } - } + if (TOWNS[n1].exits.includes(muster)) + return can_block_use_road_to_muster(n1, muster); } } return false; } function can_block_muster_with_1_move(n0, muster) { - for (let n1 of TOWNS[n0].exits) { - if (can_block_use_road_to_muster(n0, n1)) { - if (n1 == muster) - return true; - } - } + if (TOWNS[n0].exits.includes(muster)) + return can_block_use_road_to_muster(n0, muster); return false; } |