Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.18 diff -u -r1.18 player.c --- player.c 1999/03/05 23:58:19 1.18 +++ player.c 1999/03/14 20:49:02 @@ -131,13 +131,17 @@ 100, 60, 70, 80, 80, 100 }; +int government_civil_war[G_LAST] = { + 90, 80, 70, 50, 40, 30 +}; + char *government_names[G_LAST] = { "Anarchy", "Despotism", "Monarchy", "Communism", "Republic", "Democracy" }; char *ruler_titles[G_LAST] = { - "Mr.", "Emperor", "King", /* even for Elizabeth */ + "Mr.", "Emperor", "King", /* even for Elizabeth */ "Comrade", "President", "President" }; @@ -194,6 +198,16 @@ int get_government_max_rate(enum government_type type) { return government_rates[type]; +} + +/*************************************************************** +Added for civil war probability computation - Kris Bubendorfer +***************************************************************/ +int get_government_civil_war_prob(enum government_type type) +{ + if(type >= G_ANARCHY && type < G_LAST) + return government_civil_war[type]; + return 0; } /*************************************************************** Index: common/player.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.h,v retrieving revision 1.19 diff -u -r1.19 player.h --- player.h 1999/02/24 09:21:42 1.19 +++ player.h 1999/03/14 20:49:02 @@ -150,6 +150,7 @@ int can_change_to_government(struct player *pplayer, enum government_type); int get_government_max_rate(enum government_type type); +int get_government_civil_war_prob(enum government_type type); char *get_government_name(enum government_type type); char *get_ruler_title(enum government_type type); char *get_race_name(enum race_type race); Index: data/helpdata.txt =================================================================== RCS file: /home/freeciv/CVS/freeciv/data/helpdata.txt,v retrieving revision 1.54 diff -u -r1.54 helpdata.txt --- helpdata.txt 1999/02/24 09:32:57 1.54 +++ helpdata.txt 1999/03/14 20:49:10 @@ -1845,9 +1845,17 @@ scientific advances. Players remain in the civil war state for just one turn, after -which the government enters a state of anarchy. The only real -way of avoiding Civil War is to defend your civilization's -capital at all costs. +which the empire enters a state of anarchy. + +The capture of your capital does not always lead to civil war. If +you have treated your people with kindness, you are more likely to +retain their loyalty. Each city that is celebrating reduces the +chance of civil war, while each revolting city increases the +likelihood. + +In addition, the form of government directly contributes to the +chance of civil war. Governments with universal franchise are +far less likely to revolt than those more despotic in nature. The number of cities an empire needs before it can erupt into civil war is by default 10. That is, empires with fewer than 10 Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.34 diff -u -r1.34 citytools.c --- citytools.c 1999/02/27 07:10:02 1.34 +++ citytools.c 1999/03/14 20:49:11 @@ -779,6 +779,56 @@ } /* + * civil_war_triggered: + * + * The capture of a capital is not a sure fire way to throw + * and empire into civil war. Some governments are more susceptible + * than others, here are the base probabilities: + * + * Anarchy 90% + * Despotism 80% + * Monarchy 70% + * Fundamentalism 60% (In case it gets implemented one day) + * Communism 50% + * Republic 40% + * Democracy 30% + * + * Note: In the event that Fundamentalism is added, you need to + * update the array government_civil_war[G_LAST] in player.c + * + * In addition each city in revolt adds 5%, each city in rapture + * subtracts 5% from the probability of a civil war. + * + * If you have at least 1 turns notice of the impending loss of + * your capital, you can hike luxuries up to the hightest value, + * and by this reduce the chance of a civil war. In fact by + * hiking the luxuries to 100% under Democracy, it is easy to + * get massively negative numbers - guaranteeing imunity from + * civil war. Likewise, 3 revolting cities under despotism + * guarantees a civil war. + * + * This routine calculates these probabilities and returns true + * if a civil war is triggered. + * - Kris Bubendorfer + */ + +int civil_war_triggered(struct player *pplayer) +{ + /* Get base probabilities */ + + int dice = myrand(100); /* Throw the dice */ + int prob = get_government_civil_war_prob(pplayer->government); + + /* Now compute the contribution of the cities. */ + + city_list_iterate(pplayer->cities, pcity) + prob += city_unhappy(pcity) * 5 - city_celebrating(pcity) * 5; + city_list_iterate_end; + + return(dice < prob); +} + +/* * Capturing a nation's capital is a devastating blow. This function * creates a new AI player, and randomly splits the original players * city list into two. Of course this results in a real mix up of Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.57 diff -u -r1.57 unithand.c --- unithand.c 1999/03/07 10:35:59 1.57 +++ unithand.c 1999/03/14 20:49:12 @@ -1028,7 +1028,8 @@ if(city_got_building(pcity, B_PALACE) && city_list_size(&cplayer->cities) >= game.civilwarsize && game.nplayers < R_LAST - && game.civilwarsize < GAME_MAX_CIVILWARSIZE) + && game.civilwarsize < GAME_MAX_CIVILWARSIZE + && civil_war_triggered(cplayer)) civil_war(cplayer); if (pcity->size<1) {