mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-28 06:29:18 +01:00
"Career values."
This commit is contained in:
parent
e770ef07ef
commit
0f12364c95
@ -263,8 +263,11 @@ game_initialize(Fixture *fix)
|
||||
if(j < 11)
|
||||
{
|
||||
if(g_array_index(fix->teams[i]->players, Player, j).cskill > 0)
|
||||
{
|
||||
player_games_goals_set(&g_array_index(fix->teams[i]->players, Player, j), fix->clid,
|
||||
PLAYER_VALUE_GAMES, 1, TRUE);
|
||||
PLAYER_VALUE_GAMES, 1);
|
||||
g_array_index(fix->teams[i]->players, Player, j).career[PLAYER_VALUE_GAMES]++;
|
||||
}
|
||||
|
||||
g_array_index(fix->teams[i]->players, Player, j).participation = TRUE;
|
||||
}
|
||||
|
@ -323,8 +323,11 @@ live_game_event_foul(void)
|
||||
live_game_event_injury(!foul_team, fouled_player, TRUE);
|
||||
}
|
||||
else if(type == LIVE_GAME_EVENT_FOUL_YELLOW)
|
||||
{
|
||||
player_card_set(player_of_id_team(tm[foul_team], foul_player),
|
||||
match->fix->clid, PLAYER_VALUE_CARD_YELLOW, 1, TRUE);
|
||||
player_of_id_team(tm[foul_team], foul_player)->career[PLAYER_VALUE_CARD_YELLOW]++;
|
||||
}
|
||||
|
||||
if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK && foul_team !=
|
||||
last_unit.possession)
|
||||
@ -794,6 +797,8 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
|
||||
else
|
||||
player_card_set(player_of_id_team(tm[team], player), match->fix->clid, PLAYER_VALUE_CARD_RED,
|
||||
game_player_get_ban_duration(), FALSE);
|
||||
|
||||
player_of_id_team(tm[team], player)->career[PLAYER_VALUE_CARD_RED]++;
|
||||
|
||||
if(team_is_user(tm[team]) != -1)
|
||||
{
|
||||
@ -863,7 +868,8 @@ live_game_event_substitution(gint team_number, gint sub_in, gint sub_out)
|
||||
if(player_of_id_team(tm[team_number], sub_in)->cskill > 0)
|
||||
{
|
||||
player_games_goals_set(player_of_id_team(tm[team_number], sub_in),
|
||||
match->fix->clid, PLAYER_VALUE_GAMES, 1, TRUE);
|
||||
match->fix->clid, PLAYER_VALUE_GAMES, 1);
|
||||
player_of_id_team(tm[team_number], sub_in)->career[PLAYER_VALUE_GAMES]++;
|
||||
player_of_id_team(tm[team_number], sub_in)->participation = TRUE;
|
||||
}
|
||||
|
||||
@ -941,7 +947,10 @@ live_game_event_duel(void)
|
||||
const_float("float_live_game_score_team_exponent"));
|
||||
|
||||
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
player_games_goals_set(attacker, match->fix->clid, PLAYER_VALUE_SHOTS, 1, TRUE);
|
||||
{
|
||||
player_games_goals_set(attacker, match->fix->clid, PLAYER_VALUE_SHOTS, 1);
|
||||
attacker->career[PLAYER_VALUE_SHOTS]++;
|
||||
}
|
||||
|
||||
if(rndom < scoring_prob)
|
||||
{
|
||||
@ -951,8 +960,10 @@ live_game_event_duel(void)
|
||||
|
||||
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
{
|
||||
player_games_goals_set(attacker, match->fix->clid, PLAYER_VALUE_GOALS, 1, TRUE);
|
||||
player_games_goals_set(goalie, match->fix->clid, PLAYER_VALUE_GOALS, 1, TRUE);
|
||||
player_games_goals_set(attacker, match->fix->clid, PLAYER_VALUE_GOALS, 1);
|
||||
player_games_goals_set(goalie, match->fix->clid, PLAYER_VALUE_GOALS, 1);
|
||||
attacker->career[PLAYER_VALUE_GOALS]++;
|
||||
goalie->career[PLAYER_VALUE_GOALS]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -961,7 +972,10 @@ live_game_event_duel(void)
|
||||
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES &&
|
||||
(new.event.type == LIVE_GAME_EVENT_SAVE ||
|
||||
new.event.type == LIVE_GAME_EVENT_GOAL))
|
||||
player_games_goals_set(goalie, match->fix->clid, PLAYER_VALUE_SHOTS, 1, TRUE);
|
||||
{
|
||||
player_games_goals_set(goalie, match->fix->clid, PLAYER_VALUE_SHOTS, 1);
|
||||
goalie->career[PLAYER_VALUE_SHOTS]++;
|
||||
}
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
|
13
src/player.c
13
src/player.c
@ -18,6 +18,7 @@
|
||||
Player
|
||||
player_new(Team *tm, gfloat average_skill, gboolean new_id)
|
||||
{
|
||||
gint i;
|
||||
gfloat skill_factor =
|
||||
math_rnd(1 - const_float("float_player_average_skill_variance"),
|
||||
1 + const_float("float_player_average_skill_variance"));
|
||||
@ -64,6 +65,9 @@ player_new(Team *tm, gfloat average_skill, gboolean new_id)
|
||||
new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
|
||||
new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals));
|
||||
|
||||
for(i=0;i<PLAYER_VALUE_END;i++)
|
||||
new.career[i] = 0;
|
||||
|
||||
new.team = tm;
|
||||
new.participation = FALSE;
|
||||
new.offers = 0;
|
||||
@ -783,7 +787,7 @@ player_games_goals_get(const Player *pl, gint clid, gint type)
|
||||
@param diff Whether we add the value to the old one or
|
||||
replace the old value by the new one. */
|
||||
void
|
||||
player_games_goals_set(Player *pl, gint clid, gint type, gint value, gboolean diff)
|
||||
player_games_goals_set(Player *pl, gint clid, gint type, gint value)
|
||||
{
|
||||
gint i, *games_goals_value = NULL;
|
||||
PlayerGamesGoals new;
|
||||
@ -798,10 +802,7 @@ player_games_goals_set(Player *pl, gint clid, gint type, gint value, gboolean di
|
||||
else if(type == PLAYER_VALUE_SHOTS)
|
||||
games_goals_value = &g_array_index(pl->games_goals, PlayerGamesGoals, i).shots;
|
||||
|
||||
if(diff)
|
||||
*games_goals_value += value;
|
||||
else
|
||||
*games_goals_value = value;
|
||||
*games_goals_value += value;
|
||||
|
||||
if(*games_goals_value < 0)
|
||||
{
|
||||
@ -817,7 +818,7 @@ player_games_goals_set(Player *pl, gint clid, gint type, gint value, gboolean di
|
||||
|
||||
g_array_append_val(pl->games_goals, new);
|
||||
|
||||
player_games_goals_set(pl, clid, type, value, diff);
|
||||
player_games_goals_set(pl, clid, type, value);
|
||||
}
|
||||
|
||||
/** Update skill and lsu of a user player.
|
||||
|
12
src/player.h
12
src/player.h
@ -13,16 +13,6 @@ enum PlayerCompareAttrib
|
||||
PLAYER_COMPARE_ATTRIBUTE_END
|
||||
};
|
||||
|
||||
enum PlayerValue
|
||||
{
|
||||
PLAYER_VALUE_CARD_YELLOW = 0,
|
||||
PLAYER_VALUE_CARD_RED,
|
||||
PLAYER_VALUE_GAMES,
|
||||
PLAYER_VALUE_GOALS,
|
||||
PLAYER_VALUE_SHOTS,
|
||||
PLAYER_VALUE_END
|
||||
};
|
||||
|
||||
Player
|
||||
player_new(Team *tm, gfloat average_skill, gboolean new_id);
|
||||
|
||||
@ -93,7 +83,7 @@ void
|
||||
player_card_set(Player *pl, gint clid, gint card_type, gint value, gboolean diff);
|
||||
|
||||
void
|
||||
player_games_goals_set(Player *pl, gint clid, gint type, gint value, gboolean diff);
|
||||
player_games_goals_set(Player *pl, gint clid, gint type, gint value);
|
||||
|
||||
gint
|
||||
player_games_goals_get(const Player *pl, gint clid, gint type);
|
||||
|
@ -64,6 +64,18 @@ enum PlayerInjury
|
||||
PLAYER_INJURY_END
|
||||
};
|
||||
|
||||
/** Enum for different player data. */
|
||||
enum PlayerValue
|
||||
{
|
||||
PLAYER_VALUE_GAMES = 0,
|
||||
PLAYER_VALUE_GOALS,
|
||||
PLAYER_VALUE_SHOTS,
|
||||
PLAYER_VALUE_CARD_YELLOW,
|
||||
PLAYER_VALUE_CARD_RED,
|
||||
PLAYER_VALUE_END
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Representation of a player.
|
||||
@see #PlayerAttributes
|
||||
@ -103,6 +115,9 @@ typedef struct
|
||||
@see PlayerCard*/
|
||||
GArray *cards;
|
||||
|
||||
/** Career goals, games etc. */
|
||||
gint career[PLAYER_VALUE_END];
|
||||
|
||||
/** Pointer to the player's team. */
|
||||
Team *team;
|
||||
} Player;
|
||||
@ -148,6 +163,7 @@ enum PlayerInfoAttributeValue
|
||||
PLAYER_INFO_ATTRIBUTE_GAMES_GOALS,
|
||||
PLAYER_INFO_ATTRIBUTE_YELLOW_CARDS,
|
||||
PLAYER_INFO_ATTRIBUTE_BANNED,
|
||||
PLAYER_INFO_ATTRIBUTE_CAREER,
|
||||
PLAYER_INFO_ATTRIBUTE_OFFERS,
|
||||
PLAYER_INFO_ATTRIBUTE_END
|
||||
};
|
||||
|
@ -1850,6 +1850,7 @@ treeview_create_player_info(const Player *pl)
|
||||
_("Games/Goals\n"),
|
||||
_("Yellow cards (limit)\n"),
|
||||
_("Banned\n"),
|
||||
_("Career values"),
|
||||
_("New contract\noffers")};
|
||||
|
||||
for(i=0;i<PLAYER_INFO_ATTRIBUTE_END;i++)
|
||||
|
@ -87,9 +87,6 @@ treeview_helper_get_pointer(GtkTreeView *treeview, gint column)
|
||||
void
|
||||
treeview_helper_clear(GtkTreeView *treeview)
|
||||
{
|
||||
/*d*/
|
||||
/* gtk_tree_store_clear(GTK_TREE_STORE(gtk_tree_view_get_model(treeview))); */
|
||||
|
||||
gint i;
|
||||
gint number_of_columns;
|
||||
GtkTreeView *list = (treeview == NULL) ?
|
||||
@ -698,6 +695,9 @@ treeview_helper_player_ext_info_to_cell(GtkTreeViewColumn *col,
|
||||
case PLAYER_INFO_ATTRIBUTE_BANNED:
|
||||
treeview_helper_player_info_banned_to_cell(renderer, pl->cards);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_CAREER:
|
||||
treeview_helper_player_info_career_to_cell(renderer, pl);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_OFFERS:
|
||||
if(pl->offers > 0)
|
||||
g_object_set(renderer, "text", _("Player doesn't negotiate anymore"), NULL);
|
||||
@ -707,6 +707,52 @@ treeview_helper_player_ext_info_to_cell(GtkTreeViewColumn *col,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
treeview_helper_player_info_career_to_cell(GtkCellRenderer *renderer, const Player *pl)
|
||||
{
|
||||
gint i;
|
||||
gfloat goals_game = 0,
|
||||
shot_perc = 0;
|
||||
gchar *titles[PLAYER_VALUE_END] =
|
||||
{_("Games"),
|
||||
_("Goals"),
|
||||
_("Shots"),
|
||||
_("Yellows"),
|
||||
_("Reds")};
|
||||
gchar buf[SMALL], buf2[SMALL], format[SMALL];
|
||||
|
||||
strcpy(buf, "");
|
||||
for(i=0;i<PLAYER_VALUE_END;i++)
|
||||
{
|
||||
sprintf(buf2, "%s %d ", titles[i], pl->career[i]);
|
||||
strcat(buf, buf2);
|
||||
}
|
||||
|
||||
if(pl->career[PLAYER_VALUE_GAMES] > 0)
|
||||
goals_game = (gfloat)pl->career[PLAYER_VALUE_GOALS] /
|
||||
(gfloat)pl->career[PLAYER_VALUE_GAMES];
|
||||
|
||||
if(pl->pos == PLAYER_POS_GOALIE)
|
||||
{
|
||||
strcpy(format, "\nGoals/Game %.1f Save %% %.1f");
|
||||
if(pl->career[PLAYER_VALUE_SHOTS] > 0)
|
||||
shot_perc = 100 - ((gfloat)pl->career[PLAYER_VALUE_GOALS] * 100 /
|
||||
(gfloat)pl->career[PLAYER_VALUE_SHOTS]);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(format, "\nGoals/Game %.1f Shot %% %.1f");
|
||||
if(pl->career[PLAYER_VALUE_SHOTS] > 0)
|
||||
shot_perc = (gfloat)pl->career[PLAYER_VALUE_GOALS] * 100 /
|
||||
(gfloat)pl->career[PLAYER_VALUE_SHOTS];
|
||||
}
|
||||
|
||||
sprintf(buf2, format, goals_game, shot_perc);
|
||||
strcat(buf, buf2);
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
treeview_helper_player_info_banned_to_cell(GtkCellRenderer *renderer, const GArray *cards)
|
||||
{
|
||||
|
@ -132,6 +132,9 @@ treeview_helper_player_info_yellow_to_cell(GtkCellRenderer *renderer, const GArr
|
||||
void
|
||||
treeview_helper_player_info_banned_to_cell(GtkCellRenderer *renderer, const GArray *cards);
|
||||
|
||||
void
|
||||
treeview_helper_player_info_career_to_cell(GtkCellRenderer *renderer, const Player *pl);
|
||||
|
||||
gchar*
|
||||
treeview_helper_get_user_history_icon(gint history_type);
|
||||
|
||||
|
@ -48,10 +48,11 @@ enum
|
||||
TAG_TEAM_PLAYER_CARD_CLID,
|
||||
TAG_TEAM_PLAYER_CARD_YELLOW,
|
||||
TAG_TEAM_PLAYER_CARD_RED,
|
||||
TAG_TEAM_PLAYER_CAREER,
|
||||
TAG_END
|
||||
};
|
||||
|
||||
gint state, etalidx;
|
||||
gint state, etalidx, careeridx;
|
||||
GArray *teams_array;
|
||||
Team new_team;
|
||||
Player new_player;
|
||||
@ -89,7 +90,7 @@ xml_loadsave_teams_start_element (GMarkupParseContext *context,
|
||||
else if(tag == TAG_TEAM_PLAYER)
|
||||
{
|
||||
new_player = player_new(&new_team, 80, FALSE);
|
||||
etalidx = 0;
|
||||
etalidx = careeridx = 0;
|
||||
}
|
||||
|
||||
if(!valid_tag)
|
||||
@ -150,11 +151,14 @@ xml_loadsave_teams_end_element (GMarkupParseContext *context,
|
||||
tag == TAG_TEAM_PLAYER_CONTRACT ||
|
||||
tag == TAG_TEAM_PLAYER_PARTICIPATION ||
|
||||
tag == TAG_TEAM_PLAYER_GAMES_GOAL ||
|
||||
tag == TAG_TEAM_PLAYER_CAREER ||
|
||||
tag == TAG_TEAM_PLAYER_CARD)
|
||||
{
|
||||
state = TAG_TEAM_PLAYER;
|
||||
if(tag == TAG_TEAM_PLAYER_ETAL)
|
||||
etalidx++;
|
||||
else if(tag == TAG_TEAM_PLAYER_CAREER)
|
||||
careeridx++;
|
||||
else if(tag == TAG_TEAM_PLAYER_CARD)
|
||||
g_array_append_val(new_player.cards, new_card);
|
||||
else if(tag == TAG_TEAM_PLAYER_GAMES_GOAL)
|
||||
@ -267,6 +271,8 @@ xml_loadsave_teams_text (GMarkupParseContext *context,
|
||||
new_card.yellow = int_value;
|
||||
else if(state == TAG_TEAM_PLAYER_CARD_RED)
|
||||
new_card.red = int_value;
|
||||
else if(state == TAG_TEAM_PLAYER_CAREER)
|
||||
new_player.career[careeridx] = int_value;
|
||||
}
|
||||
|
||||
void
|
||||
@ -389,6 +395,9 @@ xml_loadsave_teams_write_player(FILE *fil, const Player *pl)
|
||||
for(i=0;i<4;i++)
|
||||
xml_write_float(fil, pl->etal[i], TAG_TEAM_PLAYER_ETAL, I3);
|
||||
|
||||
for(i=0;i<PLAYER_VALUE_END;i++)
|
||||
xml_write_int(fil, pl->career[i], TAG_TEAM_PLAYER_CAREER, I2);
|
||||
|
||||
for(i=0;i<pl->games_goals->len;i++)
|
||||
{
|
||||
fprintf(fil, "%s<_%d>\n", I2, TAG_TEAM_PLAYER_GAMES_GOAL);
|
||||
@ -417,7 +426,7 @@ xml_loadsave_teams_write_player(FILE *fil, const Player *pl)
|
||||
TAG_TEAM_PLAYER_CARD_RED, I3);
|
||||
|
||||
fprintf(fil, "%s</_%d>\n", I2, TAG_TEAM_PLAYER_CARD);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fil, "%s</_%d>\n", I1, TAG_TEAM_PLAYER);
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
# Most of these options are uncommented because their meaning
|
||||
# is rather clear if you take a look at the options window in the game.
|
||||
|
||||
int_opt_user_show_live_game 1
|
||||
int_opt_user_show_live_game 0
|
||||
int_opt_user_live_game_speed 0
|
||||
int_opt_user_live_game_verbosity 3
|
||||
int_opt_user_live_game_verbosity 5
|
||||
int_opt_user_show_tendency_bar 1
|
||||
int_opt_user_pause_injury 1
|
||||
int_opt_user_pause_red 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user