diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 53 |
1 files changed, 23 insertions, 30 deletions
@@ -17,6 +17,7 @@ // UI: pause after all fires (in case 0 hits the dialog disappears fast) // TODO: black hit outline in battles ("steploss/bad" action) and skip "apply 0 hits" step +// TODO: undo push/clear // ERRATA: forbid single-group regroup moves or convert to group moves after the fact, // to prevent forced march abuse. @@ -3633,7 +3634,7 @@ states.select_active_battles = { if (game.turn_option === 'assault') game.state = 'select_assault_battles' else - game.state = 'select_battle' + goto_select_battle() } else { end_combat_phase() } @@ -3656,7 +3657,7 @@ states.select_assault_battles = { }, next() { push_undo() - game.state = 'select_battle' + goto_select_battle() } } @@ -3952,7 +3953,7 @@ function gen_battle_hits() { let c = unit_class[u] if (is_elite_unit(u)) { if (game.hits[c] >= 2) { - gen_action_unit(u) + gen_action_unit_hit(u) done = false } } else { @@ -3962,7 +3963,7 @@ function gen_battle_hits() { // Eliminating the last non-elite must not leave an odd // number of hits remaining. } else { - gen_action_unit(u) + gen_action_unit_hit(u) done = false } } @@ -3970,7 +3971,7 @@ function gen_battle_hits() { } }) if (done) - gen_action_next() + gen_action('end_hits') return done } @@ -4017,11 +4018,11 @@ states.battle_hits = { view.prompt = `Battle: ${format_allocate_hits()} from Offensive Fire.` gen_battle_hits() }, - unit(who) { + unit_hit(who) { push_undo() apply_battle_hit(who) }, - next() { + end_hits() { clear_undo() end_battle_hits() }, @@ -4075,11 +4076,11 @@ states.probe_hits = { view.prompt = `Probe: ${format_allocate_hits()} from Offensive Fire.` gen_battle_hits() }, - unit(who) { + unit_hit(who) { push_undo() apply_battle_hit(who) }, - next() { + end_hits() { clear_undo() end_probe_hits() }, @@ -4248,19 +4249,13 @@ states.pursuit_fire = { } }) } - if (done) - gen_action('end_fire') - else - gen_action('withhold') + gen_action('end_fire') }, unit(who) { let slowest = slowest_undisrupted_enemy_unit_speed(game.pursuit) roll_pursuit_fire(who, (unit_speed[who] > slowest ? 2 : 1)) set_unit_fired(who) }, - withhold() { - goto_pursuit_hits() - }, end_fire() { goto_pursuit_hits() }, @@ -4280,19 +4275,13 @@ states.rout_fire = { } }) } - if (done) - gen_action('end_fire') - else - gen_action('withhold') + gen_action('end_fire') }, unit(who) { let slowest = slowest_enemy_unit_speed(game.pursuit) roll_rout_fire(who, (unit_speed[who] > slowest ? 2 : 1)) set_unit_fired(who) }, - withhold() { - goto_rout_hits() - }, end_fire() { goto_rout_hits() }, @@ -4303,7 +4292,7 @@ function gen_pursuit_hits(normal_steps, elite_steps, iterate) { iterate(game.pursuit, u => { if (is_elite_unit(u)) { if (game.hits >= 2) { - gen_action_unit(u) + gen_action_unit_hit(u) done = false } } else { @@ -4313,14 +4302,14 @@ function gen_pursuit_hits(normal_steps, elite_steps, iterate) { // Eliminating the last non-elite must not leave an odd // number of hits remaining. } else { - gen_action_unit(u) + gen_action_unit_hit(u) done = false } } } }) if (done) - gen_action('next') + gen_action('end_hits') } states.pursuit_hits = { @@ -4331,11 +4320,11 @@ states.pursuit_hits = { let elite_steps = count_elite_steps_in_pursuit() gen_pursuit_hits(normal_steps, elite_steps, for_each_undisrupted_friendly_unit_in_hex) }, - unit(who) { + unit_hit(who) { push_undo() game.hits -= reduce_unit(who) }, - next() { + end_hits() { clear_undo() end_pursuit_fire() }, @@ -4349,11 +4338,11 @@ states.rout_hits = { let elite_steps = count_elite_steps_in_rout() gen_pursuit_hits(normal_steps, elite_steps, for_each_friendly_unit_in_hex) }, - unit(who) { + unit_hit(who) { push_undo() game.hits -= reduce_unit(who) }, - next() { + end_hits() { clear_undo() end_rout_fire() }, @@ -5846,6 +5835,10 @@ function gen_action_unit(u) { gen_action('unit', u) } +function gen_action_unit_hit(u) { + gen_action('unit_hit', u) +} + function gen_action_hex(x) { gen_action('hex', x) } |