summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-12 19:14:20 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-12 19:14:20 +0200
commitde49a77ff2105c0a88bd8ca36ea273886dcaa2a3 (patch)
tree9c82e283bcdc6dd138d7ed02dfa4903069289304
parentb808c54912ff02d42d175e9d84ae707d44540702 (diff)
downloadhammer-of-the-scots-de49a77ff2105c0a88bd8ca36ea273886dcaa2a3.tar.gz
Make delay hits default behavior.
Add immediate hits as a (hidden) option.
-rw-r--r--create.html22
-rw-r--r--rules.js35
2 files changed, 23 insertions, 34 deletions
diff --git a/create.html b/create.html
index 1affdb4..8ef3843 100644
--- a/create.html
+++ b/create.html
@@ -17,25 +17,13 @@ Scottish infantry fire at +1 when the English have no archers.
</label>
</dl>
+<!--
<dl>
<dt>
<label>
-<input type="checkbox" id="delay_hits" name="delay_hits" value="true">
-Delayed hit assignment
+<input type="checkbox" id="immediate" name="immediate" value="true">
+Assign hits immediately
</label>
-<dd>Fire all blocks with the same initiative before assigning hits.
-
-<dt>
-<label>
-<input type="checkbox" id="autohit" name="autohit" value="true">
-Automatic hit assignment
-</label>
-<dd>Assign hits automatically when there is no choice.
+<dd><i>Note: This will slow down async play significantly!
</dl>
-
-<script>
-let cb1 = document.getElementById("autohit")
-let cb2 = document.getElementById("delay_hits")
-cb1.onchange = function () { if (cb1.checked) cb2.checked = false }
-cb2.onchange = function () { if (cb2.checked) cb1.checked = false }
-</script>
+-->
diff --git a/rules.js b/rules.js
index 3ce5681..0412cb8 100644
--- a/rules.js
+++ b/rules.js
@@ -1769,7 +1769,7 @@ function battle_step(active, initiative, candidate) {
if (game.battle_list) {
if (game.active !== active) {
game.active = active
- if (game.delay_hits && game.hits > 0) {
+ if (game.hits > 0) {
goto_battle_hits()
return true
}
@@ -1790,7 +1790,7 @@ function pump_battle_step() {
if (battle_step(defender, 'C', is_defender)) return
if (battle_step(attacker, 'C', is_attacker)) return
- if (game.delay_hits && game.hits > 0) {
+ if (game.hits > 0) {
game.active = ENEMY[game.active]
return goto_battle_hits()
}
@@ -1811,7 +1811,7 @@ states.battle_round = {
if (can_block_retreat(b))
gen_action_battle(view, 'battle_retreat', b)
}
- if (game.delay_hits && game.hits > 0)
+ if (game.hits > 0)
gen_action(view, 'assign')
},
assign: function () {
@@ -1858,9 +1858,9 @@ function count_enemy_hp_in_battle() {
}
function must_apply_hits() {
- if (game.delay_hits)
- return game.hits >= count_enemy_hp_in_battle()
- return game.hits > 0
+ if (game.immediate)
+ return game.hits > 0
+ return game.hits >= count_enemy_hp_in_battle()
}
function fire_with_block(b) {
@@ -1887,15 +1887,7 @@ function fire_with_block(b) {
log_battle(name + " fired " + rolls.join("") + ".")
- if (game.delay_hits) {
- game.flash = name + " fired " + rolls.join(" ")
- if (game.hits === 0)
- game.flash += "."
- else if (game.hits === 1)
- game.flash += " for a total of 1 hit."
- else if (game.hits > 1)
- game.flash += " for a total of " + game.hits + " hits."
- } else {
+ if (game.immediate) {
game.flash = name + " fired " + rolls.join(" ")
if (hits === 0)
game.flash += " and missed."
@@ -1903,6 +1895,14 @@ function fire_with_block(b) {
game.flash += " and scored 1 hit."
else
game.flash += " and scored " + hits + " hits."
+ } else {
+ game.flash = name + " fired " + rolls.join(" ")
+ if (game.hits === 0)
+ game.flash += "."
+ else if (game.hits === 1)
+ game.flash += " for a total of 1 hit."
+ else if (game.hits > 1)
+ game.flash += " for a total of " + game.hits + " hits."
}
if (must_apply_hits()) {
@@ -3100,8 +3100,9 @@ exports.setup = function (seed, scenario, options) {
if (options.autohit)
game.autohit = 1
- if (options.delay_hits)
- game.delay_hits = 1
+
+ if (options.immediate)
+ game.immediate = 1
if (options.schiltroms) {
log("")