|
Player12
An open source football management simulator
|
National-team calendar, call-ups, matches and records. More...
#include <national_teams.h>
Classes | |
| struct | Finals |
| struct | Honour |
| struct | Squad |
| struct | Team |
| struct | Travel |
Public Types | |
| using | ResultSink = std::function< void(const International::Fixture &, double home_expected)> |
| using | FinalsSink = std::function< void(const Finals &, bool decided)> |
Public Member Functions | |
| NationalTeams (std::shared_ptr< GameData > gamedata) | |
| void | setResultSink (ResultSink sink) |
| void | setFinalsSink (FinalsSink sink) |
| void | onDay (const GameDateValue &today, MatchScheduler &scheduler, WorldSimulation &world, TeamID managed_team_id) |
Daily processing: plans the season's international calendar, announces squads a week before each window, plays the day's matches through scheduler, runs the finals and releases players. | |
| void | planSeason (uint16_t season_year, const GameDateValue &today, WorldSimulation *world) |
| bool | isOnDuty (PlayerID player_id, const GameDateValue &date) const |
| std::optional< Language > | dutyNation (PlayerID player_id, const GameDateValue &date) const |
| double | injuryRiskMultiplier (PlayerID player_id, const GameDateValue &date) const |
| bool | isEligibleFor (const Player &player, Language nation, const GameDateValue &date) const |
| const Squad * | squadOf (Language nation, const GameDateValue &date) const |
| std::vector< PlayerID > | eligiblePool (Language nation, const GameDateValue &date) const |
| International::CallUpResult | validateSquad (Language nation, const std::vector< PlayerID > &players, const GameDateValue &today) const |
| International::CallUpResult | setSquad (Language nation, std::vector< PlayerID > players, const GameDateValue &today) |
| void | setCoach (Language nation, std::string name) |
| double | expectedScore (Language home, Language away, bool neutral) const |
| const std::vector< Team > & | getTeams () const |
| const Team * | getTeam (Language nation) const |
| std::vector< Language > | ranking () const |
| const std::vector< International::Fixture > & | getFixtures () const |
| const std::vector< International::Group > & | getGroups () const |
| const std::vector< Finals > & | getFinals () const |
| const std::vector< Squad > & | getSquads () const |
| const std::vector< Honour > & | getHonours () const |
| const International::Record * | getRecord (PlayerID player_id) const |
| std::vector< std::pair< PlayerID, International::Record > > | capsLeaders (size_t limit) const |
| std::vector< International::GroupRow > | table (const International::Group &group) const |
| void | load (const DatabaseConnection &db) |
| void | save (const DatabaseConnection &db) const |
| std::string | serialize () const |
| void | deserialize (const std::string &data) |
Static Public Member Functions | |
| static size_t | squadLimit (const Squad &squad) |
Static Public Attributes | |
| static constexpr TeamID | TEAM_ID_BASE = 0xF000 |
| static constexpr size_t | MIN_POOL = 20 |
| static constexpr int64_t | COMPENSATION_PER_DAY = 5'000 |
Private Member Functions | |
| void | refreshNations () |
| std::vector< Language > | pool (std::optional< International::Confederation > confederation) const |
| void | planQualifiers (uint16_t season_year, uint16_t finals_year, const std::vector< GameDateValue > &slots, const GameDateValue &summer_start) |
| void | planNationsLeague (uint16_t season_year, const std::vector< GameDateValue > &slots, const GameDateValue &summer_start) |
| void | scheduleGroup (const International::Group &group, const std::vector< GameDateValue > &slots, bool neutral) |
| void | drawFinals (Finals &entry, const GameDateValue &today, WorldSimulation &world) |
| void | progressFinals (Finals &entry, const GameDateValue &today, WorldSimulation &world) |
| void | announceWindow (const GameDateValue &today, const std::vector< GameDateValue > &match_days, const GameDateValue &start, const GameDateValue &end, WorldSimulation &world, TeamID managed_team_id) |
| void | playMatches (const GameDateValue &today, MatchScheduler &scheduler, WorldSimulation &world, TeamID managed_team_id) |
| void | releasePlayers (const GameDateValue &today, WorldSimulation &world, TeamID managed_team_id) |
| void | replaceInjured (const GameDateValue &today) |
| std::vector< PlayerID > | pickSquad (Language nation, size_t size, const GameDateValue &date, const std::vector< PlayerID > &keep) const |
| void | updateRatings (const International::Fixture &fixture) |
| uint32_t | addFixture (International::Fixture fixture) |
| bool | hasFixture (Language nation, const GameDateValue &date) const |
| const Finals * | finalsFor (Language nation, const GameDateValue &date) const |
| void | rebuildDutyIndex () |
| void | post (WorldSimulation &world, const GameDateValue &date, std::string title_key, std::string body_key, std::vector< std::string > args, bool read) const |
Private Attributes | |
| std::shared_ptr< GameData > | gamedata |
| std::vector< Team > | teams |
| std::vector< International::Fixture > | fixtures |
| std::vector< International::Group > | groups |
| std::vector< Finals > | finals |
| std::vector< Squad > | squads |
| std::vector< Honour > | honours |
| std::unordered_map< PlayerID, International::Record > | records |
| std::unordered_map< PlayerID, Travel > | travel |
| std::unordered_map< PlayerID, std::pair< GameDateValue, GameDateValue > > | duty |
| uint16_t | planned_season = 0 |
| uint32_t | next_fixture_id = 1 |
| ResultSink | result_sink |
| FinalsSink | finals_sink |
National-team calendar, call-ups, matches and records.
Matches are simulated with the match engine through the same MatchScheduler batch as club matches. Called-up players are unavailable to their clubs from the Monday of a window to its last day (finals: until their nation is out), come back with the match fatigue and injuries of the engine plus travel fatigue, and raise the injury risk for a few days after long trips. Clubs are compensated per player and day for finals.
| using NationalTeams::FinalsSink = std::function<void(const Finals&, bool decided)> |
A finals tournament was drawn (qualifiers known) or decided.
| using NationalTeams::ResultSink = std::function<void(const International::Fixture&, double home_expected)> |
A played match and the home side's expected score before it.
|
explicit |
|
private |
|
private |
| std::vector< std::pair< PlayerID, International::Record > > NationalTeams::capsLeaders | ( | size_t | limit | ) | const |
Most capped players (ties: goals, then ID).
| void NationalTeams::deserialize | ( | const std::string & | data | ) |
|
private |
| std::optional< Language > NationalTeams::dutyNation | ( | PlayerID | player_id, |
| const GameDateValue & | date | ||
| ) | const |
Nation a player is (or will be) with on date.
| std::vector< PlayerID > NationalTeams::eligiblePool | ( | Language | nation, |
| const GameDateValue & | date | ||
| ) | const |
Players the nation may call up on date (injured ones included), sorted by ID.
Expected score of home against away (Elo, home advantage unless neutral).
|
private |
|
inline |
|
inline |
|
inline |
Qualifying and nations-league groups of the current cycle.
|
inline |
| const International::Record * NationalTeams::getRecord | ( | PlayerID | player_id | ) | const |
|
inline |
| const NationalTeams::Team * NationalTeams::getTeam | ( | Language | nation | ) | const |
|
inline |
|
private |
| double NationalTeams::injuryRiskMultiplier | ( | PlayerID | player_id, |
| const GameDateValue & | date | ||
| ) | const |
Injury-risk multiplier (>= 1) after long trips, for a few days.
| bool NationalTeams::isEligibleFor | ( | const Player & | player, |
| Language | nation, | ||
| const GameDateValue & | date | ||
| ) | const |
Whether player may be picked by nation on date.
| bool NationalTeams::isOnDuty | ( | PlayerID | player_id, |
| const GameDateValue & | date | ||
| ) | const |
Called up and not yet released on date.
| void NationalTeams::load | ( | const DatabaseConnection & | db | ) |
| void NationalTeams::onDay | ( | const GameDateValue & | today, |
| MatchScheduler & | scheduler, | ||
| WorldSimulation & | world, | ||
| TeamID | managed_team_id | ||
| ) |
Daily processing: plans the season's international calendar, announces squads a week before each window, plays the day's matches through scheduler, runs the finals and releases players.
|
private |
|
private |
|
private |
| void NationalTeams::planSeason | ( | uint16_t | season_year, |
| const GameDateValue & | today, | ||
| WorldSimulation * | world | ||
| ) |
Plans the international matches of the season (idempotent).
|
private |
|
private |
|
private |
|
private |
| std::vector< Language > NationalTeams::ranking | ( | ) | const |
Nations by rating, best first.
|
private |
|
private |
|
private |
|
private |
| void NationalTeams::save | ( | const DatabaseConnection & | db | ) | const |
|
private |
| std::string NationalTeams::serialize | ( | ) | const |
| void NationalTeams::setCoach | ( | Language | nation, |
| std::string | name | ||
| ) |
Names the nation's head coach.
|
inline |
|
inline |
| International::CallUpResult NationalTeams::setSquad | ( | Language | nation, |
| std::vector< PlayerID > | players, | ||
| const GameDateValue & | today | ||
| ) |
Replaces the announced squad once validateSquad() accepts it.
|
inlinestatic |
Squad limit of a call-up (window or finals).
| const NationalTeams::Squad * NationalTeams::squadOf | ( | Language | nation, |
| const GameDateValue & | date | ||
| ) | const |
The nation's announced or current squad on date (nullptr if none).
| std::vector< International::GroupRow > NationalTeams::table | ( | const International::Group & | group | ) | const |
Group table with the current ratings as the last tie-breaker.
|
private |
| International::CallUpResult NationalTeams::validateSquad | ( | Language | nation, |
| const std::vector< PlayerID > & | players, | ||
| const GameDateValue & | today | ||
| ) | const |
Checks a squad a head coach wants to call up for the announced window.
|
staticconstexpr |
Club compensation per finals player and day (whole euros).
|
private |
Player -> (start, until) of his current or announced duty.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
Nations need this many players (and two goalkeepers).
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
Team IDs used for national teams inside match reports.
|
private |