|
Player12
An open source football management simulator
|
Owns the result pipeline of all competitions. More...
#include <competition_manager.h>
Classes | |
| struct | LineupSwap |
Public Member Functions | |
| CompetitionManager (std::shared_ptr< GameData > gamedata, std::shared_ptr< DatabaseConnection > db_conn) | |
| void | load (Calendar &calendar, uint16_t season) |
| void | save () const |
| void | onSaved () |
| void | recordResult (const Match &match, MatchReport report) |
| void | afterMatchday (Calendar &calendar, const GameDateValue &today) |
| void | startContinentalSeason (const GameDateValue &today) |
| const ContinentalCompetitions & | getContinental () const |
| ContinentalCompetitions & | getContinental () |
| void | closeSeason (const Calendar &calendar, uint16_t season, uint16_t start_year) |
| Records the season history and applies promotion/relegation. | |
| std::vector< LineupSwap > | benchSuspendedPlayers (const Match &match) |
| void | restoreLineups (const std::vector< LineupSwap > &swaps) |
| void | setCurrentSeason (uint16_t season) |
| std::optional< MatchRules::Knockout > | knockoutRules (const Calendar &calendar, const Match &match) const |
| std::vector< StandingRow > | getStandings (const Calendar &calendar, LeagueID league_id) const |
| std::vector< LeagueID > | getCupIds () const |
| std::optional< Competitions::CupStatus > | getCupStatus (const Calendar &calendar, LeagueID cup_id) const |
| std::optional< MatchReport > | getMatchReport (const GameDateValue &date, TeamID home_id, TeamID away_id) const |
| const std::vector< SeasonHistoryEntry > & | getSeasonHistory () const |
| std::vector< PlayerSeasonStats > | getTopScorers (MatchType competition_type, LeagueID competition_id, size_t limit) const |
| std::vector< PlayerSeasonStats > | getPlayerSeasonStats (PlayerID player_id) const |
| std::vector< PlayerSeasonStats > | getPlayerCareer (PlayerID player_id) const |
| const Discipline & | getDiscipline () const |
Private Types | |
| using | FixtureKey = std::tuple< GameDateValue, TeamID, TeamID > |
Private Member Functions | |
| void | refreshLeaguePoints (const Calendar &calendar, LeagueID league_id) |
| std::vector< TeamID > | competitionTeams (MatchType competition_type, LeagueID competition_id) const |
Private Attributes | |
| std::shared_ptr< GameData > | gamedata |
| std::shared_ptr< DatabaseConnection > | db_conn |
| uint16_t | current_season = 1 |
| std::map< FixtureKey, MatchReport > | pending_reports |
| PlayerSeasonTable | player_stats |
| std::set< LeagueID > | dirty_leagues |
| std::vector< SeasonHistoryEntry > | season_history |
| Discipline | discipline |
| ContinentalCompetitions | continental |
| std::vector< FixtureKey > | pending_deciders |
| bool | history_dirty = false |
Owns the result pipeline of all competitions.
Stores the structured report of every played fixture, aggregates player season statistics, keeps league points in sync with the fixture-derived tables, draws cup rounds and closes seasons (history, promotion and relegation). Game forwards its lifecycle events here.
|
private |
| CompetitionManager::CompetitionManager | ( | std::shared_ptr< GameData > | gamedata, |
| std::shared_ptr< DatabaseConnection > | db_conn | ||
| ) |
| void CompetitionManager::afterMatchday | ( | Calendar & | calendar, |
| const GameDateValue & | today | ||
| ) |
Refreshes league points, draws cup rounds that became due and runs the continental competitions (draws, knockout rounds, and a decider recorded level from a score alone settled by extra time).
| std::vector< CompetitionManager::LineupSwap > CompetitionManager::benchSuspendedPlayers | ( | const Match & | match | ) |
Temporarily replaces suspended starters of both teams with eligible reserves for a simulated match; undo with restoreLineups().
| void CompetitionManager::closeSeason | ( | const Calendar & | calendar, |
| uint16_t | season, | ||
| uint16_t | start_year | ||
| ) |
|
private |
|
inline |
|
inline |
Continental club competitions (seasons, tables, coefficients).
| std::vector< LeagueID > CompetitionManager::getCupIds | ( | ) | const |
One domestic cup per country, identified by its root league ID.
| std::optional< Competitions::CupStatus > CompetitionManager::getCupStatus | ( | const Calendar & | calendar, |
| LeagueID | cup_id | ||
| ) | const |
|
inline |
| std::optional< MatchReport > CompetitionManager::getMatchReport | ( | const GameDateValue & | date, |
| TeamID | home_id, | ||
| TeamID | away_id | ||
| ) | const |
| std::vector< PlayerSeasonStats > CompetitionManager::getPlayerCareer | ( | PlayerID | player_id | ) | const |
Every stored season row of a player, oldest first.
| std::vector< PlayerSeasonStats > CompetitionManager::getPlayerSeasonStats | ( | PlayerID | player_id | ) | const |
Current-season rows of a player (one per team and competition).
|
inline |
| std::vector< StandingRow > CompetitionManager::getStandings | ( | const Calendar & | calendar, |
| LeagueID | league_id | ||
| ) | const |
| std::vector< PlayerSeasonStats > CompetitionManager::getTopScorers | ( | MatchType | competition_type, |
| LeagueID | competition_id, | ||
| size_t | limit | ||
| ) | const |
League (or cup, with MatchType::CUP and a root league ID) scorers.
| std::optional< MatchRules::Knockout > CompetitionManager::knockoutRules | ( | const Calendar & | calendar, |
| const Match & | match | ||
| ) | const |
How a level score settles match, for the engine that plays it: a cup tie and a continental final go to extra time and penalties, a second leg too when level on aggregate (goals of the first leg included). nullopt for matches that may end drawn.
| void CompetitionManager::load | ( | Calendar & | calendar, |
| uint16_t | season | ||
| ) |
Migrates older saves and restores the state of the loaded season.
| void CompetitionManager::onSaved | ( | ) |
Drops buffers that are now persisted (call after a commit).
| void CompetitionManager::recordResult | ( | const Match & | match, |
| MatchReport | report | ||
| ) |
Stores the report of a played match and aggregates its statistics.
|
private |
| void CompetitionManager::restoreLineups | ( | const std::vector< LineupSwap > & | swaps | ) |
| void CompetitionManager::save | ( | ) | const |
Persists pending reports, stats, history and memberships. Must run inside the caller's transaction.
|
inline |
Sets the season number used for new reports and statistics.
| void CompetitionManager::startContinentalSeason | ( | const GameDateValue & | today | ) |
Enters the continental clubs of the season containing today (after the calendar has been generated); no-op when already done or too late.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Continental second legs and finals recorded since the last matchday processing (extra time when the aggregate is level).
|
private |
|
private |
|
private |