summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-06-17 14:30:50 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 12:53:18 +0100
commit208df2953976067757e9477574fda56350b6407a (patch)
tree0d0de94a40ac12465e18e2d1490e513aaac033d0
parentd51cd110dba312f50dc6bc8227f382d496d540a9 (diff)
downloadhammer-of-the-scots-208df2953976067757e9477574fda56350b6407a.tar.gz
Add autohit option for faster async play.
TODO: Pause battle screen at end of battle.
-rw-r--r--create.html5
-rw-r--r--rules.js22
2 files changed, 27 insertions, 0 deletions
diff --git a/create.html b/create.html
index a8234b8..6c38f65 100644
--- a/create.html
+++ b/create.html
@@ -6,3 +6,8 @@
<dt><a href="/hammer-of-the-scots/info/rules.html#page8">Campaign</a>
<dd>Start as per Braveheart but is played until one player achieves victory.
</dl>
+
+<p>
+<label><input type="checkbox" name="autohit" value="true">
+Automatically apply combat hits when possible.
+</label>
diff --git a/rules.js b/rules.js
index b791fbc..cbb402e 100644
--- a/rules.js
+++ b/rules.js
@@ -1797,6 +1797,23 @@ states.battle_round = {
function goto_battle_hits() {
game.battle_list = list_victims(game.active)
+ if (game.autohit) {
+ let n = 0
+ while (game.hits >= game.battle_list.length && game.battle_list.length > 0) {
+ while (game.battle_list.length > 0) {
+ let who = game.battle_list.pop()
+ log_battle(block_name(who) + " took a hit.")
+ reduce_block(who, 'combat')
+ game.hits--
+ ++n
+ }
+ if (game.hits > 0)
+ game.battle_list = list_victims(game.active)
+ }
+ if (n > 0)
+ game.flash += ` Assigned ${n}.`
+ }
+
if (game.battle_list.length === 0)
resume_battle()
else
@@ -2941,6 +2958,7 @@ exports.setup = function (seed, scenario, options) {
who: null,
where: null,
}
+
if (scenario === "The Bruce")
setup_the_bruce()
else if (scenario === "Braveheart")
@@ -2949,6 +2967,10 @@ exports.setup = function (seed, scenario, options) {
setup_campaign()
else
throw new Error("Unknown scenario:", scenario)
+
+ if (options.autohit)
+ game.autohit = 1
+
log(".h1 " + scenario)
start_year()
return game