diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-03 19:35:56 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:27 +0100 |
commit | 0e8fb16e6f787da2ec0b5cd0a759fb9ca228ab39 (patch) | |
tree | 6bb94d647d626b6e60e891f3c7e5bb837c8c6a99 | |
parent | 0e18ac1858718ab16e3bd1d7c0aa19d7bcaa2f1c (diff) | |
download | rommel-in-the-desert-0e8fb16e6f787da2ec0b5cd0a759fb9ca228ab39.tar.gz |
Misc fixes.
End battle properly when routing.
Forced march into battle.
Skip combat phase during pass turns.
Clear moved flags before buildup.
-rw-r--r-- | play.js | 17 | ||||
-rw-r--r-- | rules.js | 57 |
2 files changed, 45 insertions, 29 deletions
@@ -841,17 +841,16 @@ function update_battle() { ui.battle.classList.remove("hide") ui.battle_header.textContent = hex_name[view.battle] ui.battle_message.textContent = view.flash - // TODO: don't show disrupted units? if (player === ALLIED) { - update_battle_line(view.battle, ui.battle_line_1, u => is_axis_unit(u) && is_artillery_unit(u)) - update_battle_line(view.battle, ui.battle_line_2, u => is_axis_unit(u) && !is_artillery_unit(u)) - update_battle_line(view.battle, ui.battle_line_3, u => is_allied_unit(u) && !is_artillery_unit(u)) - update_battle_line(view.battle, ui.battle_line_4, u => is_allied_unit(u) && is_artillery_unit(u)) + update_battle_line(view.battle, ui.battle_line_1, u => is_axis_unit(u) && is_artillery_unit(u) && !is_unit_disrupted(u)) + update_battle_line(view.battle, ui.battle_line_2, u => is_axis_unit(u) && !is_artillery_unit(u) && !is_unit_disrupted(u)) + update_battle_line(view.battle, ui.battle_line_3, u => is_allied_unit(u) && !is_artillery_unit(u) && !is_unit_disrupted(u)) + update_battle_line(view.battle, ui.battle_line_4, u => is_allied_unit(u) && is_artillery_unit(u) && !is_unit_disrupted(u)) } else { - update_battle_line(view.battle, ui.battle_line_1, u => is_allied_unit(u) && is_artillery_unit(u)) - update_battle_line(view.battle, ui.battle_line_2, u => is_allied_unit(u) && !is_artillery_unit(u)) - update_battle_line(view.battle, ui.battle_line_3, u => is_axis_unit(u) && !is_artillery_unit(u)) - update_battle_line(view.battle, ui.battle_line_4, u => is_axis_unit(u) && is_artillery_unit(u)) + update_battle_line(view.battle, ui.battle_line_1, u => is_allied_unit(u) && is_artillery_unit(u) && !is_unit_disrupted(u)) + update_battle_line(view.battle, ui.battle_line_2, u => is_allied_unit(u) && !is_artillery_unit(u) && !is_unit_disrupted(u)) + update_battle_line(view.battle, ui.battle_line_3, u => is_axis_unit(u) && !is_artillery_unit(u) && !is_unit_disrupted(u)) + update_battle_line(view.battle, ui.battle_line_4, u => is_axis_unit(u) && is_artillery_unit(u) && !is_unit_disrupted(u)) } for (let i = 0; i < 4; ++i) ui.battle_hits[i].textContent = view.hits[i] @@ -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() |