From ddecff58940daac435a3ba9477c71f50234fa7eb Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 12 Oct 2023 19:01:14 +0200 Subject: Make delayed hits default behavior. Add immediate hits as a (hidden) option. --- create.html | 8 +++++--- rules.js | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/create.html b/create.html index 80dc869..a170e57 100644 --- a/create.html +++ b/create.html @@ -7,11 +7,13 @@ Iron Bridge
The road between Antioch and Harim has a move limit of 3. + diff --git a/rules.js b/rules.js index 40ea4e8..509e67c 100644 --- a/rules.js +++ b/rules.js @@ -2759,15 +2759,15 @@ function count_enemy_hp_in_siege() { } function must_apply_field_hits() { - if (game.delay_hits) - return game.hits >= count_enemy_hp_in_field() - return game.hits > 0 + if (game.immediate) + return game.hits > 0 + return game.hits >= count_enemy_hp_in_field() } function must_apply_siege_hits() { - if (game.delay_hits) - return game.hits >= count_enemy_hp_in_siege() - return game.hits > 0 + if (game.immediate) + return game.hits > 0 + return game.hits >= count_enemy_hp_in_siege() } function filter_battle_blocks(ci, is_candidate) { @@ -2789,7 +2789,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() } } @@ -2827,7 +2827,7 @@ function pump_battle_step(is_candidate_attacker, is_candidate_defender) { if (battle_step(attacker, 'C', is_candidate_attacker)) return } - if (game.delay_hits && game.hits > 0) { + if (game.hits > 0) { game.active = enemy(game.active) return goto_battle_hits() } @@ -2854,7 +2854,7 @@ function resume_field_battle() { game.active = game.attacker[game.where] if (is_friendly_field(game.where)) { - if (game.delay_hits && game.hits > 0) { + if (game.hits > 0) { game.active = enemy(save_active) return goto_field_battle_hits() } @@ -2865,7 +2865,7 @@ function resume_field_battle() { } if (is_enemy_field(game.where)) { - if (game.delay_hits && game.hits > 0) { + if (game.hits > 0) { game.active = enemy(save_active) return goto_field_battle_hits() } @@ -2877,7 +2877,7 @@ function resume_field_battle() { } if (is_enemy_battle_field()) { - if (game.delay_hits && game.hits > 0) { + if (game.hits > 0) { game.active = enemy(save_active) return goto_field_battle_hits() } @@ -2887,7 +2887,7 @@ function resume_field_battle() { } if (is_friendly_battle_field()) { - if (game.delay_hits && game.hits > 0) { + if (game.hits > 0) { game.active = enemy(save_active) return goto_field_battle_hits() } @@ -2938,7 +2938,7 @@ states.field_battle = { if (block_owner(b) === FRANKS && block_initiative(b) === 'B') gen_action(view, 'charge', b) } - if (game.delay_hits && game.hits > 0) + if (game.hits > 0) gen_action(view, 'assign') }, assign: function () { @@ -3014,7 +3014,7 @@ states.siege_battle = { if (set_has(game.storming, b)) gen_action(view, 'retreat', b) } - if (game.delay_hits && game.hits > 0) + if (game.hits > 0) gen_action(view, 'assign') }, assign: function () { @@ -3201,15 +3201,7 @@ function roll_attack(active, b, verb, is_charge) { log(active[0] + ": " + name + " " + verb + " " + rolls.join("") + ".") - if (game.delay_hits) { - game.flash = name + " " + verb + " " + rolls.join(" ") - if (game.hits === 0) - game.flash += "." - else if (game.hits === 1) - game.flash += " for a total of 1 hit." - else - game.flash += " for a total of " + game.hits + " hits." - } else { + if (game.immediate) { game.flash = name + " " + verb + " " + rolls.join(" ") + " " if (game.hits === 0) game.flash += "and missed." @@ -3217,6 +3209,14 @@ function roll_attack(active, b, verb, is_charge) { game.flash += "and scored 1 hit." else game.flash += "and scored " + game.hits + " hits." + } else { + game.flash = name + " " + verb + " " + rolls.join(" ") + if (game.hits === 0) + game.flash += "." + else if (game.hits === 1) + game.flash += " for a total of 1 hit." + else + game.flash += " for a total of " + game.hits + " hits." } if (self > 0) { @@ -3856,8 +3856,8 @@ exports.setup = function (seed, scenario, options) { log("") } - if (options && options.delay_hits) - game.delay_hits = 1 + if (options && options.immediate) + game.immediate = 1 setup_game() return game -- cgit v1.2.3