Player12
An open source football management simulator
Loading...
Searching...
No Matches
season_history.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <cstdint>
12#include <map>
13#include <string>
14#include <tuple>
15#include <vector>
16
17#include "global/types.h"
18
19struct MatchReport;
20
47
54{
55 uint16_t season = 0;
59 uint16_t appearances = 0;
60 uint16_t starts = 0;
61 uint16_t minutes = 0;
62 uint16_t goals = 0;
63 uint16_t assists = 0;
64 uint16_t yellow_cards = 0;
65 uint16_t red_cards = 0;
66 float rating_total = 0.0f;
67 uint16_t rated_matches = 0;
68
70 float averageRating() const
71 {
72 return rated_matches == 0
73 ? 0.0f
74 : rating_total / static_cast<float>(rated_matches);
75 }
76};
77
79using PlayerSeasonKey = std::tuple<uint16_t, PlayerID, TeamID, MatchType>;
80using PlayerSeasonTable = std::map<PlayerSeasonKey, PlayerSeasonStats>;
81
82namespace SeasonStats
83{
91void accumulate(PlayerSeasonTable& table, const MatchReport& report);
92
94std::vector<PlayerSeasonStats> topScorers(const PlayerSeasonTable& table,
95 uint16_t season,
96 MatchType competition_type,
97 const std::vector<TeamID>& team_ids,
98 size_t limit);
99} // namespace SeasonStats
Definition season_history.h:83
std::vector< PlayerSeasonStats > topScorers(const PlayerSeasonTable &table, uint16_t season, MatchType competition_type, const std::vector< TeamID > &team_ids, size_t limit)
Definition season_history.cpp:108
void accumulate(PlayerSeasonTable &table, const MatchReport &report)
Adds the player lines of a competitive match to the season table.
Definition season_history.cpp:40
std::string_view table
Definition runtime_editor_validation.cpp:44
std::map< PlayerSeasonKey, PlayerSeasonStats > PlayerSeasonTable
Definition season_history.h:80
std::tuple< uint16_t, PlayerID, TeamID, MatchType > PlayerSeasonKey
Definition season_history.h:79
Structured summary of a played fixture, persisted per fixture.
Definition match_report.h:93
Competitive (league or cup) totals of a player for one team in one season. Friendlies are not counted...
Definition season_history.h:54
uint16_t appearances
Definition season_history.h:59
uint16_t yellow_cards
Definition season_history.h:64
uint16_t minutes
Definition season_history.h:61
float averageRating() const
Definition season_history.h:70
TeamID team_id
Definition season_history.h:57
PlayerID player_id
Definition season_history.h:56
uint16_t season
Definition season_history.h:55
float rating_total
Definition season_history.h:66
uint16_t red_cards
Definition season_history.h:65
uint16_t goals
Definition season_history.h:62
uint16_t rated_matches
Definition season_history.h:67
MatchType competition_type
Definition season_history.h:58
uint16_t starts
Definition season_history.h:60
uint16_t assists
Definition season_history.h:63
Final outcome of one competition in one season.
Definition season_history.h:31
LeagueID competition_id
Definition season_history.h:35
std::vector< TeamID > promoted
Definition season_history.h:42
TeamID champion_id
Definition season_history.h:40
MatchType competition_type
Definition season_history.h:34
PlayerID top_scorer_id
Definition season_history.h:44
uint16_t season
Definition season_history.h:32
uint16_t start_year
Definition season_history.h:33
std::string competition_name
Definition season_history.h:39
std::vector< TeamID > relegated
Definition season_history.h:43
uint16_t top_scorer_goals
Definition season_history.h:45
TeamID runner_up_id
Definition season_history.h:41
MatchType
Represents the type or category of a match.
Definition types.h:40
uint8_t LeagueID
Type alias for League identifiers.
Definition types.h:15
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21