summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-08 23:30:07 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-08 23:30:07 +0100
commitf15dd0c0842cb3944ebc006da5b135cea6eed7b2 (patch)
treeb09e105d4b86fe439e6ea585f45a85b3c96b2c32
parent7895920ab6b4e34fa675c4fd520b82ca243b80ab (diff)
downloadmaria-f15dd0c0842cb3944ebc006da5b135cea6eed7b2.tar.gz
New alternating move procedure and states.
Allow movement on Bohemia map; alternate only after Flanders piece move.
-rw-r--r--play.js9
-rw-r--r--rules.js120
2 files changed, 56 insertions, 73 deletions
diff --git a/play.js b/play.js
index 8ebe698..80acf4f 100644
--- a/play.js
+++ b/play.js
@@ -1613,21 +1613,20 @@ function on_update() {
action_button("pass", "Pass")
action_button("next", "Next")
- confirm_action_button("restart", "Restart",
- "Restart movement phase on Flanders map?")
confirm_action_button("dispute", "Dispute",
- "Dispute order of movement on Flanders map and restart movement phase?")
+ "Dispute order of movement on Flanders map and restart Austrian and Pragmatic Army movement phase?")
+
+ confirm_action_button("restart", "Restart",
+ "Restart Austrian and Pragmatic Army movement phase?")
action_button("end_political_card", "End political card")
action_button("end_place_hussars", "End place hussars")
action_button("end_setup", "End setup")
action_button("end_recruit", "End recruit")
- action_button("end_flanders", "End Flanders")
action_button("end_movement", "End movement")
action_button("end_combat", "End combat")
action_button("end_supply", "End supply")
action_button("end_turn", "End turn")
- action_button("end_bohemia", "End Bohemia")
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 a057e56..ffafa20 100644
--- a/rules.js
+++ b/rules.js
@@ -1411,9 +1411,8 @@ const advanced_sequence_of_play = [
// alternate moves on flanders starting with pragmatic army
{ power: P_PRAGMATIC, action: init_movement },
- { power: P_PRAGMATIC, action: goto_movement_global },
+ { power: P_PRAGMATIC, action: goto_movement_flanders },
{ power: P_PRAGMATIC, action: end_movement },
- { power: P_PRAGMATIC, action: goto_movement_coop },
{ power: P_AUSTRIA, action: goto_combat },
{ power: P_PRAGMATIC, action: goto_combat },
@@ -2376,35 +2375,18 @@ function has_unmoved_piece_on_flanders_map(pow) {
return false
}
-function goto_movement_global() {
- game.state = "movement"
-}
-
-function goto_movement_coop() {
+function goto_movement_flanders() {
game.state = "movement"
- game.flags |= F_MOVE_FLANDERS
+ // save RESTART point
clear_undo()
push_undo()
game.restart = game.undo[0]
clear_undo()
-
- game.flags |= F_MOVE_COOP
-}
-
-function goto_movement_flanders() {
- game.flags |= F_MOVE_FLANDERS
- game.state = "movement"
- if (!has_unmoved_piece_on_flanders_map(game.power))
- next_sequence_of_play()
}
-function goto_movement_bohemia() {
- log_br()
- game.flags &= ~F_MOVE_FLANDERS
+function goto_movement_global() {
game.state = "movement"
- if (!has_unmoved_piece_on_bohemia_map(game.power))
- next_sequence_of_play()
}
function resume_movement() {
@@ -2420,7 +2402,7 @@ function resume_movement() {
}
function resume_movement_after_flanders_stacking() {
- flush_move_log()
+ flush_alternate_move()
set_active_to_power(coop_major_power(game.power))
game.selected = -1
game.state = "movement"
@@ -2472,6 +2454,8 @@ function can_general_move_anywhere(p) {
}
function may_dispute_flanders_movement() {
+ if (game.flags & F_MOVE_DISPUTE)
+ return false
if (game.power === P_PRAGMATIC && has_moved_piece_on_flanders_map(P_AUSTRIA))
return true
if (game.power === P_AUSTRIA)
@@ -2489,7 +2473,7 @@ states.movement_flanders_next = {
gen_action_power(P_PRAGMATIC)
},
power(pow) {
- flush_move_log()
+ flush_alternate_move()
set_active_to_power(pow)
game.state = "movement"
},
@@ -2525,6 +2509,7 @@ states.movement = {
}
}
+ // if (has_unmoved_piece_on_flanders_map(game.power)) prompt("Move your pieces on the Flanders map.") else
if (done_trains && done_generals)
prompt("Movement done.")
else if (done_generals && !done_trains)
@@ -2534,47 +2519,43 @@ states.movement = {
else
prompt("Move your generals and supply trains.")
- /*
- if (game.flags & F_MOVE_COOP) {
- if (may_dispute_flanders_movement())
- view.actions.dispute = 1
- else
- view.actions.dispute = 0
- if (game.power === P_PRAGMATIC && has_unmoved_piece_on_flanders_map(P_AUSTRIA))
- gen_action_power(P_AUSTRIA)
- if (game.power === P_AUSTRIA && has_unmoved_piece_on_flanders_map(P_PRAGMATIC))
- gen_action_power(P_PRAGMATIC)
- }
-
- if (game.flags & F_MOVE_FLANDERS) {
- if (!has_unmoved_piece_on_flanders_map(P_PRAGMATIC) && !has_unmoved_piece_on_flanders_map(P_AUSTRIA))
- view.actions.end_flanders = 1
- else
- view.actions.end_flanders = 0
- } else {
- if (DEBUG || !has_unmoved_piece(game.power)) {
- if (game.power === P_AUSTRIA && !is_two_player())
- view.actions.end_bohemia = 1
- else
- view.actions.end_movement = 1
+ // austria/pragmatic shared movement phase
+ if (!is_two_player() && !is_intro() && (game.power === P_PRAGMATIC || game.power === P_AUSTRIA)) {
+ if (has_unmoved_piece_on_flanders_map(P_AUSTRIA) || has_unmoved_piece_on_flanders_map(P_PRAGMATIC)) {
+ // pieces left to move on flanders
+ if (!(game.flags & F_MOVE_DISPUTE)) {
+ if (game.power === P_PRAGMATIC && has_unmoved_piece_on_flanders_map(P_AUSTRIA))
+ gen_action_power(P_AUSTRIA)
+ if (game.power === P_AUSTRIA && has_unmoved_piece_on_flanders_map(P_PRAGMATIC))
+ gen_action_power(P_PRAGMATIC)
+ if (may_dispute_flanders_movement())
+ view.actions.dispute = 1
+ else
+ view.actions.dispute = 0
+ }
+ if (game.restart) {
+ if (has_moved_piece_on_flanders_map(P_PRAGMATIC) || has_moved_piece_on_flanders_map(P_AUSTRIA))
+ view.actions.restart = 1
+ else
+ view.actions.restart = 0
+ }
} else {
- if (game.power === P_AUSTRIA && !is_two_player())
- view.actions.end_bohemia = 0
+ // only bohemian pieces left
+ if (!has_unmoved_piece(P_PRAGMATIC) && !has_unmoved_piece(P_AUSTRIA))
+ view.actions.end_movement = 1
+ else if (game.power === P_PRAGMATIC && has_unmoved_piece(P_AUSTRIA))
+ gen_action_power(P_AUSTRIA)
+ else if (game.power === P_AUSTRIA && has_unmoved_piece(P_PRAGMATIC))
+ gen_action_power(P_PRAGMATIC)
else
view.actions.end_movement = 0
}
-
- }
- */
-
- // austria/pragmatic shared movement phase
- if (!is_two_player() && !is_intro()) {
- if (game.restart)
- view.actions.restart = 1
+ } else {
+ if (!has_unmoved_piece(game.power))
+ view.actions.end_movement = 1
+ else
+ view.actions.end_movement = DEBUG
}
-
- if (DEBUG || !has_unmoved_piece(game.power))
- view.actions.end_movement = 1
},
piece(p) {
push_undo()
@@ -2611,7 +2592,6 @@ states.movement = {
this.end_movement()
},
end_movement() {
- delete game.restart // TODO: when?
push_undo()
next_sequence_of_play()
},
@@ -2620,19 +2600,19 @@ states.movement = {
set_active_to_power(pow)
},
restart() {
- clear_undo()
+ let dispute = game.flags & F_MOVE_DISPUTE
game.undo = [ game.restart ]
delete game.restart
pop_undo()
- goto_movement_coop()
+ goto_movement_flanders()
game.state = "restart_flanders_movement"
+ game.flags |= dispute // preserve disputed mode
},
dispute() {
- // enter non-coop mode
- clear_undo()
game.undo = [ game.restart ]
delete game.restart
pop_undo()
+ goto_movement_flanders()
game.state = "dispute_flanders_movement"
game.flags |= F_MOVE_DISPUTE
},
@@ -2656,12 +2636,16 @@ states.dispute_flanders_movement = {
view.actions.next = 1
},
next() {
- log("Alternating moves.")
- next_sequence_of_play() // jump to non-coop movement
+ log("Disputed Flanders movement.")
+ game.state = "movement"
},
}
function end_movement() {
+ game.flags &= ~F_MOVE_DISPUTE
+ game.flags &= ~F_MOVE_FLANDERS
+ delete game.restart
+
if (game.moved.length === 0)
log("Nothing moved.")
@@ -3073,7 +3057,7 @@ function is_alternating_move() {
return false
}
-function flush_move_log() {
+function flush_alternate_move() {
log_conquest(game.move_conq)
game.move_conq = []
log_br()