summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-27 20:23:04 +0100
committerTor Andersson <tor@ccxvii.net>2024-10-27 20:23:04 +0100
commite25758efa7da42308fe9611ab0c7dbf59a55c140 (patch)
tree54593ed0aae1970ede6f907f90fbdb9696de6c7d
parentca168e3d99fd49602ea290c04045e7140c5da70e (diff)
downloadmaria-e25758efa7da42308fe9611ab0c7dbf59a55c140.tar.gz
tweak ui when ending movement (on flanders map particularly)
-rw-r--r--play.js3
-rw-r--r--rules.js47
2 files changed, 45 insertions, 5 deletions
diff --git a/play.js b/play.js
index fffe5ba..6d02d51 100644
--- a/play.js
+++ b/play.js
@@ -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?")
diff --git a/rules.js b/rules.js
index 8cd9109..7343c2a 100644
--- a/rules.js
+++ b/rules.js
@@ -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()
},