From 8772993aa7b3a9dacbe8102e649af3f7a159b6cf Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 9 Jul 2023 17:04:28 +0200 Subject: Damnatio & Pretender fixes. --- rules.js | 62 +++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/rules.js b/rules.js index 85dcf54..dfc28bf 100644 --- a/rules.js +++ b/rules.js @@ -2647,7 +2647,7 @@ states.damnatio_memoriae = { }, pass() { push_undo() - resume_take_actions() + goto_becoming_emperor() }, } @@ -2676,7 +2676,7 @@ states.damnatio_memoriae_mobs = { logi("Mob in %" + where + ".") set_mobs(where, get_mobs(where) + 1) if (--game.count === 0) - resume_take_actions() + goto_becoming_emperor() }, } @@ -2966,6 +2966,7 @@ states.replace_pretender_governor = { push_undo() log("Replace Governor in %" + game.where + ".") set_governor_location(id, game.where) + update_neutral_italia() resume_take_actions() }, pass() { @@ -3284,15 +3285,23 @@ states.pretender_seat_of_power = { }, } -function goto_pretender_breakaway() { - let seat = find_seat_of_power() - for (let where of PRETENDER_ADJACENT[seat]) { - if (get_support(where) >= 3 && !is_breakaway(where) && is_own_province(where)) { - game.state = "pretender_breakaway" - return +function calc_breakaway_empire(start) { + for (let where of PRETENDER_ADJACENT[start]) { + let bit = 1 << where + if (!(game.count & bit) && get_support(where) >= 3 && !is_pretender_province(where) && is_own_province(where)) { + game.count |= bit + calc_breakaway_empire(where) } } - resume_take_actions() +} + +function goto_pretender_breakaway() { + game.count = 0 + calc_breakaway_empire(find_seat_of_power()) + if (game.count) + game.state = "pretender_breakaway" + else + resume_take_actions() } states.pretender_breakaway = { @@ -3301,16 +3310,18 @@ states.pretender_breakaway = { prompt("Pretender: Place breakaway markers.") view.color = POPULACE let seat = find_seat_of_power() - for (let where of PRETENDER_ADJACENT[seat]) - if (get_support(where) >= 3 && !is_breakaway(where) && is_own_province(where)) + for (let where = 0; where < 12; ++where) + if (game.count & (1 << where)) gen_action_region(where) }, region(where) { push_undo() log("Breakaway in %" + where + ".") + game.count &= ~(1 << where) add_breakaway(where) remove_quaestor(where) // no effect anymore - goto_pretender_breakaway() + if (game.count === 0) + resume_take_actions() }, } @@ -4720,14 +4731,16 @@ states.support_check_mobs = { // === EXPAND PRETENDER EMPIRE === function goto_expand_pretender_empire() { - for (let where = 1; where < 12; ++where) { - if (is_expand_pretender_province(where)) { - log_h3("Expand Pretender Empire") - game.state = "expand_pretender_empire" - return - } + game.count = 0 + for (let where = 1; where < 12; ++where) + if (is_expand_pretender_province(where)) + game.count |= (1 << where) + if (game.count) { + log_h3("Expand Pretender Empire") + game.state = "expand_pretender_empire" + } else { + goto_gain_legacy() } - goto_gain_legacy() } states.expand_pretender_empire = { @@ -4736,15 +4749,17 @@ states.expand_pretender_empire = { prompt("Expand Pretender Empire: Add breakaway markers.") view.color = POPULACE for (let where = 1; where < 12; ++where) - if (is_expand_pretender_province(where)) + if (game.count & (1 << where)) gen_action_region(where) }, region(where) { push_undo() logi("Breakaway %" + where) + game.count &= ~(1 << where) add_breakaway(where) remove_quaestor(where) // no effect anymore - goto_expand_pretender_empire() + if (game.count === 0) + goto_gain_legacy() }, } @@ -4773,6 +4788,7 @@ states.legitimize_claim = { inactive: "Gain Legacy", prompt() { prompt("Gain Legacy: Remove seat of power and breakaway markers in your provinces.") + view.color = POPULACE for (let where = 1; where < 12; ++where) if (is_own_province(where) && is_seat_of_power(where) || is_breakaway(where)) gen_action_region(where) @@ -4814,7 +4830,7 @@ function goto_gain_legacy_provinces() { award_legacy_summary(game.current, "Provinces", count_own_provinces()) award_legacy_summary(game.current, "Improvements", count_own_improvements()) - if (is_emperor_player() && game.legacy[game.current] >= 60) { + if (!game.end && is_emperor_player() && game.legacy[game.current] >= 60) { log_br() log("Game will end after this round!") game.end = 1 @@ -5098,12 +5114,12 @@ states.refill_hand = { flip_discard_to_available() }, end_turn() { - clear_undo() end_refill_hand() } } function end_refill_hand() { + clear_undo() game.current = next_player() if (game.current === game.first && game.end) goto_game_end() -- cgit v1.2.3