diff options
-rw-r--r-- | rules.js | 138 |
1 files changed, 75 insertions, 63 deletions
@@ -1097,7 +1097,7 @@ function eliminate_military_emperor(id) { if (is_emperor_player()) game.combat.own_military_emperor_died = 1 log(PLAYER_NAME[id/6|0] + " Emperor died!") - remove_governor(ITALIA) + remove_governor(ITALIA, true) } function assign_hit_to_legion(id) { @@ -1433,6 +1433,8 @@ function roll_barbarian_crisis() { function goto_barbarian_invasion(tribe, black) { game.count = black + log_br() + // Ardashir: All active Sassanids invade! if (tribe === SASSANIDS) { if (get_barbarian_location(ARDASHIR) === SASSANIDS_HOMELAND) @@ -1486,7 +1488,7 @@ function barbarian_name(id) { } function invade_with_barbarian_counter(id, path, where) { - logi(barbarian_name(id) + " to %" + where) + log(barbarian_name(id) + " to %" + where + ".") set_barbarian_location(id, where) for (let loc of path) { if (has_limes(loc)) @@ -1655,7 +1657,7 @@ states.ludi_saeculares = { }, card(c) { push_undo() - logi("Discard " + card_name(c)) + log("Discarded " + card_name(c) + ".") set_delete(current_hand(), c) set_add(current_discard(), c) award_legacy(game.current, "Ludi Saeculares", 2 * card_value(c)) @@ -2247,7 +2249,7 @@ function recall_governor() { log("Recall Governor from %" + where + ".") spend_senate(2) set_placed_governor(where) - remove_governor(where) + remove_governor(where, false) } // ACTION: PLACE GOVERNOR @@ -2260,7 +2262,7 @@ function gen_place_governor() { function reduce_support(where) { if (get_support(where) === 1) - remove_governor(where) + remove_governor(where, true) else set_support(where, get_support(where) - 1) } @@ -2274,12 +2276,13 @@ function remove_emperor_token(where) { if (where === ITALIA) game.emperor = NEUTRAL_EMPEROR else if (is_populace_emperor_seat(where)) - remove_governor(ITALIA) + remove_governor(ITALIA, true) } } -function remove_governor(where) { - log("Removed governor from %" + where + ".") +function remove_governor(where, verbose) { + if (verbose) + log("Removed governor in %" + where + ".") eliminate_militia(where) set_mobs(where, 0) @@ -2330,8 +2333,6 @@ function place_governor(where, new_governor) { if (where !== ITALIA && is_governor_of_emperor_player(new_governor)) increase_support(ITALIA) - log_br() - update_neutral_italia() } @@ -2526,9 +2527,8 @@ function roll_to_place_governor(praetorian_guard) { if (have >= need) { goto_place_governor_success() } else { - log("Failed with " + have + " votes!") - log_br() - resume_take_actions() + log("Failed with " + have + (have === 1 ? " vote." : " votes.")) + end_place_governor() } } @@ -2574,7 +2574,7 @@ function goto_place_governor_success() { } } else { place_governor(game.where, game.selected_governor) - resume_take_actions() + end_place_governor() } } @@ -2652,14 +2652,14 @@ states.damnatio_memoriae = { } function play_damnatio_memoriae() { - award_legacy(game.count >> 3, "Damnatio Memoriae", -get_support(ITALIA)) + remove_legacy(game.count >> 3, get_support(ITALIA)) game.state = "damnatio_memoriae_mobs" game.count = game.count & 7 } function play_damnatio_memoriae_exp() { - award_legacy(game.count >> 3, "Damnatio Memoriae", -get_support(ITALIA)) - resume_take_actions() + remove_legacy(game.count >> 3, get_support(ITALIA)) + goto_becoming_emperor() } states.damnatio_memoriae_mobs = { @@ -2673,7 +2673,7 @@ states.damnatio_memoriae_mobs = { }, region(where) { push_undo() - logi("Mob in %" + where + ".") + log("Placed mob in %" + where + ".") set_mobs(where, get_mobs(where) + 1) if (--game.count === 0) goto_becoming_emperor() @@ -2710,7 +2710,7 @@ function goto_becoming_emperor() { if (game.emperor === NEUTRAL_EMPEROR) game.state = "becoming_emperor" else - resume_take_actions() + end_place_governor() } function has_mobs_in_own_provinces() { @@ -2738,16 +2738,14 @@ states.becoming_emperor = { game.emperor = id let where = get_governor_location(id) if (where === ITALIA) { - log("Senate Emperor in Italia.") - log_br() - resume_take_actions() + log("Senate Emperor.") + end_place_governor() } else { log("Populace Emperor in %" + where + ".") - log_br() if (has_mobs_in_own_provinces()) game.state = "becoming_populace_emperor" else - resume_take_actions() + end_place_governor() } }, general(id) { @@ -2755,8 +2753,7 @@ states.becoming_emperor = { game.emperor = ARMY + id let where = get_general_location(id) log("Military Emperor in %" + where + ".") - log_br() - resume_take_actions() + end_place_governor() }, } @@ -2772,13 +2769,18 @@ states.becoming_populace_emperor = { }, region(where) { push_undo() - log("Remove mob from %" + where + ".") + log("Removed mob in %" + where + ".") set_mobs(where, 0) if (!has_mobs_in_own_provinces()) - resume_take_actions() + end_place_governor() }, } +function end_place_governor() { + log_br() + resume_take_actions() +} + // ACTION: CREATE ARMY function gen_create_army() { @@ -2870,11 +2872,11 @@ function enter_capital() { if (is_pretender_province(where) && is_enemy_province(where)) { game.count = get_province_governor(where) / 6 | 0 game.where = where + log_h3("Occupied %" + where + ".") if (is_seat_of_power(where)) { game.state = "occupy_seat_of_power_1" return } else { - log_br() game.state = "occupy_breakaway" return } @@ -2903,9 +2905,9 @@ states.occupy_seat_of_power_1 = { }, region(where) { push_undo() - log("Remove Seat of Power in %" + where + ".") + log("Removed seat of power.") remove_seat_of_power(where) - remove_governor(where) + remove_governor(where, false) resume_occupy_seat_of_power() }, } @@ -2936,18 +2938,20 @@ states.occupy_breakaway = { }, region(where) { push_undo() - log("Removed breakaway in %" + where + ".") + log("Removed breakaway.") remove_breakaway(where) - remove_governor(where) + remove_governor(where, false) goto_replace_pretender() }, } function goto_replace_pretender() { - if (has_available_governor()) + if (has_available_governor()) { game.state = "replace_pretender_governor" - else + } else { + log("Removed governor.") end_occupation_of_pretender_capital() + } } states.replace_pretender_governor = { @@ -2965,13 +2969,14 @@ states.replace_pretender_governor = { }, governor(id) { push_undo() - log("Placed governor in %" + game.where + ".") + log("Replaced governor.") set_governor_location(id, game.where) update_neutral_italia() end_occupation_of_pretender_capital() }, pass() { push_undo() + log("Removed governor.") end_occupation_of_pretender_capital() }, } @@ -3013,13 +3018,13 @@ states.castra = { } }, militia(where) { - log("Castra on militia in %" + where + ".") + log("Castra in %" + where + ".") add_militia_castra(where) resume_take_actions() }, general(id) { let where = get_general_location(id) - log("Castra on army in %" + where + ".") + log("Castra in %" + where + ".") add_general_castra(id) resume_take_actions() }, @@ -3247,7 +3252,7 @@ states.mob = { function auto_remove_pretender_empire(seat) { let pretender = get_province_governor(seat) / 6 | 0 - log("Remove Seat of Power in %" + seat + ".") + log("Removed seat of power in %" + seat + ".") remove_seat_of_power(seat) for (let where = 1; where < 12; ++where) { if (is_breakaway(where) && (get_province_governor(where) / 6 | 0) === pretender) { @@ -3269,6 +3274,7 @@ function can_play_pretender() { } function play_pretender() { + log_h3("Pretender.") game.state = "pretender_seat_of_power" } @@ -3327,10 +3333,15 @@ states.pretender_breakaway = { add_breakaway(where) remove_quaestor(where) // no effect anymore if (game.count === 0) - resume_take_actions() + end_pretender() }, } +function end_pretender() { + log_br() + resume_take_actions() +} + // CARD: Princeps Senatus @@ -3585,7 +3596,7 @@ states.mobile_vulgus = { }, support() { push_undo() - log("Reduce support level in %" + game.where + ".") + log("Reduced support level.") let n = get_support(game.where) + count_units_in_capital(game.where) spend_populace(n) reduce_support(game.where) @@ -3622,7 +3633,7 @@ states.demagogue_confirm = { }, confirm() { clear_undo() - log_h3("Demagogue") + log_h3("Demagogue.") game.demagogue = new Array(get_player_count()).fill(-1) game.count = game.current game.state = "demagogue" @@ -3668,7 +3679,7 @@ function goto_demagogue_reveal() { for (let p = 0; p < get_player_count(); ++p) { if (p !== game.current) { let c = game.demagogue[p] - logi(PLAYER_NAME[p] + " " + card_name(c)) + log(PLAYER_NAME[p] + " revealed " + card_name(c) + ".") if (card_value(c) === 1) mobs = true else @@ -3696,7 +3707,7 @@ states.demagogue_mobs = { region(where) { push_undo() let p = get_province_player(where) - logi("Mob in %" + where) + log("Placed mob in %" + where + ".") set_mobs(where, get_mobs(where) + 1) game.demagogue[p] = -1 for (let p = 0; p < game.demagogue.length; ++p) @@ -3760,10 +3771,8 @@ function can_militia_battle_with_army(where, attacker, is_force_march) { function goto_battle(type, where, attacker, target, is_force_march) { log_h2("Battle in %" + where) - if (game.active_event === EVENT_GOOD_AUGURIES || game.active_event === EVENT_BAD_AUGURIES) { + if (game.active_event === EVENT_GOOD_AUGURIES || game.active_event === EVENT_BAD_AUGURIES) log("E" + game.active_event + ".") - log_br() - } spend_military(1) game.where = where @@ -3926,7 +3935,7 @@ function roll_combat_dice() { function roll_flanking_maneuver_dice() { log_h3("FLANKING MANEUVER") game.combat.dhits = roll_attacker_dice() - log("Total " + game.combat.dhits + " hits!") + log("Total hits: " + game.combat.dhits) log_br() } @@ -4404,20 +4413,23 @@ function goto_combat_victory() { goto_combat_victory_defender() } +function remove_legacy(p, reason, n) { + log(PLAYER_NAME[p] + " -" + n + " Legacy.") + game.legacy[p] -= n +} + function award_legacy(p, reason, n) { - if (n > 0) + if (n > 0) { log(PLAYER_NAME[p] + " +" + n + " Legacy for " + reason + ".") - if (n < 0) - log(PLAYER_NAME[p] + " " + n + " Legacy for " + reason + ".") - game.legacy[p] += n + game.legacy[p] += n + } } function award_legacy_summary(p, reason, n) { - if (n > 0) + if (n > 0) { logi("+" + n + " for " + reason) - if (n < 0) - logi(n + " for " + reason) - game.legacy[p] += n + game.legacy[p] += n + } } function award_combat_legacy(p, reason, n) { @@ -4677,7 +4689,7 @@ states.support_check = { region(where) { push_undo() game.count |= (1 << where) - log("Reduce support level in %" + where + ".") + log("Reduced support level in %" + where + ".") reduce_support(where) resume_support_check() }, @@ -4735,7 +4747,7 @@ states.support_check_mobs = { region(where) { push_undo() log("More mobs than support in %" + where + ".") - remove_governor(where) + remove_governor(where, true) goto_support_check_mobs() }, } @@ -4748,7 +4760,7 @@ function goto_expand_pretender_empire() { if (is_expand_pretender_province(where)) game.count |= (1 << where) if (game.count) { - log_h3("Expand Pretender Empire") + log_h3("Expand Pretender Empire:") game.state = "expand_pretender_empire" } else { goto_gain_legacy() @@ -4766,7 +4778,7 @@ states.expand_pretender_empire = { }, region(where) { push_undo() - logi("Breakaway %" + where) + logi("Breakaway in %" + where) game.count &= ~(1 << where) add_breakaway(where) remove_quaestor(where) // no effect anymore @@ -4778,7 +4790,7 @@ states.expand_pretender_empire = { // === GAIN LEGACY === function goto_gain_legacy() { - log_h3("Gain Legacy") + log_h3("Gain Legacy:") if (is_only_pretender_player()) award_legacy_summary(game.current, "Pretender", count_own_breakaway_provinces()) @@ -5189,14 +5201,14 @@ function goto_game_end() { game.crisis[3] = 0 game.crisis[4] = 0 - log_h3("Emperor Turns") + log_h3("Emperor Turns:") let cutoff = award_emperor_turns(10, 1000) cutoff = award_emperor_turns(6, cutoff) cutoff = award_emperor_turns(3, cutoff) award_emperor_turns(0, cutoff) - log_h3("Final Score") + log_h3("Final Score:") game.current = game.first do { logi(PLAYER_NAME[game.current] + " " + game.legacy[game.current]) |