diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 57 |
1 files changed, 37 insertions, 20 deletions
@@ -467,6 +467,12 @@ function reveal_units_in_hex(x) { set_add(game.revealed, u) } +function hide_friendly_units_in_hex(x) { + for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) + if (unit_hex(u) === x) + set_delete(game.revealed, u) +} + function hide_units_in_hex(x) { for (let u = 0; u < unit_count; ++u) if (unit_hex(u) === x) @@ -2853,13 +2859,15 @@ function goto_final_supply_check() { // Now in supply! let base_net = friendly_supply_network() + let summary = [] for (let u of game.disrupt) { if (base_net[unit_hex(u)]) { - // TODO: summary? - log(`Restored supply at #${unit_hex(u)}.`) + set_add(summary, unit_hex(u)) set_unit_supply(u, SS_BASE) } } + for (let x of summary) + log(`Restored supply at #${x}.`) // Assign leftover fortress and oasis supply game.state = 'final_fortress_supply' @@ -3851,11 +3859,9 @@ states.forced_marches = { if (roll >= 4) { log(`>${die_face_hit[roll]} to #${to}`) visit_hex(to) - if (has_enemy_unit(to)) { + if (has_enemy_unit(to)) engage_via_hexside(who, via, to, false) - } else { - set_unit_hex(who, to) - } + set_unit_hex(who, to) } else { log(`>${die_face_miss[roll]} disrupted at #${from}`) set_unit_hex(who, from) @@ -4421,6 +4427,7 @@ states.rout_attrition = { function goto_rout_move() { if (has_friendly_unit(game.rout.from)) { + hide_friendly_units_in_hex(game.rout.from) // TODO: auto-eliminate if no withdraw path available game.state = 'rout_move' log(`Withdrew`) @@ -4515,15 +4522,16 @@ function goto_combat_phase() { return goto_rout(BENGHAZI, false, goto_combat_phase) if (is_mandatory_combat(TOBRUK)) return goto_rout(TOBRUK, false, goto_combat_phase) - } else { - if (is_mandatory_combat(BARDIA)) - set_add(game.active_battles, BARDIA) - if (is_mandatory_combat(BENGHAZI)) - set_add(game.active_battles, BENGHAZI) - if (is_mandatory_combat(TOBRUK)) - set_add(game.active_battles, TOBRUK) + return end_combat_phase() } + if (is_mandatory_combat(BARDIA)) + set_add(game.active_battles, BARDIA) + if (is_mandatory_combat(BENGHAZI)) + set_add(game.active_battles, BENGHAZI) + if (is_mandatory_combat(TOBRUK)) + set_add(game.active_battles, TOBRUK) + let n = count_and_reveal_battle_hexes() if (n > 0) { if (n > game.active_battles.length) @@ -4717,7 +4725,13 @@ function goto_battle(x) { game.hits = [ 0, 0, 0, 0 ] } -function end_battle() { +function end_battle_1() { + game.flash = "" + game.battle = 0 + game.hits = 0 +} + +function end_battle_2() { if (!is_battle_hex(game.battle)) { release_hex_control(game.battle) hide_units_in_hex(game.battle) @@ -4726,10 +4740,6 @@ function end_battle() { set_delete(game.active_battles, game.battle) set_delete(game.assault_battles, game.battle) - game.flash = "" - game.battle = 0 - game.hits = 0 - set_active_player() if (game.active_battles.length > 0) game.state = 'select_battle' @@ -4990,7 +5000,9 @@ states.battle_hits = { function end_battle_hits() { if (is_friendly_rout_hex(game.battle)) { - goto_rout(game.battle, false, end_battle) + let where = game.battle + end_battle_1() + goto_rout(where, false, end_battle_2) } else if (game.active === game.phasing && has_friendly_units_in_battle()) { // goto offensive fire log_br() @@ -4998,7 +5010,8 @@ function end_battle_hits() { game.state = 'battle_fire' game.hits = [ 0, 0, 0, 0 ] } else { - end_battle() + end_battle_1() + end_battle_2() } } @@ -5054,6 +5067,7 @@ states.probe_hits = { } function end_probe_hits() { + // TODO: rout during probe combat? if (game.active !== game.phasing && has_friendly_units_in_battle()) { // goto offensive fire game.state = 'probe_fire' @@ -5384,6 +5398,9 @@ function end_rout_fire() { // === BUILDUP - SUPPLY CHECK === function end_month() { + set_clear(game.fired) + set_clear(game.moved) + // Forget captured fortresses (for bonus cards) clear_fortresses_captured() |