diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 134 |
1 files changed, 46 insertions, 88 deletions
@@ -95,66 +95,6 @@ const COOPERATE = [ [ P_AUSTRIA, P_PRAGMATIC ], ] -exports.setup = function (seed, _scenario, _options) { - game = { - seed: seed, - log: [], - undo: [], - active: 0, // player - power: 0, // power - state: "setup", - - turn: 1, - step: 0, - ctl: [], - loc: [], - str: [], - } - - Austria 6 Malmedy - Austria T Geel - - Austria 1 Austerlitz - Austria 2 Steinamanger - Austria 3 Stuhlweißenburg - Austria 4 Stuhlweißenburg - Austria 5 Trübau - Austria T Hlinsko - Austria T Bruck - Austria H1 Off-map - Austria H2 Off-map - - Prussia 1 Steinau - Prussia 2 Steinau - Prussia 3 Sprottau - Prussia 4 Ostpreussen Box - Prussia T Grünberg - Prussia T Silesia Box - - Saxony 1 Radeberg - Saxony T Meißen - - Bavaria 1 Ergoldsbach - Bavaria T Falkenstein - - France 1 Beaune - France T Bar-le-Duc - France 5 Sarreguemines - France 4 Créspy-en-V. - - France 2 Schwandorf - France 3 Ergoldsbach - France T Regensburg - - Pragmatic T Tilburg - Pragmatic 3 Dordecht - Pragmatic 1 Delfzijl - Pragmatic 2 Delfzijl - - - return game -} - */ @@ -555,14 +495,6 @@ function count_unused_troops_on_map() { return n } -function count_unused_generals() { - let n = 0 - for (let p of all_power_generals[game.power]) - if (game.pos[p] !== REMOVED && game.troops[p] === 0) - ++n - return n -} - function has_any_piece(to) { for (let s of game.pos) if (s === to) @@ -1338,7 +1270,7 @@ function sum_card_values(list) { } function find_largest_card(list) { - for (let v = 13; v >= 2; --v) { + for (let v = 10; v >= 2; --v) { for (let c of list) if (to_value(c) === v) return c @@ -2439,7 +2371,7 @@ const POWER_FROM_SETUP_STEP = [ P_BAVARIA, P_PRUSSIA, P_SAXONY, - P_PRUSSIA, + P_PRAGMATIC, P_AUSTRIA, ] @@ -2452,13 +2384,22 @@ const setup_initial_tcs = [ 2, 5, 9, 3, 3, 5 ] const setup_total_troops = [ 26, 5, 16+6, 5, 14, 28 ] -const setup_troops = [ - 0, 0, 0, 0, 0, +const setup_min_troops = [ + 1, 1, 1, 1, 1, 5, - 0, 0, 4, 6, + 1, 1, 4, 6, 5, - 0, 0, 0, - 0, 0, 6, 2, 0, 4, + 1, 1, 1, + 1, 1, 6, 2, 1, 4, +] + +const setup_max_troops = [ + 8, 8, 8, 8, 8, + 5, + 8, 8, 8, 6, + 8, + 8, 8, 8, + 8, 8, 8, 8, 8, 8, ] const setup_piece_position = [ @@ -2536,7 +2477,7 @@ function make_political_deck() { function make_tactics_deck(n) { let deck = [] for (let suit = 0; suit <= 3; ++suit) - for (let value = 2; value <= 13; ++value) + for (let value = 2; value <= 10; ++value) deck.push((n << 7) | (suit << 4) | value) deck.push((n << 7) | (RESERVE << 4) | 2) deck.push((n << 7) | (RESERVE << 4) | 3) @@ -2570,11 +2511,11 @@ exports.setup = function (seed, _scenario, _options) { step: 0, pol_deck: null, deck: null, - hand: [], + hand: [ [], [], [], [], [], [] ], pos: setup_piece_position.slice(), oos: 0, - troops: setup_troops.slice(), + troops: setup_min_troops.map(n => 0), conquest: [], moved: [], @@ -2634,21 +2575,41 @@ states.setup = { }, } +function count_unsetup_min() { + let n = 0 + for (let p of all_power_generals[game.power]) + if (game.troops[p] === 0) + n += setup_min_troops[p] + return n +} + +function count_unsetup_max() { + let n = 0 + for (let p of all_power_generals[game.power]) + if (game.troops[p] === 0) + n += setup_max_troops[p] + return n +} + states.setup_general = { inactive: "setup troops", prompt() { prompt("Add troops to " + format_selected() + ".") view.selected = game.selected - let n_selected = game.selected.length - let n_other = count_unused_generals() - game.selected.length + let who = game.selected[0] + + let n_self_min = setup_min_troops[who] + let n_self_max = setup_max_troops[who] + let n_other_min = count_unsetup_min() - n_self_min + let n_other_max = count_unsetup_max() - n_self_max let n_troops = setup_total_troops[game.power] - count_used_troops() // leave at least 1 for each remaining general - let take_max = Math.min(8 * n_selected, n_troops - n_other) + let take_max = Math.min(n_self_max, n_troops - n_other_min) // leave no more than 8 for each remaining general - let take_min = Math.max(1 * n_selected, n_troops - n_other * 8) + let take_min = Math.max(n_self_min, n_troops - n_other_max) view.actions.value = [] for (let i = take_min; i <= take_max; ++i) @@ -2658,7 +2619,7 @@ states.setup_general = { let save = game.selected.length - 1 for (let p of game.selected) { let n = Math.min(8, v - save) - game.troops[p] = n + game.troops[p] += n v -= n --save } @@ -2668,12 +2629,10 @@ states.setup_general = { } function end_setup() { - if (++game.step === 7) { + if (++game.step === 6) { goto_start_turn() } else { set_active_setup_power() - if (count_unused_generals() === 0) - end_setup() } } @@ -2727,13 +2686,12 @@ exports.view = function (state, player) { actions: null, log: game.log, - fate: game.turn <= 5 ? game.turn : game.fate, + turn: game.turn, pos: game.pos, oos: game.oos, conquest: game.conquest, troops: mask_troops(player), hand: mask_hand(player), - oo: game.oo, pt: total_troops_list(), power: game.power, |