diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-08 22:53:00 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-08 22:53:00 +0100 |
commit | 7895920ab6b4e34fa675c4fd520b82ca243b80ab (patch) | |
tree | fe1e2871880ea63709940a155ebe48e28f6a8e7e | |
parent | 6c465b792393062fd9ff70bf3aa8ddccd4a7fa4f (diff) | |
download | maria-7895920ab6b4e34fa675c4fd520b82ca243b80ab.tar.gz |
x
-rw-r--r-- | rules.js | 109 |
1 files changed, 40 insertions, 69 deletions
@@ -100,7 +100,7 @@ const F_SAXONY_TC_ONCE = 128 // only draw TCs once per turn const F_FRANCE_REDUCED = 256 const F_PRUSSIA_NEUTRAL = 512 const F_MOVE_FLANDERS = 1024 -const F_MOVE_COOP = 2048 +const F_MOVE_DISPUTE = 2048 const F_INTRODUCTORY = 4096 const F_TWO_PLAYER = 8192 const F_PLAYER_A_PICK = 16384 // picked PC card @@ -1411,16 +1411,9 @@ 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: end_movement }, { power: P_PRAGMATIC, action: goto_movement_coop }, - { power: P_PRAGMATIC, action: goto_movement_flanders }, - { power: P_AUSTRIA, action: goto_movement_flanders }, - { power: P_PRAGMATIC, action: goto_movement_flanders }, - { power: P_AUSTRIA, action: goto_movement_flanders }, - { power: P_PRAGMATIC, action: goto_movement_flanders }, - { power: P_AUSTRIA, action: goto_movement_flanders }, - { power: P_PRAGMATIC, action: goto_movement_flanders }, - { power: P_AUSTRIA, action: goto_movement_bohemia }, - { power: P_AUSTRIA, action: end_movement }, { power: P_AUSTRIA, action: goto_combat }, { power: P_PRAGMATIC, action: goto_combat }, @@ -2383,13 +2376,6 @@ function has_unmoved_piece_on_flanders_map(pow) { return false } -function has_unmoved_piece_on_bohemia_map(pow) { - for (let p of all_power_pieces[pow]) - if (is_bohemia_space(game.pos[p]) && !set_has(game.moved, p)) - return true - return false -} - function goto_movement_global() { game.state = "movement" } @@ -2426,37 +2412,19 @@ function resume_movement() { game.power = P_AUSTRIA set_active_to_power(coop_major_power(game.power)) game.selected = -1 + game.state = "movement" - if ((game.flags & F_MOVE_FLANDERS) && !(game.flags & F_MOVE_COOP)) { - let row = advanced_sequence_of_play[game.stage+1] - if (row.action === goto_movement_flanders) { - let next = game.power === P_PRAGMATIC ? P_AUSTRIA : P_PRAGMATIC - if (!has_unmoved_piece_on_flanders_map(next)) { - ++game.stage // no unmoved pieces, so can skip next step - next_sequence_of_play() - } else { - game.state = "movement_flanders_next" - } - } else { - game.state = "movement" - } - } else { - game.state = "movement" - } + // alternate on flanders map (TODO: when dispute only) + if (is_alternating_move()) + game.state = "movement_flanders_next" } function resume_movement_after_flanders_stacking() { + flush_move_log() set_active_to_power(coop_major_power(game.power)) game.selected = -1 - let row = advanced_sequence_of_play[game.stage+1] - if (row.action === goto_movement_flanders) { - next_sequence_of_play() - } else { - if (has_unmoved_piece_on_flanders_map(game.power)) - game.state = "movement" - else - next_sequence_of_play() - } + game.state = "movement" + // TODO: proper alternation? resume_movement() ? } function is_forbidden_neutral_space(pow, to) { @@ -2520,8 +2488,10 @@ states.movement_flanders_next = { else gen_action_power(P_PRAGMATIC) }, - power(_) { - next_sequence_of_play() + power(pow) { + flush_move_log() + set_active_to_power(pow) + game.state = "movement" }, } @@ -2533,8 +2503,6 @@ states.movement = { for (let p of all_controlled_generals(game.power)) { if (!set_has(game.moved, p) && is_piece_on_map(p)) { - if ((game.flags & F_MOVE_FLANDERS) && !is_flanders_space(game.pos[p])) - continue if (can_general_move_anywhere(p)) { gen_action_piece(p) done_generals = false @@ -2549,8 +2517,6 @@ states.movement = { } if (!set_has(game.moved, p)) { if (is_piece_on_map(p)) { - if ((game.flags & F_MOVE_FLANDERS) && !is_flanders_space(game.pos[p])) - continue if (can_train_move_anywhere(p)) { gen_action_piece(p) done_trains = false @@ -2559,9 +2525,7 @@ states.movement = { } } - if (game.flags & F_MOVE_FLANDERS) - prompt("Move pieces on the Flanders map.") - else if (done_trains && done_generals) + if (done_trains && done_generals) prompt("Movement done.") else if (done_generals && !done_trains) prompt("Move your supply trains.") @@ -2570,6 +2534,7 @@ 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 @@ -2582,8 +2547,6 @@ states.movement = { } if (game.flags & F_MOVE_FLANDERS) { - if (game.restart) - view.actions.restart = 1 if (!has_unmoved_piece_on_flanders_map(P_PRAGMATIC) && !has_unmoved_piece_on_flanders_map(P_AUSTRIA)) view.actions.end_flanders = 1 else @@ -2602,6 +2565,16 @@ states.movement = { } } + */ + + // austria/pragmatic shared movement phase + if (!is_two_player() && !is_intro()) { + if (game.restart) + view.actions.restart = 1 + } + + if (DEBUG || !has_unmoved_piece(game.power)) + view.actions.end_movement = 1 }, piece(p) { push_undo() @@ -2615,6 +2588,11 @@ states.movement = { return } + if (is_flanders_space(game.pos[p])) + game.flags |= F_MOVE_FLANDERS + else + game.flags &= ~F_MOVE_FLANDERS + let here = game.pos[p] if (data.cities.main_roads[here].length > 0) game.main = 1 @@ -2633,18 +2611,10 @@ states.movement = { this.end_movement() }, end_movement() { + delete game.restart // TODO: when? push_undo() next_sequence_of_play() }, - end_bohemia() { - this.end_movement() - }, - end_flanders() { - push_undo() - game.flags &= ~F_MOVE_COOP - delete game.restart - next_sequence_of_play() - }, power(pow) { // cooperative on flanders map set_active_to_power(pow) @@ -2664,6 +2634,7 @@ states.movement = { delete game.restart pop_undo() game.state = "dispute_flanders_movement" + game.flags |= F_MOVE_DISPUTE }, } @@ -3089,7 +3060,7 @@ function is_flanders_stack_move() { } function is_alternating_move() { - if (game.flags & F_MOVE_FLANDERS) { + if (!is_two_player() && !is_intro() && (game.flags & F_MOVE_DISPUTE) && (game.flags & F_MOVE_FLANDERS)) { if (game.power === P_PRAGMATIC) { if (has_unmoved_piece_on_flanders_map(P_AUSTRIA)) return true @@ -3102,6 +3073,12 @@ function is_alternating_move() { return false } +function flush_move_log() { + log_conquest(game.move_conq) + game.move_conq = [] + log_br() +} + function end_move_piece() { let here = game.pos[game.selected] @@ -3121,12 +3098,6 @@ function end_move_piece() { delete game.move_path - if (is_alternating_move()) { - log_conquest(game.move_conq) - game.move_conq = [] - log_br() - } - // uniting stacks: flag all as moved let supreme = false if (is_general(game.selected)) { |