summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-01-27 01:03:28 +0100
committerTor Andersson <tor@ccxvii.net>2022-11-17 12:53:18 +0100
commitba443fd64e8597bd4f4f2a6199540205672eb737 (patch)
tree385e6cbc1e2a3e710ecd12fc47d4e9599d6b3ccb /rules.js
parentc7f8596e8fa6aba108f6ff92791d0e9f4b41d39c (diff)
downloadhammer-of-the-scots-ba443fd64e8597bd4f4f2a6199540205672eb737.tar.gz
Don't highlight Lanark or Badenoch if only Norse/French remain in pool.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js20
1 files changed, 19 insertions, 1 deletions
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;
}