From d99c41b26f058935b796f3092e3ee86930b072a4 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 18 Sep 2022 13:46:04 +0200 Subject: Merge engage_via and forced_march_via states. --- rules.js | 46 +++------------------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 746b455..685c400 100644 --- a/rules.js +++ b/rules.js @@ -3656,16 +3656,7 @@ function move_via(who, to, speed, move) { function move_unit(who, to, speed, move) { let from = unit_hex(who) - if (is_forced_march_move(from, to, speed)) { - if (move_via(who, to, speed, move)) { - forced_march_via(who, game.hexside.via[0], to, move) - game.hexside = null - } else { - game.state = 'forced_march_via' - } - } - - else if (has_enemy_unit(to)) { + if (is_forced_march_move(from, to, speed) || has_enemy_unit(to)) { if (move_via(who, to, speed, move)) { if (game.hexside.forced[0]) forced_march_via(who, game.hexside.via[0], to, move) @@ -3673,7 +3664,7 @@ function move_unit(who, to, speed, move) { engage_via(who, game.hexside.via[0], to, move) game.hexside = null } else { - game.state = 'engage_via' + game.state = 'move_via' } } @@ -3692,7 +3683,7 @@ function resume_move() { game.state = 'move' } -states.forced_march_via = { +states.move_via = { inactive: "movement", prompt() { view.prompt = `Movement: Select which path to take.` @@ -3701,37 +3692,6 @@ states.forced_march_via = { // view.path = {} - let rommel = (game.hexside.move === game.rommel) ? 1 : 0 - let from = unit_hex(game.hexside.who) - let speed = unit_speed[game.hexside.who] - search_move(from, speed + 1 + rommel) - - for (let x of game.hexside.via) { - gen_action_hex(x) - } - }, - hex(via) { - let rommel = (game.hexside.move === game.rommel) ? 1 : 0 - let who = game.hexside.who - let from = unit_hex(who) - let speed = unit_speed[who] - search_move(from, speed + 1 + rommel) - - forced_march_via(game.hexside.who, via, game.hexside.to, game.hexside.move) - game.hexside = null - resume_move() - } -} - -states.engage_via = { - inactive: "movement", - prompt() { - view.prompt = `Movement: Select which hex side to cross.` - view.selected = game.hexside.who - view.selected_hexes = game.hexside.to - - // view.path = {} - let rommel = (game.hexside.move === game.rommel) ? 1 : 0 let who = game.hexside.who let from = unit_hex(who) -- cgit v1.2.3