mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-02-21 22:07:39 +01:00
Live game development.
This commit is contained in:
parent
82f82acec6
commit
83898c68f1
13
src/game.c
13
src/game.c
@ -666,3 +666,16 @@ game_substitute_player_send_off(Team *tm, gint player_number,
|
||||
treeview_show_user_player_list(&usr(current_user), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/** Decrease the players' fitness during a live game.
|
||||
@param fix The match being played. */
|
||||
void
|
||||
game_decrease_fitness(const Fixture *fix)
|
||||
{
|
||||
gint i, j;
|
||||
|
||||
for(i=0;i<2;i++)
|
||||
for(j=0;j<11;j++)
|
||||
if(player_of(fix->teams[i], j)->cskill > 0)
|
||||
player_decrease_fitness(player_of(fix->teams[i], j));
|
||||
}
|
||||
|
@ -87,5 +87,7 @@ game_player_card(gint clid, Player *pl, gboolean red, gboolean second_yellow);
|
||||
void
|
||||
game_substitute_player_send_off(Team *tm, gint player_number,
|
||||
gint *to_substitute, gint *substitute);
|
||||
void
|
||||
game_decrease_fitness(const Fixture *fix);
|
||||
|
||||
#endif
|
||||
|
@ -226,13 +226,13 @@ live_game_evaluate_unit(LiveGameUnit *unit)
|
||||
else if(type == LIVE_GAME_EVENT_GENERAL)
|
||||
live_game_event_general(FALSE);
|
||||
else if(type == LIVE_GAME_EVENT_START_MATCH)
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
else if(type == LIVE_GAME_EVENT_HALF_TIME ||
|
||||
type == LIVE_GAME_EVENT_EXTRA_TIME ||
|
||||
type == LIVE_GAME_EVENT_PENALTIES ||
|
||||
type == LIVE_GAME_EVENT_END_MATCH)
|
||||
{
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
if(type != LIVE_GAME_EVENT_END_MATCH && show &&
|
||||
option_int("int_opt_user_pause_break", usr(fixture_user_team_involved(match->fix)).options))
|
||||
misc_callback_pause_live_game();
|
||||
@ -292,7 +292,7 @@ live_game_event_foul(void)
|
||||
|
||||
last_unit.event.type = type;
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
if(type == LIVE_GAME_EVENT_FOUL_RED ||
|
||||
type == LIVE_GAME_EVENT_FOUL_RED_INJURY ||
|
||||
@ -344,7 +344,7 @@ live_game_event_lost_possession(void)
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER],
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
live_game_event_general(TRUE);
|
||||
}
|
||||
@ -382,7 +382,7 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
|
||||
if(math_rnd(0, 1) < const_float("float_live_game_injury_is_temp"))
|
||||
last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY;
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
if(last_unit.event.type == LIVE_GAME_EVENT_INJURY)
|
||||
{
|
||||
@ -437,7 +437,7 @@ live_game_event_stadium(void)
|
||||
else if(rndom < const_float("float_live_game_stadium_event_breakdown"))
|
||||
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_BREAKDOWN;
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
live_game_event_general(TRUE);
|
||||
}
|
||||
@ -494,7 +494,7 @@ live_game_event_scoring_chance(void)
|
||||
}
|
||||
}
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
live_game_event_duel();
|
||||
}
|
||||
@ -559,7 +559,7 @@ live_game_event_penalty(void)
|
||||
game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE);
|
||||
}
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
live_game_event_duel();
|
||||
}
|
||||
@ -644,7 +644,7 @@ live_game_event_general(gboolean create_new)
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER],
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
}
|
||||
|
||||
/** Fill in the players values in a general unit. */
|
||||
@ -713,7 +713,7 @@ live_game_event_free_kick(void)
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
live_game_event_duel();
|
||||
}
|
||||
@ -739,7 +739,7 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
game_player_card(match->fix->clid, player_of_id(tm[team], player), TRUE, second_yellow);
|
||||
|
||||
@ -805,7 +805,7 @@ live_game_event_substitution(gint team_number, gint sub_in, gint sub_out)
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
}
|
||||
|
||||
/** Show a team change event, e.g. structure change.
|
||||
@ -827,7 +827,7 @@ live_game_event_team_change(gint team_number, gint event_type)
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
}
|
||||
|
||||
/** Calculate whether a player who tries to score succeeds. */
|
||||
@ -898,7 +898,7 @@ live_game_event_duel(void)
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
live_game_finish_unit();
|
||||
|
||||
if(last_unit.time != LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
live_game_event_general(TRUE);
|
||||
@ -1279,9 +1279,6 @@ live_game_generate_commentary(LiveGameUnit *unit)
|
||||
g_string_printf(commentary, "%s changes anti-boost to ON.",
|
||||
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
|
||||
}
|
||||
|
||||
if(show)
|
||||
game_gui_live_game_show_unit(unit);
|
||||
}
|
||||
|
||||
/** Assemble some stats like ball possession or shots
|
||||
@ -1408,6 +1405,26 @@ live_game_pit_teams(const LiveGameUnit *unit, gfloat exponent)
|
||||
return factor;
|
||||
}
|
||||
|
||||
/** Some polishing of the latest unit. Write commentary etc. */
|
||||
void
|
||||
live_game_finish_unit(void)
|
||||
{
|
||||
LiveGameUnit *unit = &last_unit;
|
||||
|
||||
live_game_generate_commentary(unit);
|
||||
|
||||
if(unit->minute != -1 && unit->time != LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
{
|
||||
game_decrease_fitness(match->fix);
|
||||
if(stat2 == current_user &&
|
||||
unit->minute % const_int("int_live_game_player_list_refresh") == 0)
|
||||
treeview_show_user_player_list(&usr(current_user), 1);
|
||||
}
|
||||
|
||||
if(show)
|
||||
game_gui_live_game_show_unit(unit);
|
||||
}
|
||||
|
||||
/** Find a random player (influenced by fitness) who gets
|
||||
injured. */
|
||||
void
|
||||
|
@ -100,4 +100,7 @@ live_game_event_substitution(gint team_number, gint sub_in, gint sub_out);
|
||||
void
|
||||
live_game_event_team_change(gint team_number, gint event_type);
|
||||
|
||||
void
|
||||
live_game_finish_unit(void);
|
||||
|
||||
#endif
|
||||
|
33
src/player.c
33
src/player.c
@ -623,3 +623,36 @@ player_get_game_skill(const Player *pl, gboolean skill)
|
||||
return (gfloat)pl->cskill * powf((gfloat)pl->fitness / 10000,
|
||||
const_float("float_player_fitness_impact_on_skill"));
|
||||
}
|
||||
|
||||
/** Decrease a player's fitness during a match.
|
||||
@param pl The player. */
|
||||
void
|
||||
player_decrease_fitness(Player *pl)
|
||||
{
|
||||
gint i;
|
||||
gint age_limits[7] =
|
||||
{const_int("int_player_fitness_decrease_peak_age_diff1"),
|
||||
const_int("int_player_fitness_decrease_peak_age_diff2"),
|
||||
const_int("int_player_fitness_decrease_peak_age_diff3"),
|
||||
const_int("int_player_fitness_decrease_peak_age_diff4"),
|
||||
const_int("int_player_fitness_decrease_peak_age_diff5"),
|
||||
const_int("int_player_fitness_decrease_peak_age_diff6"),
|
||||
const_int("int_player_fitness_decrease_peak_age_diff7")};
|
||||
gint reduce[8] =
|
||||
{const_int("int_player_fitness_decrease_minus1"),
|
||||
const_int("int_player_fitness_decrease_minus2"),
|
||||
const_int("int_player_fitness_decrease_minus3"),
|
||||
const_int("int_player_fitness_decrease_minus4"),
|
||||
const_int("int_player_fitness_decrease_minus5"),
|
||||
const_int("int_player_fitness_decrease_minus6"),
|
||||
const_int("int_player_fitness_decrease_minus7"),
|
||||
const_int("int_player_fitness_decrease_minus_else")};
|
||||
|
||||
gint diff = pl->peak_age - pl->age;
|
||||
|
||||
for(i=0;i<7;i++)
|
||||
if(diff > age_limits[i])
|
||||
break;
|
||||
|
||||
pl->fitness = MAX(0, pl->fitness - reduce[i]);
|
||||
}
|
||||
|
@ -84,4 +84,7 @@ player_id_index(const Team *tm, gint player_id);
|
||||
gfloat
|
||||
player_get_game_skill(const Player *pl, gboolean skill);
|
||||
|
||||
void
|
||||
player_decrease_fitness(Player *pl);
|
||||
|
||||
#endif
|
||||
|
@ -185,7 +185,7 @@ float_live_game_stadium_event_breakdown 1000
|
||||
# foul probabilities.
|
||||
float_live_game_foul 110
|
||||
float_live_game_foul_red_injury 50
|
||||
float_live_game_foul_red 800
|
||||
float_live_game_foul_red 80
|
||||
float_live_game_foul_yellow 230
|
||||
|
||||
gfloat duration[6]={0,0.7,0.85,0.95,0.975,1};
|
||||
@ -246,6 +246,10 @@ int_player_injury_duration_dev_shoulder 5
|
||||
int_player_injury_duration_ligament 22
|
||||
int_player_injury_duration_dev_ligament 8
|
||||
|
||||
# refresh rate of the player list during a live game
|
||||
# the smaller the more often the list gets refreshed
|
||||
int_live_game_player_list_refresh 5
|
||||
|
||||
# probability that a scoring chance is an own goal.
|
||||
float_live_game_scoring_chance_is_own_goal 10
|
||||
|
||||
@ -288,6 +292,24 @@ float_player_fitness_impact_on_skill 250
|
||||
# the higher the worse. @see game_get_player_contribution()
|
||||
float_player_fitness_exponent 250
|
||||
|
||||
# these determine the players' fitness decrease during
|
||||
# a match
|
||||
int_player_fitness_decrease_peak_age_diff1 500
|
||||
int_player_fitness_decrease_minus1 8
|
||||
int_player_fitness_decrease_peak_age_diff2 250
|
||||
int_player_fitness_decrease_minus2 7
|
||||
int_player_fitness_decrease_peak_age_diff3 150
|
||||
int_player_fitness_decrease_minus3 6
|
||||
int_player_fitness_decrease_peak_age_diff4 100
|
||||
int_player_fitness_decrease_minus4 5
|
||||
int_player_fitness_decrease_peak_age_diff5 -100
|
||||
int_player_fitness_decrease_minus5 5
|
||||
int_player_fitness_decrease_peak_age_diff6 -200
|
||||
int_player_fitness_decrease_minus6 7
|
||||
int_player_fitness_decrease_peak_age_diff7 -400
|
||||
int_player_fitness_decrease_minus7 10
|
||||
int_player_fitness_decrease_minus_else 15
|
||||
|
||||
# bounds for the home advantage factor
|
||||
float_game_home_advantage_lower 40
|
||||
float_game_home_advantage_upper 80
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
int_opt_user_confirm_unfit 1
|
||||
int_opt_user_show_live_game 1
|
||||
int_opt_user_live_game_speed -10
|
||||
int_opt_user_live_game_speed 0
|
||||
int_opt_user_show_tendency_bar 1
|
||||
int_opt_user_notify_transfer 0
|
||||
int_opt_user_notify_pos -1
|
||||
@ -29,7 +29,7 @@ int_opt_user_penalty_shooter -1
|
||||
int_opt_user_pause_injury 1
|
||||
int_opt_user_pause_red 1
|
||||
int_opt_user_pause_break 1
|
||||
int_opt_user_auto_sub 0
|
||||
int_opt_user_auto_sub 1
|
||||
int_opt_user_show_overall 0
|
||||
|
||||
# the order of these attributes is important
|
||||
|
Loading…
x
Reference in New Issue
Block a user