diff options
-rw-r--r-- | play.js | 149 | ||||
-rw-r--r-- | rules.js | 181 |
2 files changed, 163 insertions, 167 deletions
@@ -42,17 +42,14 @@ const suit_class = [ "spades", "clubs", "hearts", "diamonds", "reserve" ] const suit_letter = [ "S", "C", "H", "D", "R" ] const P_FRANCE = 0 -const P_BAVARIA = 1 -const P_PRUSSIA = 2 -const P_SAXONY = 3 -const P_PRAGMATIC = 4 -const P_AUSTRIA = 5 +const P_PRUSSIA = 1 +const P_PRAGMATIC = 2 +const P_AUSTRIA = 3 +const P_BAVARIA = 4 +const P_SAXONY = 5 -const power_name = [ "France", "Bavaria", "Prussia", "Saxony", "Pragmatic Army", "Austria" ] -const power_class = [ "france", "bavaria", "prussia", "saxony", "pragmatic", "austria" ] - -const is_major_power = [ 1, 0, 1, 0, 1, 1 ] -const is_minor_power = [ 0, 1, 0, 1, 0, 0 ] +const power_name = [ "France", "Prussia", "Pragmatic Army", "Austria", "Bavaria", "Saxony" ] +const power_class = [ "france", "prussia", "pragmatic", "austria", "bavaria", "saxony" ] const SPADES = 0 const CLUBS = 1 @@ -68,20 +65,20 @@ const all_powers = [ 0, 1, 2, 3, 4, 5 ] const all_power_generals = [ [ 0, 1, 2, 3, 4 ], - [ 5 ], - [ 6, 7, 8, 9 ], - [ 10 ], - [ 11, 12, 13 ], - [ 14, 15, 16, 17, 18, 19 ], + [ 5, 6, 7, 8 ], + [ 9, 10, 11 ], + [ 12, 13, 14, 15, 16, 17 ], + [ 18 ], + [ 19 ], ] const all_power_trains = [ [ 20, 21 ], - [ 22 ], - [ 23, 24 ], - [ 25 ], - [ 26 ], - [ 27, 28, 29 ], + [ 22, 23 ], + [ 24 ], + [ 25, 26, 27 ], + [ 28 ], + [ 29 ], ] const last_piece = 29 @@ -90,36 +87,36 @@ const all_hussars = [ 30, 31 ] const piece_power = [ P_FRANCE, P_FRANCE, P_FRANCE, P_FRANCE, P_FRANCE, - P_BAVARIA, P_PRUSSIA, P_PRUSSIA, P_PRUSSIA, P_PRUSSIA, - P_SAXONY, P_PRAGMATIC, P_PRAGMATIC, P_PRAGMATIC, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, - P_FRANCE, P_FRANCE, P_BAVARIA, - P_PRUSSIA, P_PRUSSIA, P_SAXONY, + P_FRANCE, P_FRANCE, + P_PRUSSIA, P_PRUSSIA, P_PRAGMATIC, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, + P_BAVARIA, + P_SAXONY, P_AUSTRIA, P_AUSTRIA ] const piece_rank = [ 1, 2, 3, 4, 5, - 1, 1, 2, 3, 4, - 1, 1, 2, 3, 1, 2, 3, 4, 5, 6, + 1, + 1, ] const piece_abbr = [ "F1", "F2", "F3", "F4", "F5", - "B1", "P1", "P2", "P3", "P4", - "S1", "PA1", "PA2", "PA3", "A1", "A2", "A3", "A4", "A5", "A6", + "B1", + "S1", ] const piece_name = [ @@ -128,12 +125,10 @@ const piece_name = [ "Broglie", "Maillebois", "Noailles", - "Törring", "Friedrich", "Schwerin", "Leopold", "Dessauer", - "Rutowski", "George II", "Cumberland", "Earl of Stair", @@ -143,12 +138,14 @@ const piece_name = [ "Batthyány", "Neipperg", "Arenberg", + "Törring", + "Rutowski", "supply train", "supply train", - "supply train", "supply train", "supply train", "supply train", - "supply train", "supply train", "supply train", "supply train", + "supply train", + "supply train", "hussar", "hussar", ] @@ -158,12 +155,10 @@ const piece_log_name = [ "Broglie", "Maillebois", "Noailles", - "Törring", "Friedrich", "Schwerin", "Leopold", "Dessauer", - "Rutowski", "George II", "Cumberland", "Earl of Stair", @@ -173,21 +168,17 @@ const piece_log_name = [ "Batthyány", "Neipperg", "Arenberg", + "Törring", + "Rutowski", "French ST", "French ST", - "Bavarian ST", "Prussian ST", "Prussian ST", - "Saxon ST", "Pragmatic Army ST", "Austrian ST", "Austrian ST", "Austrian ST", + "Bavarian ST", + "Saxon ST", "Hussars", "Hussars", ] - -const all_pieces = [ ...all_power_generals.flat(), ...all_power_trains.flat() ] -const all_trains = [ ...all_power_trains.flat() ] -const all_generals = [ ...all_power_generals.flat() ] -const all_generals_by_rank = all_generals.slice().sort((a,b)=>piece_rank[a]-piece_rank[b]) - function to_deck(c) { return c >> 7 } @@ -288,12 +279,12 @@ function hide_move_path() { /* PANEL ORDER */ -const panel_order = [ P_FRANCE, P_BAVARIA, P_PRUSSIA, P_SAXONY, P_PRAGMATIC, P_AUSTRIA, P_AUSTRIA+1 ] +const panel_order = [ P_FRANCE, P_BAVARIA, P_PRUSSIA, P_SAXONY, P_PRAGMATIC, P_AUSTRIA, 6 ] const panel_start = { - "Observer": P_FRANCE, - "Louis XV": P_FRANCE, - "Frederick": P_PRUSSIA, - "Maria Theresa": P_AUSTRIA, + "Observer": 0, + "Louis XV": 0, + "Frederick": 2, + "Maria Theresa": 5, } function remember_position(e) { @@ -368,29 +359,29 @@ const ui = { power_panel_list: document.getElementById("power_panel_list"), power_header: [ document.getElementById("hand_france_header"), - document.getElementById("hand_bavaria_header"), document.getElementById("hand_prussia_header"), - document.getElementById("hand_saxony_header"), document.getElementById("hand_pragmatic_header"), document.getElementById("hand_austria_header"), + document.getElementById("hand_bavaria_header"), + document.getElementById("hand_saxony_header"), document.getElementById("political_header"), ], power_panel: [ document.getElementById("hand_france_panel"), - document.getElementById("hand_bavaria_panel"), document.getElementById("hand_prussia_panel"), - document.getElementById("hand_saxony_panel"), document.getElementById("hand_pragmatic_panel"), document.getElementById("hand_austria_panel"), + document.getElementById("hand_bavaria_panel"), + document.getElementById("hand_saxony_panel"), document.getElementById("political_panel"), ], hand: [ document.getElementById("hand_france"), - document.getElementById("hand_bavaria"), document.getElementById("hand_prussia"), - document.getElementById("hand_saxony"), document.getElementById("hand_pragmatic"), document.getElementById("hand_austria"), + document.getElementById("hand_bavaria"), + document.getElementById("hand_saxony"), ], cities: [], roads: [], @@ -502,36 +493,38 @@ function on_init() { create_piece("piece", 2, "piece cylinder france france_3"), create_piece("piece", 3, "piece cylinder france france_4"), create_piece("piece", 4, "piece cylinder france france_5"), - create_piece("piece", 5, "piece cylinder bavaria bavaria_1"), - - create_piece("piece", 6, "piece cylinder prussia prussia_1"), - create_piece("piece", 7, "piece cylinder prussia prussia_2"), - create_piece("piece", 8, "piece cylinder prussia prussia_3"), - create_piece("piece", 9, "piece cylinder prussia prussia_4"), - create_piece("piece", 10, "piece cylinder saxony saxony_1"), - create_piece("piece", 11, "piece cylinder pragmatic pragmatic_1"), - create_piece("piece", 12, "piece cylinder pragmatic pragmatic_2"), - create_piece("piece", 13, "piece cylinder pragmatic pragmatic_3"), - - create_piece("piece", 14, "piece cylinder austria austria_1"), - create_piece("piece", 15, "piece cylinder austria austria_2"), - create_piece("piece", 16, "piece cylinder austria austria_3"), - create_piece("piece", 17, "piece cylinder austria austria_4"), - create_piece("piece", 18, "piece cylinder austria austria_5"), - create_piece("piece", 19, "piece cylinder austria austria_6"), + + create_piece("piece", 5, "piece cylinder prussia prussia_1"), + create_piece("piece", 6, "piece cylinder prussia prussia_2"), + create_piece("piece", 7, "piece cylinder prussia prussia_3"), + create_piece("piece", 8, "piece cylinder prussia prussia_4"), + create_piece("piece", 9, "piece cylinder pragmatic pragmatic_1"), + create_piece("piece", 10, "piece cylinder pragmatic pragmatic_2"), + create_piece("piece", 11, "piece cylinder pragmatic pragmatic_3"), + + create_piece("piece", 12, "piece cylinder austria austria_1"), + create_piece("piece", 13, "piece cylinder austria austria_2"), + create_piece("piece", 14, "piece cylinder austria austria_3"), + create_piece("piece", 15, "piece cylinder austria austria_4"), + create_piece("piece", 16, "piece cylinder austria austria_5"), + create_piece("piece", 17, "piece cylinder austria austria_6"), + + create_piece("piece", 18, "piece cylinder bavaria bavaria_1"), + create_piece("piece", 19, "piece cylinder saxony saxony_1"), create_piece("piece", 20, "piece cube france"), create_piece("piece", 21, "piece cube france"), - create_piece("piece", 22, "piece cube bavaria"), + create_piece("piece", 22, "piece cube prussia"), create_piece("piece", 23, "piece cube prussia"), - create_piece("piece", 24, "piece cube prussia"), - create_piece("piece", 25, "piece cube saxony"), - create_piece("piece", 26, "piece cube pragmatic"), + create_piece("piece", 24, "piece cube pragmatic"), + create_piece("piece", 25, "piece cube austria"), + create_piece("piece", 26, "piece cube austria"), create_piece("piece", 27, "piece cube austria"), - create_piece("piece", 28, "piece cube austria"), - create_piece("piece", 29, "piece cube austria"), + + create_piece("piece", 28, "piece cube bavaria"), + create_piece("piece", 29, "piece cube saxony"), create_piece("piece", 30, "piece disc austria"), create_piece("piece", 31, "piece disc austria"), @@ -543,8 +536,8 @@ function on_init() { for (let e of ui.troops) ui.pieces_element.appendChild(e) - ui.victory = [ [], [], [], [], [], [] ] - ui.retro = [ [], [], [], [], [], [] ] + ui.victory = [ [], [], [], [] ] + ui.retro = [ [], [], [], [] ] for (let pow of [ P_FRANCE, P_PRUSSIA, P_PRAGMATIC, P_AUSTRIA ]) { ui.victory[pow] = [] ui.retro[pow] = [] @@ -72,17 +72,14 @@ const suit_class = [ "spades", "clubs", "hearts", "diamonds", "reserve" ] const suit_letter = [ "S", "C", "H", "D", "R" ] const P_FRANCE = 0 -const P_BAVARIA = 1 -const P_PRUSSIA = 2 -const P_SAXONY = 3 -const P_PRAGMATIC = 4 -const P_AUSTRIA = 5 +const P_PRUSSIA = 1 +const P_PRAGMATIC = 2 +const P_AUSTRIA = 3 +const P_BAVARIA = 4 +const P_SAXONY = 5 -const power_name = [ "France", "Bavaria", "Prussia", "Saxony", "Pragmatic Army", "Austria" ] -const power_class = [ "france", "bavaria", "prussia", "saxony", "pragmatic", "austria" ] - -const is_major_power = [ 1, 0, 1, 0, 1, 1 ] -const is_minor_power = [ 0, 1, 0, 1, 0, 0 ] +const power_name = [ "France", "Prussia", "Pragmatic Army", "Austria", "Bavaria", "Saxony" ] +const power_class = [ "france", "prussia", "pragmatic", "austria", "bavaria", "saxony" ] const SPADES = 0 const CLUBS = 1 @@ -98,20 +95,20 @@ const all_powers = [ 0, 1, 2, 3, 4, 5 ] const all_power_generals = [ [ 0, 1, 2, 3, 4 ], - [ 5 ], - [ 6, 7, 8, 9 ], - [ 10 ], - [ 11, 12, 13 ], - [ 14, 15, 16, 17, 18, 19 ], + [ 5, 6, 7, 8 ], + [ 9, 10, 11 ], + [ 12, 13, 14, 15, 16, 17 ], + [ 18 ], + [ 19 ], ] const all_power_trains = [ [ 20, 21 ], - [ 22 ], - [ 23, 24 ], - [ 25 ], - [ 26 ], - [ 27, 28, 29 ], + [ 22, 23 ], + [ 24 ], + [ 25, 26, 27 ], + [ 28 ], + [ 29 ], ] const last_piece = 29 @@ -120,36 +117,36 @@ const all_hussars = [ 30, 31 ] const piece_power = [ P_FRANCE, P_FRANCE, P_FRANCE, P_FRANCE, P_FRANCE, - P_BAVARIA, P_PRUSSIA, P_PRUSSIA, P_PRUSSIA, P_PRUSSIA, - P_SAXONY, P_PRAGMATIC, P_PRAGMATIC, P_PRAGMATIC, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, - P_FRANCE, P_FRANCE, P_BAVARIA, - P_PRUSSIA, P_PRUSSIA, P_SAXONY, + P_FRANCE, P_FRANCE, + P_PRUSSIA, P_PRUSSIA, P_PRAGMATIC, P_AUSTRIA, P_AUSTRIA, P_AUSTRIA, + P_BAVARIA, + P_SAXONY, P_AUSTRIA, P_AUSTRIA ] const piece_rank = [ 1, 2, 3, 4, 5, - 1, 1, 2, 3, 4, - 1, 1, 2, 3, 1, 2, 3, 4, 5, 6, + 1, + 1, ] const piece_abbr = [ "F1", "F2", "F3", "F4", "F5", - "B1", "P1", "P2", "P3", "P4", - "S1", "PA1", "PA2", "PA3", "A1", "A2", "A3", "A4", "A5", "A6", + "B1", + "S1", ] const piece_name = [ @@ -158,12 +155,10 @@ const piece_name = [ "Broglie", "Maillebois", "Noailles", - "Törring", "Friedrich", "Schwerin", "Leopold", "Dessauer", - "Rutowski", "George II", "Cumberland", "Earl of Stair", @@ -173,12 +168,14 @@ const piece_name = [ "Batthyány", "Neipperg", "Arenberg", + "Törring", + "Rutowski", "supply train", "supply train", - "supply train", "supply train", "supply train", "supply train", - "supply train", "supply train", "supply train", "supply train", + "supply train", + "supply train", "hussar", "hussar", ] @@ -188,12 +185,10 @@ const piece_log_name = [ "Broglie", "Maillebois", "Noailles", - "Törring", "Friedrich", "Schwerin", "Leopold", "Dessauer", - "Rutowski", "George II", "Cumberland", "Earl of Stair", @@ -203,21 +198,17 @@ const piece_log_name = [ "Batthyány", "Neipperg", "Arenberg", + "Törring", + "Rutowski", "French ST", "French ST", - "Bavarian ST", "Prussian ST", "Prussian ST", - "Saxon ST", "Pragmatic Army ST", "Austrian ST", "Austrian ST", "Austrian ST", + "Bavarian ST", + "Saxon ST", "Hussars", "Hussars", ] - -const all_pieces = [ ...all_power_generals.flat(), ...all_power_trains.flat() ] -const all_trains = [ ...all_power_trains.flat() ] -const all_generals = [ ...all_power_generals.flat() ] -const all_generals_by_rank = all_generals.slice().sort((a,b)=>piece_rank[a]-piece_rank[b]) - function to_deck(c) { return c >> 7 } @@ -293,6 +284,11 @@ const DRESDEN = find_city("Dresden") const ENGLAND = find_city("England") +const all_pieces = [ ...all_power_generals.flat(), ...all_power_trains.flat() ] +const all_trains = [ ...all_power_trains.flat() ] +const all_generals = [ ...all_power_generals.flat() ] +const all_generals_by_rank = all_generals.slice().sort((a,b)=>piece_rank[a]-piece_rank[b]) + const all_france_bavaria_generals = [ ...all_power_generals[P_FRANCE], ...all_power_generals[P_BAVARIA], @@ -604,19 +600,19 @@ set_add_all(all_fortresses, data.type.minor_fortress) const all_home_country_fortresses = [] all_home_country_fortresses[P_FRANCE] = set_intersect(all_fortresses, data.country.France) -all_home_country_fortresses[P_BAVARIA] = set_intersect(all_fortresses, data.country.Bavaria) all_home_country_fortresses[P_PRUSSIA] = set_intersect(all_fortresses, data.country.Prussia) -all_home_country_fortresses[P_SAXONY] = set_intersect(all_fortresses, data.country.Saxony) -all_home_country_fortresses[P_AUSTRIA] = set_intersect(all_fortresses, data.country.Austria) all_home_country_fortresses[P_PRAGMATIC] = set_intersect(all_fortresses, data.country.Netherlands) +all_home_country_fortresses[P_AUSTRIA] = set_intersect(all_fortresses, data.country.Austria) +all_home_country_fortresses[P_BAVARIA] = set_intersect(all_fortresses, data.country.Bavaria) +all_home_country_fortresses[P_SAXONY] = set_intersect(all_fortresses, data.country.Saxony) const all_home_country_major_fortresses = [] all_home_country_major_fortresses[P_FRANCE] = set_intersect(data.type.major_fortress, data.country.France) -all_home_country_major_fortresses[P_BAVARIA] = set_intersect(data.type.major_fortress, data.country.Bavaria) all_home_country_major_fortresses[P_PRUSSIA] = set_intersect(data.type.major_fortress, data.country.Prussia) -all_home_country_major_fortresses[P_SAXONY] = set_intersect(data.type.major_fortress, data.country.Saxony) -all_home_country_major_fortresses[P_AUSTRIA] = set_intersect(data.type.major_fortress, data.country.Austria) all_home_country_major_fortresses[P_PRAGMATIC] = set_intersect(data.type.major_fortress, data.country.Netherlands) +all_home_country_major_fortresses[P_AUSTRIA] = set_intersect(data.type.major_fortress, data.country.Austria) +all_home_country_major_fortresses[P_BAVARIA] = set_intersect(data.type.major_fortress, data.country.Bavaria) +all_home_country_major_fortresses[P_SAXONY] = set_intersect(data.type.major_fortress, data.country.Saxony) const all_silesian_fortresses = set_intersect(all_fortresses, data.country.Silesia) @@ -637,11 +633,11 @@ function is_home_country(s) { // TODO: Silesia switch (game.power) { case P_FRANCE: return set_has(data.country.France, s) - case P_BAVARIA: return set_has(data.country.Bavaria, s) case P_PRUSSIA: return set_has(data.country.Prussia, s) - case P_SAXONY: return set_has(data.country.Saxony, s) - case P_AUSTRIA: return set_has(data.country.Austria, s) case P_PRAGMATIC: return set_has(data.country.Netherlands, s) + case P_AUSTRIA: return set_has(data.country.Austria, s) + case P_BAVARIA: return set_has(data.country.Bavaria, s) + case P_SAXONY: return set_has(data.country.Saxony, s) } } @@ -720,7 +716,7 @@ function is_protected_from_conquest(s) { /* STATE */ -const tc_per_turn_table = [ 5, 1, 3, 1, 3, 5 ] +const tc_per_turn_table = [ 5, 3, 3, 5, 1, 1 ] function tc_per_turn() { let n = tc_per_turn_table[game.power] @@ -739,16 +735,17 @@ function tc_per_turn() { function player_from_power(pow) { switch (pow) { case P_FRANCE: - case P_BAVARIA: return R_LOUIS_XV case P_PRUSSIA: return R_FREDERICK - case P_SAXONY: - return R_FREDERICK case P_PRAGMATIC: return R_FREDERICK case P_AUSTRIA: return R_MARIA_THERESA + case P_SAXONY: + return R_FREDERICK + case P_BAVARIA: + return R_LOUIS_XV } } @@ -909,10 +906,10 @@ const POWER_FROM_ACTION_STAGE = [ ] const title_from_action_stage = [ - "=0 France and Bavaria", - "=2 Prussia and Saxony", - "=5 Austria", - "=4 Pragmatic Army", + "=" + P_FRANCE + "France and Bavaria", + "=" + P_PRUSSIA + "Prussia and Saxony", + "=" + P_PRAGMATIC + "Pragmatic Army", + "=" + P_AUSTRIA + "Austria", ] function set_active_to_current_action_stage() { @@ -929,12 +926,12 @@ const POWER_FROM_WINTER_STAGE = [ ] const title_from_winter_stage = [ - "=0", - "=1", - "=2", - "=3", - "=4", - "=5", + "=" + P_FRANCE, + "=" + P_BAVARIA, + "=" + P_PRUSSIA, + "=" + P_SAXONY, + "=" + P_PRAGMATIC, + "=" + P_AUSTRIA, ] function set_active_to_current_winter_stage() { @@ -3105,9 +3102,7 @@ function goto_retroactive_conquest() { const POWER_FROM_SETUP_STAGE = [ P_FRANCE, - P_BAVARIA, P_PRUSSIA, - P_SAXONY, P_PRAGMATIC, P_AUSTRIA, ] @@ -3117,26 +3112,35 @@ function set_active_setup_power() { game.active = current_player() } -const setup_initial_tcs = [ 2, 5, 9, 3, 3, 5 ] +const setup_initial_tcs = [ 2, 9, 3, 5, 5, 3 ] -const setup_total_troops = [ 26, 5, 16+6, 5, 14, 28 ] +const setup_total_troops = [ 26, 16+6, 14, 28, 5, 5 ] const setup_min_troops = [ 1, 1, 1, 1, 1, - 5, 1, 1, 4, 6, - 5, 1, 1, 1, 1, 1, 6, 2, 1, 4, + 5, + 5, ] const setup_max_troops = [ 8, 8, 8, 8, 8, - 5, 8, 8, 8, 6, - 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 5, + 5, +] + +const setup_troops = [ + 0, 0, 0, 0, 0, + 0, 0, 0, 6, + 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 5, + 5, ] const setup_piece_position = [ @@ -3149,18 +3153,12 @@ const setup_piece_position = [ find_city("Créspy-en-V."), find_city("Sarreguemines"), - // B - find_city("Ergoldsbach"), - // P find_city("Steinau"), find_city("Steinau"), find_city("Sprottau"), find_city("East Prussia"), - // S - find_city("Radeberg"), - // PA find_city("Delfzijl"), find_city("Delfzijl"), @@ -3174,22 +3172,22 @@ const setup_piece_position = [ find_city("Trübau"), find_city("Malmedy"), + // B + find_city("Ergoldsbach"), + + // S + find_city("Radeberg"), + // - TRAINS - // F find_city("Bar-le-Duc"), find_city("Regensburg"), - // B - find_city("Falkenstein"), - // P find_city("Grünberg"), find_city("Silesia Victory"), - // S - find_city("Meißen"), - // PA find_city("Tilburg"), @@ -3198,6 +3196,12 @@ const setup_piece_position = [ find_city("Bruck"), find_city("Geel"), + // B + find_city("Falkenstein"), + + // S + find_city("Meißen"), + // Hussars ELIMINATED, ELIMINATED @@ -3255,7 +3259,7 @@ exports.setup = function (seed, _scenario, _options) { pos: setup_piece_position.slice(), oos: 0, supreme: 0, - troops: new Array(20).fill(0), + troops: setup_troops.slice(), victory: [], elector: [], @@ -3304,7 +3308,7 @@ states.setup = { } else { let n_stacks = 0 for (let p of all_power_generals[game.power]) { - if (!set_has(game.moved, p)) { + if (game.troops[p] === 0) { gen_action_piece(p) n_stacks ++ } @@ -3319,7 +3323,6 @@ states.setup = { }, piece(p) { push_undo() - set_add(game.moved, p) game.selected = p game.state = "setup_general" }, @@ -3377,7 +3380,7 @@ states.setup_general = { } function end_setup() { - if (++game.stage === 6) { + if (++game.stage === 4) { goto_start_turn() } else { set_active_setup_power() |