diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 110 |
1 files changed, 88 insertions, 22 deletions
@@ -516,6 +516,10 @@ const all_prussia_pragmatic_austria_bavaria_saxony_pieces = [ all_prussia_pieces /* DATA */ +function is_major_power(pow) { + return pow < 4 +} + function is_bohemia_space(s) { return s >= 0 && s <= 401 } @@ -1081,13 +1085,16 @@ function is_two_player() { return game.flags & F_TWO_PLAYER } -const tc_per_turn_table = [ 5, 3, 3, 5, 1, 1 ] - -function tc_per_turn() { - let n = tc_per_turn_table[game.power] +const TC_PER_TURN_TABLE = [ 5, 3, 3, 5, 1, 1 ] +function tc_per_turn_base() { if (game.power === P_FRANCE && is_intro()) - n = 3 + return 3 + return TC_PER_TURN_TABLE[game.power] +} + +function tc_per_turn_modifier() { + let n = 0 // Saxony track if (game.power === P_SAXONY) { @@ -1131,6 +1138,28 @@ function tc_per_turn() { return n } +function tc_per_turn() { + return tc_per_turn_base() + tc_per_turn_modifier() +} + +function count_subsidies(pow) { + let n = 0 + if (game.contracts[game.power]) + for (let other of all_powers) + if (map_get(game.contracts[game.power], other, 0) > 0) + ++n + return n +} + +function list_subsidies(pow) { + let result = [] + if (game.contracts[game.power]) + for (let other of all_powers) + if (map_get(game.contracts[game.power], other, 0) > 0) + result.push(power_name[other]) + return result +} + function player_from_power(pow) { if (is_two_player()) { switch (pow) { @@ -1714,7 +1743,7 @@ function total_discard_list() { function log_draw_tc(k, pow) { if (pow >= 0 && k >= 0) { if (pow !== game.power) - log(`${power_name[pow]} ${k} TC (${power_name[game.power]}).`) + log(`${power_name[pow]} ${k} TC (subsidy).`) else log(`${power_name[pow]} ${k} TC.`) } @@ -1753,8 +1782,6 @@ function give_subsidy(other) { } function goto_tactical_cards() { - clear_undo() // reveal random cards - if (game.power === P_SAXONY) { if (game.flags & F_SAXONY_TC_ONCE) { next_sequence_of_play() @@ -1763,8 +1790,15 @@ function goto_tactical_cards() { game.flags |= F_SAXONY_TC_ONCE } - game.draw = [] + if (is_major_power(game.power)) + game.state = "tactical_cards_draw" + else + draw_tactical_cards() +} +function draw_tactical_cards() { + clear_undo() // reveal random cards + game.draw = [] if (game.power === P_BAVARIA && is_enemy_controlled_fortress(MUNCHEN)) { log("Bavaria TC draw lost\nS" + MUNCHEN + " is enemy controlled.") } else if (game.power === P_SAXONY && is_enemy_controlled_fortress(DRESDEN)) { @@ -1839,18 +1873,6 @@ function goto_tactical_cards() { game.state = "tactical_cards_show" } -states.tactical_cards_show = { - inactive: "draw tactical cards", - prompt() { - view.draw = game.draw - prompt("Draw " + format_card_list_prompt(game.draw) + ".") - view.actions.end_cards = 1 - }, - end_cards() { - end_tactical_cards() - }, -} - function end_tactical_cards() { for (let c of game.hand2[game.power]) set_add(game.hand1[game.power], c) @@ -1863,6 +1885,48 @@ function end_tactical_cards() { next_sequence_of_play() } +states.tactical_cards_draw = { + inactive: "draw tactical cards", + prompt() { + let base = tc_per_turn_base() + let mod = tc_per_turn_modifier() + let sub = count_subsidies(game.power) + + let str = "Draw " + base + " " + if (mod < 0) + str += "\u2212" + (-mod) + " " + else if (mod > 0) + str += "+" + (mod) + " " + str += "TC." + + if (sub > 0) + str += " Give " + sub + " TC to " + list_subsidies().join(" and ") + "." + + prompt(str) + if (base + mod - sub >= 0) + view.actions.draw = 1 + else + view.actions.draw = 0 + // else cancel contracts! + // TODO: force france to cancel one subsidy if prussia cannot draw cards + }, + draw() { + draw_tactical_cards() + }, +} + +states.tactical_cards_show = { + inactive: "draw tactical cards", + prompt() { + view.draw = game.draw + prompt("Draw " + format_card_list_prompt(game.draw) + ".") + view.actions.next = 1 + }, + next() { + end_tactical_cards() + }, +} + /* PAYMENT */ function sum_card_values(list) { @@ -4515,7 +4579,7 @@ states.determine_trump_suit = { // 25.4 Place TCs on the political display function goto_place_tc_on_display() { - log("Place TCs on political display") + log("Place TC on political display") next_place_tc_on_display() } @@ -6184,6 +6248,7 @@ states.cancel_subsidy_approve_both = { let to = game.proposal.to prompt(`Cancel subsidy contract from ${power_name[from]} to ${power_name[to]}?`) view.actions.accept = 1 + // TODO: cannot refuse if minor power fortress is occupied! view.actions.refuse = 1 }, accept() { @@ -6206,6 +6271,7 @@ states.cancel_subsidy_approve_last = { let to = game.proposal.to prompt(`Cancel subsidy contract from ${power_name[from]} to ${power_name[to]}?`) view.actions.accept = 1 + // TODO: cannot refuse if minor power fortress is occupied! view.actions.refuse = 1 }, accept() { |