diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-07-26 17:30:10 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:26 +0100 |
commit | ca6ff126e74dd6bde8af32f6a3f945394e5d3c26 (patch) | |
tree | 635a855d511fd15ee56fd79152be17d5bba66d8d /rules.js | |
parent | 2664e69b6b41a97f14f4d156d8ac3cdb1b597c3a (diff) | |
download | rommel-in-the-desert-ca6ff126e74dd6bde8af32f6a3f945394e5d3c26.tar.gz |
initial & final supply check routs
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 155 |
1 files changed, 113 insertions, 42 deletions
@@ -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() { |