|
Player12
An open source football management simulator
|
Seasons, draws, knockouts, prize money and coefficients of the continental club competitions. More...
#include <continental.h>
Classes | |
| struct | AssociationCoefficient |
| struct | DrawEvent |
| struct | Entrant |
| struct | Season |
| struct | Tie |
| struct | TieScore |
Public Types | |
| using | NewsSink = std::function< void(InboxMessage, const std::vector< TeamID > &, bool)> |
Public Member Functions | |
| ContinentalCompetitions (std::shared_ptr< GameData > gamedata) | |
| void | setNewsSink (NewsSink sink) |
| void | startSeason (uint16_t season_year, const GameDateValue &today) |
Enters the qualified clubs of season_year and plans the league-phase draw. Uses the qualification computed by closeSeason() or, without one (first season, older saves), the clubs' reputation. Nothing happens if the season already exists or if today is too late to play the league phase. | |
| void | afterMatchday (Calendar &calendar, const GameDateValue &today) |
| void | onResult (const Match &match) |
| bool | needsExtraTime (const Calendar &calendar, const Match &match) const |
| std::optional< int > | deciderLead (const Calendar &calendar, const Match &match) const |
| std::optional< std::pair< int, int > > | deciderAggregate (const Calendar &calendar, const Match &match) const |
| bool | resolveDecider (const Calendar &calendar, Match &match) |
| void | closeSeason (const Calendar &calendar, uint16_t season_year, const std::unordered_map< LeagueID, std::vector< StandingRow > > &tables, const std::map< LeagueID, TeamID > &cup_winners) |
| Season end: updates coefficients from the season's matches and computes the clubs qualified for the next season. | |
| void | refresh (const Calendar &calendar) |
| const std::vector< Season > & | getSeasons () const |
| const Season * | getSeason (LeagueID competition_id) const |
| const std::vector< StandingRow > & | getTable (LeagueID competition_id) const |
| TieScore | tieScore (const Calendar &calendar, const Season &season, const Tie &tie) const |
| std::vector< AssociationCoefficient > | associationRanking (Continental::Continent continent) const |
| double | clubCoefficient (TeamID team_id) const |
| std::optional< LeagueID > | competitionOf (TeamID team_id) const |
| const std::map< LeagueID, std::vector< Entrant > > & | getQualified () const |
| void | load (const DatabaseConnection &db) |
| void | save (const DatabaseConnection &db) const |
| std::string | serialize () const |
| void | deserialize (const std::string &data) |
Static Public Attributes | |
| static constexpr size_t | COEFFICIENT_SEASONS = 5 |
Private Member Functions | |
| Season * | findSeason (LeagueID competition_id) |
| std::vector< Entrant > | qualifyByReputation (const Continental::CompetitionRules &rules, std::vector< TeamID > &taken) const |
| std::vector< Entrant > | qualify (const Continental::CompetitionRules &rules, const std::unordered_map< LeagueID, std::vector< StandingRow > > &tables, const std::map< LeagueID, TeamID > &cup_winners, std::vector< TeamID > &taken) const |
| std::vector< LeagueID > | rankedAssociations (Continental::Continent continent) const |
| AssociationCoefficient | associationCoefficient (LeagueID association) const |
| std::vector< TeamID > | topDivisionClubs (LeagueID association) const |
| bool | isLowestTier (const Continental::CompetitionRules &rules) const |
| void | assignPots (Season &season) const |
| void | drawLeaguePhase (Calendar &calendar, Season &season, const GameDateValue &today) |
| void | advanceKnockouts (Calendar &calendar, Season &season, const GameDateValue &today) |
| void | drawKnockoutRound (Calendar &calendar, Season &season, Continental::Round round, std::vector< TeamID > seeded, std::vector< TeamID > unseeded, const GameDateValue &today) |
| void | payPrize (TeamID team_id, const GameDateValue &date, int64_t amount) |
| void | postNews (const GameDateValue &date, std::string title_key, std::string body_key, std::vector< std::string > args, const std::vector< TeamID > &involved, bool headline) const |
| std::vector< const Match * > | competitionMatches (const Calendar &calendar, LeagueID competition_id) const |
| const Match * | findLeg (const Calendar &calendar, LeagueID competition_id, uint8_t stage, TeamID home_id, TeamID away_id) const |
| std::string | teamName (TeamID team_id) const |
Private Attributes | |
| std::shared_ptr< GameData > | gamedata |
| NewsSink | news |
| std::vector< Season > | seasons |
| std::map< LeagueID, AssociationCoefficient > | associations |
| std::map< TeamID, std::array< double, COEFFICIENT_SEASONS > > | clubs |
| uint16_t | last_closed_season = 0 |
| bool | results_dirty = true |
| std::map< LeagueID, std::vector< Entrant > > | qualified |
| uint16_t | qualified_season = 0 |
| std::map< LeagueID, std::vector< StandingRow > > | tables |
Seasons, draws, knockouts, prize money and coefficients of the continental club competitions.
Qualification comes from the final domestic tables (and cup winners) of the previous season, association places from the association coefficient ranking (club results of the last five seasons divided by the clubs entered). The league-phase draw is an event in late August; each knockout draw happens the day the previous round is complete.
| using ContinentalCompetitions::NewsSink = std::function<void(InboxMessage, const std::vector<TeamID>&, bool)> |
Message, clubs it concerns, and whether it is general news.
|
explicit |
|
private |
| void ContinentalCompetitions::afterMatchday | ( | Calendar & | calendar, |
| const GameDateValue & | today | ||
| ) |
Draws that are due and knockout progress; call once per day.
|
private |
|
private |
| std::vector< ContinentalCompetitions::AssociationCoefficient > ContinentalCompetitions::associationRanking | ( | Continental::Continent | continent | ) | const |
Associations of a continent, best coefficient first.
| void ContinentalCompetitions::closeSeason | ( | const Calendar & | calendar, |
| uint16_t | season_year, | ||
| const std::unordered_map< LeagueID, std::vector< StandingRow > > & | tables, | ||
| const std::map< LeagueID, TeamID > & | cup_winners | ||
| ) |
Season end: updates coefficients from the season's matches and computes the clubs qualified for the next season.
| tables | Final tables of the top divisions (1st first). |
| cup_winners | Domestic cup winner per association (top league). |
| double ContinentalCompetitions::clubCoefficient | ( | TeamID | team_id | ) | const |
Club coefficient: own points of five seasons or 20% of its association's coefficient, whichever is higher.
|
private |
Competition a club plays this season, if any.
| std::optional< std::pair< int, int > > ContinentalCompetitions::deciderAggregate | ( | const Calendar & | calendar, |
| const Match & | match | ||
| ) | const |
For a deciding match: the goals this match's home and away sides scored in the earlier leg ({0, 0} for a final); nullopt for any other match.
| std::optional< int > ContinentalCompetitions::deciderLead | ( | const Calendar & | calendar, |
| const Match & | match | ||
| ) | const |
For a deciding match (a final, or a second leg whose first leg is played): the home side's aggregate lead from the earlier leg (0 for a final). The tie goes to extra time when the home side's goals plus this lead equal the away side's goals. nullopt for any other match.
| void ContinentalCompetitions::deserialize | ( | const std::string & | data | ) |
|
private |
|
private |
|
private |
|
private |
|
inline |
Clubs qualified for next season (after closeSeason()).
| const ContinentalCompetitions::Season * ContinentalCompetitions::getSeason | ( | LeagueID | competition_id | ) | const |
|
inline |
| const std::vector< StandingRow > & ContinentalCompetitions::getTable | ( | LeagueID | competition_id | ) | const |
Cached league-phase table (empty before the draw).
|
private |
| void ContinentalCompetitions::load | ( | const DatabaseConnection & | db | ) |
| bool ContinentalCompetitions::needsExtraTime | ( | const Calendar & | calendar, |
| const Match & | match | ||
| ) | const |
A second leg (or final) whose aggregate is level after 90 minutes.
| void ContinentalCompetitions::onResult | ( | const Match & | match | ) |
Prize money of a league-phase result; call once per played match.
|
private |
|
private |
|
private |
|
private |
|
private |
| void ContinentalCompetitions::refresh | ( | const Calendar & | calendar | ) |
Rebuilds cached tables from the calendar (after loading).
Settles a deciding match whose aggregate is level with extra time and penalties; true if match changed.
| void ContinentalCompetitions::save | ( | const DatabaseConnection & | db | ) | const |
| std::string ContinentalCompetitions::serialize | ( | ) | const |
|
inline |
| void ContinentalCompetitions::startSeason | ( | uint16_t | season_year, |
| const GameDateValue & | today | ||
| ) |
Enters the qualified clubs of season_year and plans the league-phase draw. Uses the qualification computed by closeSeason() or, without one (first season, older saves), the clubs' reputation. Nothing happens if the season already exists or if today is too late to play the league phase.
|
private |
| ContinentalCompetitions::TieScore ContinentalCompetitions::tieScore | ( | const Calendar & | calendar, |
| const Season & | season, | ||
| const Tie & | tie | ||
| ) | const |
Aggregate score of a tie.
|
private |
|
private |
|
private |
|
staticconstexpr |
|
private |
|
private |
Latest season whose results are in the coefficients.
|
private |
|
private |
|
private |
A result changed since the last knockout check.
|
private |
|
private |