From ba443fd64e8597bd4f4f2a6199540205672eb737 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 27 Jan 2022 01:03:28 +0100 Subject: Don't highlight Lanark or Badenoch if only Norse/French remain in pool. --- rules.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 85c976d..e1e9b1b 100644 --- a/rules.js +++ b/rules.js @@ -250,6 +250,14 @@ function count_blocks_in_area(where) { return count; } +function count_blocks_in_area_excluding(where, exc) { + let count = 0; + for (let b in BLOCKS) + if (game.location[b] === where && !exc.includes(b)) + ++count; + return count; +} + function castle_limit(where) { if (game.active === SCOTLAND && is_cathedral_area(where)) return AREAS[where].limit + 1; @@ -2646,6 +2654,16 @@ function goto_scottish_builds() { clear_undo(); } +function can_build_scottish_block_in(where) { + if (is_under_castle_limit(where)) { + if (where === "Lanark" || where === "Badenoch") + return count_blocks_in_area_excluding(S_BAG, [ NORSE, FRENCH_KNIGHTS ]) > 0; + else + return count_blocks_in_area(S_BAG) > 0; + } + return false; +} + states.scottish_builds = { prompt: function (view, current) { if (is_inactive_player(current)) @@ -2662,7 +2680,7 @@ states.scottish_builds = { can_build = true; } } - if (is_under_castle_limit(where) && count_blocks_in_area(S_BAG) > 0) { + if (can_build_scottish_block_in(where)) { gen_action(view, 'area', where); can_build = true; } -- cgit v1.2.3