summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-10-08 13:22:20 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 12:53:18 +0100
commitf25e26904ade3e0ec4711d50935b3999e6b92746 (patch)
tree7988fbf3cccdaf130fcd95abcb83ef5a2e3b330e
parent76e0db683c31956264275565911f27733ebc29f5 (diff)
downloadhammer-of-the-scots-f25e26904ade3e0ec4711d50935b3999e6b92746.tar.gz
Schiltroms optional rule.
-rw-r--r--create.html6
-rw-r--r--rules.js30
2 files changed, 35 insertions, 1 deletions
diff --git a/create.html b/create.html
index 8244612..1f37751 100644
--- a/create.html
+++ b/create.html
@@ -8,6 +8,12 @@
</dl>
<p>
+<label><input type="checkbox" id="schiltroms" name="schiltroms" value="true">
+Schiltroms:
+Scottish infantry fire at +1 when the English have no archers.
+</label>
+
+<p>
<label><input type="checkbox" id="delay_hits" name="delay_hits" value="true">
Fire with all blocks before assigning hits.
</label>
diff --git a/rules.js b/rules.js
index 8e80964..bc0de4e 100644
--- a/rules.js
+++ b/rules.js
@@ -280,9 +280,28 @@ function block_fire_power(who, where) {
else if (who === B_MORAY && where === AREA_MORAY)
++combat
}
+ if (game.schiltroms) {
+ if (is_scottish_infantry(who) && english_have_no_archers_in_battle(where))
+ ++combat
+ }
return combat
}
+function is_scottish_infantry(who) {
+ return block_owner(who) === SCOTLAND && block_type(who) === 'infantry'
+}
+
+function is_english_archers(who) {
+ return block_owner(who) === ENGLAND && block_type(who) === 'archers'
+}
+
+function english_have_no_archers_in_battle(where) {
+ for (let b = 0; b < block_count; ++b)
+ if (game.location[b] === where && is_english_archers(b) && !is_battle_reserve(b))
+ return false
+ return true
+}
+
function is_coastal_area(where) {
return AREAS[where].coastal
}
@@ -3048,6 +3067,8 @@ exports.setup = function (seed, scenario, options) {
if (options.rng)
game.rng = options.rng
+ log(".h1 " + scenario)
+
if (scenario === "The Bruce")
setup_the_bruce()
else if (scenario === "Braveheart")
@@ -3062,7 +3083,14 @@ exports.setup = function (seed, scenario, options) {
if (options.delay_hits)
game.delay_hits = 1
- log(".h1 " + scenario)
+ if (options.schiltroms) {
+ log("")
+ log("Schiltroms:")
+ logi("Scottish infantry fire at +1 in battles where the English have no archers.")
+ log("")
+ game.schiltroms = 1
+ }
+
start_year()
return game
}