From ca6ff126e74dd6bde8af32f6a3f945394e5d3c26 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 26 Jul 2022 17:30:10 +0200 Subject: initial & final supply check routs --- rules.js | 155 ++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 42 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index f7287dd..30001e3 100644 --- a/rules.js +++ b/rules.js @@ -1,11 +1,11 @@ "use strict" +// TODO: BLITZ TURN + +// TODO: fortress supply // TODO: fortress battles mandatory combat! -// TODO: claim fortress control // TODO: FORCED MARCHES -// TODO: BLITZ TURN -// TODO: FINAL SUPPLY CHECK // TODO: SUPPLY CARDS (playing and revealing and choosing turn option) // TODO: BUILDUP @@ -1421,6 +1421,50 @@ function goto_player_turn() { goto_initial_supply_check() } +function goto_turn_option() { + set_active_player() + game.state = 'turn_option' +} + +states.turn_option = { + inactive: "turn option", + prompt() { + view.prompt = "Select Turn Option" + gen_action('basic') + gen_action('offensive') + gen_action('assault') + gen_action('blitz') + gen_action('pass') + }, + basic() { + push_undo() + game.turn_option = 'basic' + goto_move_phase() + }, + offensive() { + push_undo() + game.turn_option = 'offensive' + goto_move_phase() + }, + assault() { + push_undo() + game.turn_option = 'assault' + goto_move_phase() + }, + blitz() { + push_undo() + game.turn_option = 'blitz' + goto_move_phase() + }, + pass() { + push_undo() + game.turn_option = 'pass' + goto_move_phase() + }, +} + +// === INITIAL & FINAL SUPPLY CHECK === + function goto_initial_supply_check() { update_supply_networks() let snet = game.phasing === AXIS ? game.axis_supply : game.allied_supply @@ -1447,11 +1491,39 @@ function goto_initial_supply_check() { set_add(game.recover, u) }) - // TODO: check for enemy routs + goto_initial_supply_check_rout() +} - goto_turn_option() +function goto_initial_supply_check_rout() { + let n = 0, where = 0 + for (let x of all_hexes) { + if (is_friendly_rout_hex(x)) { + where = x + n++ + } + } + if (n === 0) + goto_turn_option() + else if (n === 1) + goto_rout(where, false, "goto_initial_supply_check_rout") + else + game.state = 'initial_supply_check_routs' } +states.initial_supply_check_routs = { + prompt() { + view.prompt = `Initial Supply Check: Rout!` + for (let x of all_hexes) + if (is_enemy_rout_hex(x)) + gen_action_hex(x) + }, + hex(where) { + goto_rout(where, true, "goto_initial_supply_check_rout") + } +} + +after_rout.goto_initial_supply_check_rout = goto_initial_supply_check_rout + function goto_final_supply_check() { set_active_player() @@ -1474,52 +1546,51 @@ function goto_final_supply_check() { } }) - // TODO: rout friendly units - - end_player_turn() + goto_final_supply_check_rout() } -function goto_turn_option() { - game.state = 'turn_option' +function goto_final_supply_check_rout() { + let n = 0, where = 0 + for (let x of all_hexes) { + if (is_friendly_rout_hex(x)) { + where = x + n++ + } + } + if (n === 0) + end_player_turn() + else if (n === 1) + goto_rout(where, false, "goto_final_supply_check_rout") + else + game.state = 'final_supply_check_routs' } -states.turn_option = { - inactive: "turn option", +states.final_supply_check_routs = { prompt() { - view.prompt = "Select Turn Option" - gen_action('basic') - gen_action('offensive') - gen_action('assault') - gen_action('blitz') - gen_action('pass') - }, - basic() { - push_undo() - game.turn_option = 'basic' - goto_move_phase() - }, - offensive() { - push_undo() - game.turn_option = 'offensive' - goto_move_phase() - }, - assault() { - push_undo() - game.turn_option = 'assault' - goto_move_phase() - }, - blitz() { - push_undo() - game.turn_option = 'blitz' - goto_move_phase() + view.prompt = `Final Supply Check: Rout!` + for (let x of all_hexes) + if (is_friendly_rout_hex(x)) + gen_action_hex(x) }, - pass() { - push_undo() - game.turn_option = 'pass' - goto_move_phase() + hex(where) { + goto_rout(where, false, "goto_final_supply_check_rout") + } +} + +states.final_supply_check_routs = { + prompt() { + view.prompt = `Final Supply Check: Rout!` + for (let x of all_hexes) + if (is_friendly_rout_hex(x)) + gen_action_hex(x) }, + hex(where) { + goto_rout(where, false, "goto_final_supply_check_rout") + } } +after_rout.goto_final_supply_check_rout = goto_final_supply_check_rout + // ==== MOVEMENT PHASE === function goto_move_phase() { -- cgit v1.2.3