diff options
-rw-r--r-- | rules.js | 41 |
1 files changed, 27 insertions, 14 deletions
@@ -8,7 +8,15 @@ var states = {} var game = null var view = null -var after_rout_table = {} +var after_rout_table = { + end_battle_2: end_battle_2, + end_refuse_battle_move_2: end_refuse_battle_move_2, + end_retreat_2: end_retreat_2, + goto_combat_phase: goto_combat_phase, + goto_final_supply_check_rout: goto_final_supply_check_rout, + goto_forced_marches_rout: goto_forced_marches_rout, + goto_initial_supply_check_rout: goto_initial_supply_check_rout, +} const { all_hexes, hex_exists, hex_road, side_road, side_limit, hex_name, regions, @@ -953,6 +961,15 @@ function for_each_undisrupted_friendly_unit_in_hex(x, fn) { fn(u) } +function has_undisrupted_and_unmoved_friendly_unit(x) { + if (has_undisrupted_friendly_unit(x)) { + for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) + if (unit_hex(u) === x && !is_unit_moved(u)) + return true + } + return false +} + function for_each_undisrupted_and_unmoved_friendly_unit_in_hex(x, fn) { for (let u = first_friendly_unit; u <= last_friendly_unit; ++u) if (is_unit_undisrupted(u) && unit_hex(u) === x && !is_unit_moved(u)) @@ -2439,7 +2456,6 @@ function goto_player_turn() { game.to1 = game.to2 = 0 // reset moved and fired flags - game.forced = [] set_clear(game.fired) set_clear(game.moved) @@ -2964,6 +2980,7 @@ function flush_move_summary() { function goto_move_phase() { set_clear(game.fired) + game.forced = [] game.state = 'select_moves' init_move_summary() if (game.phasing === AXIS) { @@ -3036,7 +3053,7 @@ states.group_move_from = { for (let x of all_hexes) { if (x === game.from1 && !game.to1) continue - if (has_undisrupted_friendly_unit(x)) + if (has_undisrupted_and_unmoved_friendly_unit(x)) gen_action_hex(x) } if (has_friendly_unit_in_raw_hex(friendly_queue())) @@ -4335,12 +4352,8 @@ function goto_rout(from, enemy, after) { clear_undo() // remember state and callback so we can resume after routing - - if (after) { - if (!after_rout_table[after.name]) - after_rout_table[after.name] = after + if (after) after = after.name - } game.rout = { state: game.state, @@ -4631,12 +4644,12 @@ function is_assault_battle() { function is_fortress_defensive_fire() { if ((game.state === 'battle_fire' && is_passive_player()) || (game.state === 'probe_fire' && is_active_player())) { + if (game.battle === BARDIA) + return is_fortress_friendly_controlled(BARDIA) if (game.battle === BENGHAZI) - return game.benghazi === game.active + return is_fortress_friendly_controlled(BENGHAZI) if (game.battle === TOBRUK) - return game.tobruk === game.active - if (game.battle === BARDIA) - return game.tobruk === game.active + return is_fortress_friendly_controlled(TOBRUK) } return false } @@ -5528,7 +5541,7 @@ function goto_buildup_discard() { } states.buildup_discard = { - inactive: "buildup (discard)", + inactive: "buildup", prompt() { view.prompt = "Buildup: Discard any unwanted dummy cards." let hand = player_hand() @@ -5567,7 +5580,7 @@ function goto_buildup_reinforcements() { } states.buildup_reinforcements = { - inactive: "buildup (reinforcements)", + inactive: "buildup", prompt() { view.prompt = `Buildup: Bring on reinforcements.` |