diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-18 13:46:04 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:27 +0100 |
commit | d99c41b26f058935b796f3092e3ee86930b072a4 (patch) | |
tree | 65eb90d00ab8efc4db2b923ec8acb38cfd4bd2f9 /rules.js | |
parent | e5a5358988f154154236f61dd7d649efb4a09021 (diff) | |
download | rommel-in-the-desert-d99c41b26f058935b796f3092e3ee86930b072a4.tar.gz |
Merge engage_via and forced_march_via states.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 46 |
1 files changed, 3 insertions, 43 deletions
@@ -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.` @@ -3702,37 +3693,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) let speed = unit_speed[who] |