diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-10-27 20:23:04 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-27 20:23:04 +0100 |
commit | e25758efa7da42308fe9611ab0c7dbf59a55c140 (patch) | |
tree | 54593ed0aae1970ede6f907f90fbdb9696de6c7d /rules.js | |
parent | ca168e3d99fd49602ea290c04045e7140c5da70e (diff) | |
download | maria-e25758efa7da42308fe9611ab0c7dbf59a55c140.tar.gz |
tweak ui when ending movement (on flanders map particularly)
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 47 |
1 files changed, 42 insertions, 5 deletions
@@ -2032,6 +2032,28 @@ states.movement_flanders_next = { }, } +function has_moved_any_pieces() { + if (game.power === P_AUSTRIA && !(game.flags & F_MOVE_FLANDERS)) + return has_moved_any_bohemia_pieces() + for (let p of all_controlled_generals(game.power)) + if (set_has(game.moved, p)) + return true + for (let p of all_controlled_trains(game.power)) + if (set_has(game.moved, p)) + return true + return false +} + +function has_moved_any_bohemia_pieces() { + for (let p of all_controlled_generals(game.power)) + if (is_bohemia_space(game.pos[p]) && set_has(game.moved, p)) + return true + for (let p of all_controlled_trains(game.power)) + if (is_bohemia_space(game.pos[p]) && set_has(game.moved, p)) + return true + return false +} + states.movement = { inactive: "move", prompt() { @@ -2066,7 +2088,9 @@ states.movement = { } } - if (done_trains && done_generals) + if (game.power === P_AUSTRIA && (game.flags & F_MOVE_FLANDERS)) + prompt("Move one piece on the Flanders map.") + else if (done_trains && done_generals) prompt("Movement done.") else if (done_generals && !done_trains) prompt("Move your supply trains.") @@ -2075,10 +2099,17 @@ states.movement = { else prompt("Move your generals and supply trains.") - if (game.moved.length === 0) - view.actions.confirm_end_movement = 1 - else - view.actions.end_movement = 1 + if (game.power === P_AUSTRIA && (game.flags & F_MOVE_FLANDERS)) { + if (!has_moved_any_pieces()) + view.actions.confirm_end_flanders = 1 + else + view.actions.end_flanders = 1 + } else { + if (!has_moved_any_pieces()) + view.actions.confirm_end_movement = 1 + else + view.actions.end_movement = 1 + } }, re_enter() { push_undo() @@ -2108,6 +2139,12 @@ states.movement = { game.state = "move_general" } }, + confirm_end_flanders() { + this.end_flanders() + }, + end_flanders() { + this.end_movement() + }, confirm_end_movement() { this.end_movement() }, |