Refactor team_get_average_talents()

This commit is contained in:
Tom Stellard 2021-03-16 20:51:54 -07:00 committed by Tom Stellard
parent 5373da9c30
commit 9d144835ed
1 changed files with 6 additions and 4 deletions

View File

@ -1030,13 +1030,15 @@ team_get_average_talents(const GArray *teams)
if(teams->len == 0)
return 0;
for(i=0;i<teams->len;i++)
for(j=0;j<g_array_index(teams, Team, i).players->len;j++)
for(i=0;i<teams->len;i++) {
const Team *team = &g_array_index(teams, Team, i);
for(j=0;j<team->players->len;j++)
{
sum += g_array_index(g_array_index(teams, Team, i).players,
Player, j).talent;
const Player *player = &g_array_index(team->players, Player, j);
sum += player->talent;
cnt++;
}
}
return sum / (gfloat)cnt;
}