diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-03 17:03:04 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:27 +0100 |
commit | 079bc01141cb061e405e29d1df2c87fad8ecddc3 (patch) | |
tree | 336be05d6b182604b616ab7830cd16da6eef2f7c /rules.js | |
parent | 5f3205f345511f3fec8d404db89c677e0e4aaa86 (diff) | |
download | rommel-in-the-desert-079bc01141cb061e405e29d1df2c87fad8ecddc3.tar.gz |
More summaries.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 100 |
1 files changed, 88 insertions, 12 deletions
@@ -2754,12 +2754,15 @@ function goto_initial_supply_check() { } function goto_initial_supply_check_recover() { + let summary = [] for (let u of game.recover) { if (is_unit_supplied(u) && is_unit_disrupted(u) && !is_battle_hex(unit_hex(u))) { - log(`Recovered at #${unit_hex(u)}.`) + set_add(summary, unit_hex(u)) clear_unit_disrupted(u) } } + for (let x of summary) + log(`Recovered at #${x}.`) // remember enemy units that can recover on their next turn set_clear(game.recover) @@ -2843,12 +2846,16 @@ function goto_final_supply_check() { } function goto_final_supply_check_disrupt() { + let summary = [] for (let u of game.disrupt) { if (is_unit_unsupplied(u) && is_unit_undisrupted(u)) { - log(`Disrupted at #${unit_hex(u)}`) + set_add(summary, unit_hex(u)) set_unit_disrupted(u) } } + for (let x of summary) + log(`Disrupted at #${x}.`) + game.disrupt = null goto_final_supply_check_rout() } @@ -4231,7 +4238,7 @@ function goto_refuse_battle() { states.refuse_battle = { inactive: "refuse battle", prompt() { - view.prompt = `You may Refuse Battle.` + view.prompt = `You may Refuse Battle from hexes just attacked.` for (let x of game.active_battles) if (can_all_undisrupted_units_disengage_and_withdraw(x)) gen_action_hex(x) @@ -5557,6 +5564,17 @@ states.buildup_reinforcements = { inactive: "buildup (reinforcements)", prompt() { view.prompt = `Buildup: Bring on reinforcements.` + + view.selected = [] + for_each_friendly_unit_in_month(game.month, u => { + set_add(view.selected, u) + }) + if (game.month < current_scenario().end) { + for_each_friendly_unit_in_month(game.month+1, u => { + set_add(view.selected, u) + }) + } + gen_action_hex(friendly_base()) }, hex(base) { @@ -5604,6 +5622,58 @@ function apply_reinforcements() { function goto_buildup_spending() { game.state = 'spending_bps' + game.summary = { + refit: 0, + redeployed: {}, + replaced_steps: 0, + replaced_bps: 0, + dismantled: 0, + built: 0, + cards: 0, + } +} + +function print_buildup_summary() { + let keys = Object.keys(game.summary.redeployed).sort((a,b)=>a-b) + if (keys.length > 0) { + log("Redeployed") + for (let mm of keys) { + let n = game.summary.redeployed[mm] + let from = (mm) & 255 + let to = (mm >>> 8 ) & 255 + let sea = (mm >>> 16) & 255 + if (sea) + log(`>${n} #${from} to #${to}*`) + else + log(`>${n} #${from} to #${to}`) + } + } + + if (game.summary.refit > 0) + log(`Returned ${game.summary.refit} for Refit.`) + + if (game.summary.replaced_steps > 0) + log(`Replaced ${game.summary.replaced_steps} steps for ${game.summary.replaced_bps} BPs.`) + + if (game.summary.dismantled > 0) + log(`Dismantled ${game.summary.dismantled} minefields.`) + if (game.summary.built === 1) + log(`Built 1 minefield.`) + else if (game.summary.built > 1) + log(`Built ${game.summary.built} minefields.`) + + let cards = is_axis_player() ? game.buildup.axis_cards : game.buildup.allied_cards + if (cards === 1) + log(`Purchased 1 extra card.`) + else if (cards > 1) + log(`Purchased ${cards} extra cards.`) + + game.summary = null +} + +function push_buildup_summary(from, to, sea) { + let mm = (from) | (to << 8) | (sea << 16) + game.summary.redeployed[mm] = (game.summary.redeployed[mm]|0) + 1 } function available_bps() { @@ -5781,7 +5851,10 @@ states.spending_bps = { }, extra_supply_card() { push_undo() - log(`Purchased extra supply card.`) + if (is_axis_player()) + game.buildup.axis_cards++ + else + game.buildup.allied_cards++ pay_bps(10) }, minefield() { @@ -5790,13 +5863,14 @@ states.spending_bps = { }, replacement() { game.buildup.changed = 1 - log(`Replaced unit.`) + game.summary.replaced_steps ++ + game.summary.replaced_bps += replacement_cost(game.selected) replace_unit(game.selected) pay_bps(replacement_cost(game.selected)) }, refit() { game.buildup.changed = 1 - log(`Returned for Refit.`) + game.summary.refit ++ hide_unit(game.selected) set_unit_hex(pop_selected(), friendly_refit()) }, @@ -5821,16 +5895,16 @@ states.spending_bps = { if (to === from) { game.selected = -1 } else if (to === friendly_refit()) { - log(`Returned for Refit.`) + game.summary.refit ++ hide_unit(game.selected) set_unit_hex(pop_selected(), friendly_refit()) } else { search_redeploy(from) if (can_move_to(to, 2)) { - log(`Redeployed to #${to}.`) + push_buildup_summary(from, to, 0) pay_bps(1) } else { - log(`Sea Redeployed to #${to}.`) + push_buildup_summary(from, to, 1) if (is_fortress_besieged(from) || is_fortress_besieged(to)) pay_bps(4) else @@ -5850,6 +5924,8 @@ states.spending_bps = { game.selected = -1 clear_undo() + print_buildup_summary() + let n = available_bps() if (n > 20) { log(`Lost ${n - 20} unspent BPs.`) @@ -5897,7 +5973,7 @@ states.minefield = { }, hex(x) { let mfs = friendly_minefields() - log(`Built minefield.`) + game.summary.built ++ pay_bps(15) set_add(mfs, x) game.state = 'spending_bps' @@ -5950,8 +6026,8 @@ states.dismantle3 = { }, hex(x) { let mfs = friendly_minefields() - log(`Dismantled minefields.`) - log(`Built minefield.`) + game.summary.dismantled += 2 + game.summary.built ++ set_add(mfs, x) game.state = 'spending_bps' }, |