Skip to content

Commit

Permalink
Switch to Anarchy when the current government is lost
Browse files Browse the repository at this point in the history
When the technology for the current government is lost, the game used to pick
some government at random. Be more punitive and always switch to Anarchy. This
is more consistent with other government changes.

Closes #2047.
  • Loading branch information
lmoureaux authored and jwrober committed Dec 29, 2023
1 parent 4298d9d commit 902906a
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions server/techtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,24 +787,6 @@ pick_random_tech_to_lose(const struct research *presearch)
return A_NONE;
}

/**
Helper for research_tech_lost().
*/
static inline struct government *
pick_random_government(struct player *pplayer)
{
struct government *picked = nullptr;
int gov_nb = 0;

for (auto &pgov : governments) {
if (can_change_to_government(pplayer, &pgov) && 0 == fc_rand(++gov_nb)) {
picked = &pgov;
}
};
fc_assert(nullptr != picked);
return picked;
}

/**
Remove one tech from the research.
*/
Expand Down Expand Up @@ -850,30 +832,26 @@ static void research_tech_lost(struct research *presearch, Tech_type_id tech)
{
// Check government.
if (!can_change_to_government(pplayer, government_of_player(pplayer))) {
/* Lost the technology for the government; switch to random
* available government. */
struct government *pgov = pick_random_government(pplayer);
// Lost the technology for the government; switch to Anarchy.
struct government *pgov = game.government_during_revolution;

notify_player(
pplayer, nullptr, E_NEW_GOVERNMENT, ftc_server,
_("The required technology for our government '%s' "
"was lost. The citizens have started a "
"revolution into '%s'."),
"was lost. The country has fallen in %s."),
government_name_translation(government_of_player(pplayer)),
government_name_translation(pgov));
handle_player_change_government(pplayer, government_number(pgov));
send_player_info_c(pplayer, nullptr);
} else if (nullptr != pplayer->target_government
&& !can_change_to_government(pplayer,
pplayer->target_government)) {
/* Lost the technology for the target government; use a random
* available government as new target government. */
struct government *pgov = pick_random_government(pplayer);
// Lost the technology for the target government; switch to Anarchy.
struct government *pgov = game.government_during_revolution;

notify_player(pplayer, nullptr, E_NEW_GOVERNMENT, ftc_server,
_("The required technology for our new government "
"'%s' was lost. The citizens chose '%s' as new "
"target government."),
"'%s' was lost. The country has fallen in %s."),
government_name_translation(pplayer->target_government),
government_name_translation(pgov));
pplayer->target_government = pgov;
Expand Down

0 comments on commit 902906a

Please sign in to comment.