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 | |
parent | ca168e3d99fd49602ea290c04045e7140c5da70e (diff) | |
download | maria-e25758efa7da42308fe9611ab0c7dbf59a55c140.tar.gz |
tweak ui when ending movement (on flanders map particularly)
-rw-r--r-- | play.js | 3 | ||||
-rw-r--r-- | rules.js | 47 |
2 files changed, 45 insertions, 5 deletions
@@ -1373,11 +1373,14 @@ function on_update() { action_button("end_cards", "End card draw") action_button("end_setup", "End setup") action_button("end_recruit", "End recruit") + action_button("end_flanders", "Pass Flanders moves") action_button("end_movement", "End movement") action_button("end_combat", "End combat") action_button("end_supply", "End supply") action_button("end_turn", "End turn") + confirm_action_button("confirm_end_flanders", "Pass Flanders moves", + "You have NOT moved ANY pieces on the FLANDERS map!\nAre you sure you want to SKIP movement for the FLANDERS map?") confirm_action_button("confirm_end_movement", "End movement", "You have NOT moved ANY pieces!\nAre you sure you want to SKIP movement?") @@ -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() }, |