diff --git a/ChangeLog b/ChangeLog index 61053e96..e81e2da5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ - added more meaning to autosave filenames (user, country etc.) - added W-L-D and cup round robin rank info to the next opponent view - added possibility to edit player names in the second player list + - corrected some supercup definition errors which resulted in + crashes + - foul probabilities in the live game are more sophisticated now 29/01/2009: v2.3.1 - added possibility for multiple tables in leagues (think diff --git a/po/de.po b/po/de.po index 0fe96638..2023e198 100644 --- a/po/de.po +++ b/po/de.po @@ -2993,7 +2993,7 @@ msgstr "Gehalt " #. 'Wager' is the amount of money the user placed on a bet. #: src/misc3_callbacks.c:162 msgid "Wager" -msgstr "Gehalt" +msgstr "Einsatz" #. How much the user wagers; how much he won or lost. #: src/treeview2.c:401 @@ -3001,7 +3001,7 @@ msgid "" "Wager/\n" "Win/Loss" msgstr "" -"Gehalt/\n" +"Einsatz/\n" "Gewinn/Verlust" #: src/treeview.c:1505 diff --git a/src/bygfoot.h b/src/bygfoot.h index 22bd0d6d..5f31a0ff 100644 --- a/src/bygfoot.h +++ b/src/bygfoot.h @@ -40,8 +40,8 @@ /** * Program version number and year (copyright). */ -#define VERS "2.3.1" -#define YEAR "2005 - 2008" +#define VERS "2.3.2" +#define YEAR "2005 - 2009" /** Home dir name */ //#define HOMEDIRNAME ".bygfoot-cvs" diff --git a/src/game.c b/src/game.c index 9717a273..1a7f24c9 100644 --- a/src/game.c +++ b/src/game.c @@ -648,6 +648,37 @@ game_player_injury(Player *pl) } } +/** Calculate the probability of a foul event occurring. */ +gfloat +game_get_foul_prob(const LiveGame *live_game, const LiveGameUnit *unit) +{ + gfloat prob; + gint i; + + /* Base probability (a linear function of match time). */ + prob = const_float("float_live_game_foul_base") + + const_float("float_live_game_foul_max_inc") * MIN(1, (gfloat)(unit->minute) / 90); + + /* Add possible boost influence of the team not in possession. */ + prob *= (1 + live_game->fix->teams[!unit->possession]->boost * + const_float("float_team_boost_foul_factor")); + + /* Reduce probability depending on the current cards of + the team not in possession, except if their boost is on. */ + if(live_game->fix->teams[!unit->possession]->boost != 1) + { + for(i = 0; i < 11; i++) + if(g_array_index(live_game->fix->teams[!unit->possession]->players, Player, i).card_status == + PLAYER_CARD_STATUS_YELLOW) + prob *= (1 - const_float("float_live_game_foul_prob_reduction_yellow")); + else if(g_array_index(live_game->fix->teams[!unit->possession]->players, Player, i).card_status == + PLAYER_CARD_STATUS_RED) + prob *= (1 - const_float("float_live_game_foul_prob_reduction_red")); + } + + return prob; +} + /** Return a factor influencing who's fouled whom depending on the states of the team boosts. @param boost1 Boost of the team in possession. diff --git a/src/game.h b/src/game.h index eed7869a..189b8eaa 100644 --- a/src/game.h +++ b/src/game.h @@ -122,4 +122,7 @@ game_get_default_penalty_shooter(const Team *tm); void game_boost_cost(void); +gfloat +game_get_foul_prob(const LiveGame *live_game, const LiveGameUnit *unit); + #endif diff --git a/src/live_game.c b/src/live_game.c index b8c5c89c..53522313 100644 --- a/src/live_game.c +++ b/src/live_game.c @@ -232,9 +232,6 @@ live_game_fill_new_unit(LiveGameUnit *new) (1 + (const_float("float_player_boost_injury_effect") * (tm0->boost != 0 || tm1->boost != 0))); - foul_event_prob = const_float("float_live_game_foul") * - (1 + (tm0->boost + tm1->boost) * const_float("float_team_boost_foul_factor")); - new->possession = old->possession; if(old->event.type == LIVE_GAME_EVENT_GENERAL) @@ -244,6 +241,8 @@ live_game_fill_new_unit(LiveGameUnit *new) scoring_chance = const_float("float_live_game_scoring_chance") * live_game_pit_teams(new, const_float("float_live_game_scoring_chance_team_exponent")); + foul_event_prob = game_get_foul_prob(match, new); + if(rndom < foul_event_prob) new->event.type = LIVE_GAME_EVENT_FOUL; else if(rndom < foul_event_prob + @@ -360,6 +359,7 @@ live_game_event_foul(void) #endif gfloat rndom = math_rnd(0, 1); + gfloat reduction_factor = 1; gint type, fouled_player, foul_player, foul_team; if((debug > 100 && stat2 != -1) || @@ -393,16 +393,22 @@ live_game_event_foul(void) last_unit.area, 0, -1, FALSE); } - if(rndom < const_float("float_live_game_foul_red_injury")) + /* Probability of hard foul gets reduced if the player is already booked, except when boost is on. */ + if(tms[foul_team]->boost != 1 && + player_of_id_team(tms[foul_team], foul_player)->card_status == PLAYER_CARD_STATUS_YELLOW) + reduction_factor = 1 - const_float("float_live_game_foul_booked_reduction"); + + if(rndom < const_float("float_live_game_foul_red_injury") * reduction_factor) type = LIVE_GAME_EVENT_FOUL_RED_INJURY; - else if(rndom < const_float("float_live_game_foul_red")) + else if(rndom < const_float("float_live_game_foul_red") * reduction_factor) type = LIVE_GAME_EVENT_FOUL_RED; - else if(rndom < const_float("float_live_game_foul_yellow")) + else if(rndom < const_float("float_live_game_foul_yellow") * reduction_factor) { type = LIVE_GAME_EVENT_FOUL_YELLOW; player_card_set(player_of_id_team(tms[foul_team], foul_player), match->fix->clid, PLAYER_VALUE_CARD_YELLOW, 1, TRUE); player_of_id_team(tms[foul_team], foul_player)->career[PLAYER_VALUE_CARD_YELLOW]++; + player_of_id_team(tms[foul_team], foul_player)->card_status = PLAYER_CARD_STATUS_YELLOW; } else type = LIVE_GAME_EVENT_FOUL; @@ -420,6 +426,7 @@ live_game_event_foul(void) query_live_game_second_yellow(foul_team, foul_player)); if(type == LIVE_GAME_EVENT_FOUL_RED_INJURY) live_game_event_injury(!foul_team, fouled_player, TRUE); + player_of_id_team(tms[foul_team], foul_player)->card_status = PLAYER_CARD_STATUS_RED; } if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK && foul_team != diff --git a/src/player.c b/src/player.c index 4b812654..7b57a9ee 100644 --- a/src/player.c +++ b/src/player.c @@ -94,6 +94,7 @@ player_new(Team *tm, gfloat average_talent, gboolean new_id) const_float("float_player_lsu_upper")); new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard)); new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals)); + new.card_status = PLAYER_CARD_STATUS_NONE; for(i=0;iclid, PLAYER_VALUE_CARD_RED, 1, FALSE); } + pl->card_status = PLAYER_CARD_STATUS_NONE; + if(pl->cpos == PLAYER_POS_GOALIE && ((fix->result[0][0] == 0 && fix->teams[1] == pl->team) || (fix->result[1][0] == 0 && fix->teams[0] == pl->team))) diff --git a/src/player_struct.h b/src/player_struct.h index c6fc2908..913e1873 100644 --- a/src/player_struct.h +++ b/src/player_struct.h @@ -109,6 +109,14 @@ enum PlayerValue PLAYER_VALUE_END }; +/** Enumeration for the yellow/red + card status during the live game. */ +enum PlayerCardStatus +{ + PLAYER_CARD_STATUS_NONE = 0, + PLAYER_CARD_STATUS_YELLOW, + PLAYER_CARD_STATUS_RED +}; /** Representation of a player. @@ -127,7 +135,8 @@ typedef struct value, /**< Value of the player. */ wage, /**< Wage of the player. */ offers, /**< Number of times the player received a contract offer. */ - streak; /**< The streak the player is on. */ + streak, /**< The streak the player is on. */ + card_status; /**< The card status of the player during a live game. */ gfloat skill, /**< Skill. Between 0 and a constant (specified in the constants file). */ diff --git a/support_files/bygfoot_constants b/support_files/bygfoot_constants index a2cb571f..e6dd4596 100644 --- a/support_files/bygfoot_constants +++ b/support_files/bygfoot_constants @@ -517,13 +517,23 @@ float_live_game_stadium_event_riots 30000 float_live_game_stadium_event_fire 10000 # foul probabilities. -float_live_game_foul 11000 +float_live_game_foul_base 7000 +float_live_game_foul_max_inc 8000 + +# if a team already got booked it fouls less often +float_live_game_foul_prob_reduction_yellow 10000 +float_live_game_foul_prob_reduction_red 20000 + +# a player who's already booked fouls more carefully +float_live_game_foul_booked_reduction 50000 + +# probabilities for special foul consequences float_live_game_foul_red_injury 1500 float_live_game_foul_red 3800 float_live_game_foul_yellow 28000 # ban duration probabilities -# should add up to 1000 +# should add up to 100000 float_live_game_ban_1 70000 float_live_game_ban_2 15000 float_live_game_ban_3 10000