diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 78 |
1 files changed, 62 insertions, 16 deletions
@@ -1823,6 +1823,7 @@ function count_defenders() { function start_battle() { game.battle_round = 0 game.flash = "" + game.hits = 0 logbr() log(".h4 Battle in #" + game.where) if (game.surprise === game.where) @@ -1948,7 +1949,13 @@ function pump_battle_round() { function battle_step(active, initiative, candidate) { game.battle_list = filter_battle_blocks(initiative, candidate) if (game.battle_list) { - game.active = active + if (game.active !== active) { + game.active = active + if (game.delay_hits && game.hits > 0) { + goto_battle_hits() + return true + } + } return true } return false @@ -1982,6 +1989,11 @@ function pump_battle_round() { if (battle_step(attacker, 'D', is_attacker)) return } + if (game.delay_hits && game.hits > 0) { + game.active = enemy(game.active) + return goto_battle_hits() + } + start_battle_round() } } @@ -2008,33 +2020,50 @@ function can_fire_with_block(b) { function fire_with_block(b) { set_add(game.moved, b) - game.hits = 0 let strength = block_strength(b) let fire = block_fire_power(b) let name = block_name(b) + " " + block_initiative(b) + fire + let rolls = [] + let hits = 0 for (let i = 0; i < strength; ++i) { let die = roll_d6() if (die <= fire) { rolls.push(DIE_HIT[die]) - ++game.hits + ++hits } else { rolls.push(DIE_MISS[die]) } } - game.flash = name + " fired " + rolls.join(" ") + " " - if (game.hits === 0) - game.flash += "and missed." - else if (game.hits === 1) - game.flash += "and scored 1 hit." - else - game.flash += "and scored " + game.hits + " hits." + game.hits += hits 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 { + game.flash = name + " fired " + rolls.join(" ") + if (hits === 0) + game.flash += " and missed." + else if (hits === 1) + game.flash += " and scored 1 hit." + else + game.flash += " and scored " + hits + " hits." + } + if (game.hits > 0) { - game.active = enemy(game.active) - goto_battle_hits() + if (!game.delay_hits) { + game.active = enemy(game.active) + goto_battle_hits() + } else { + resume_battle() + } } else { resume_battle() } @@ -2108,6 +2137,16 @@ states.battle_round = { if (can_pass) gen_action_battle(view, 'battle_pass', b) gen_action_block(view, b) } + if (game.delay_hits && game.hits > 0) + gen_action(view, 'assign') + }, + assign: function () { + game.active = enemy(game.active) + if (game.hits === 1) + game.flash = `Inflicted 1 hit.` + else + game.flash = `Inflicted ${game.hits} hits.` + goto_battle_hits() }, block: function (who) { if (can_fire_with_block(who)) @@ -2150,10 +2189,12 @@ function goto_battle_hits() { game.flash += ` Assigned ${n}.` } - if (game.battle_list.length === 0) + if (game.battle_list.length === 0) { + game.hits = 0 resume_battle() - else + } else { game.state = 'battle_hits' + } } function list_victims(p) { @@ -2178,10 +2219,12 @@ function apply_hit(who) { resume_battle() else { game.battle_list = list_victims(game.active) - if (game.battle_list.length === 0) + if (game.battle_list.length === 0) { + game.hits = 0 resume_battle() - else + } else { game.flash += " " + game.hits + (game.hits === 1 ? " hit left." : " hits left.") + } } } @@ -2675,6 +2718,9 @@ exports.setup = function (seed, scenario, options) { if (options.autohit) game.autohit = 1 + if (options.delay_hits) + game.delay_hits = 1 + setup_historical_deployment() if (scenario === "Free Deployment") start_free_deployment() |