|
Player12
An open source football management simulator
|
Represents a football league containing teams and a leaderboard. More...
#include <league.h>
Public Member Functions | |
| League (LeagueID league_id, const std::string &league_name, const std::vector< TeamID > &initial_team_ids={}, std::optional< LeagueID > parent=std::nullopt, TieBreakRule tie_break_rule=TieBreakRule::GOAL_DIFFERENCE) | |
| Constructs a League object. | |
| uint8_t | getId () const |
| Gets the league ID. | |
| std::string | getName () const |
| Gets the name of the league. | |
| const std::vector< TeamID > & | getTeamIDs () const |
| Gets the IDs of the teams in the league. | |
| void | addTeamID (TeamID team_id) |
| Adds a team to the league. | |
| void | removeTeamID (TeamID team_id) |
| Removes a team from the league. | |
| uint16_t | getPoints (TeamID team_id) const |
| Gets the points of a specific team. | |
| void | addPoints (TeamID team_id, uint16_t points) |
| Adds points to a specific team. | |
| void | setPoints (TeamID team_id, uint16_t points) |
| Sets the points of a specific team. | |
| void | resetPoints () |
| Resets the points of all teams in the league to zero. | |
| const std::map< TeamID, uint16_t > & | getLeaderboard () const |
| Gets the league leaderboard. | |
| std::optional< LeagueID > | getParentLeagueID () const |
| Gets the parent league ID, if any. | |
| TieBreakRule | getTieBreakRule () const |
| Ordering rule for teams level on points. | |
Private Attributes | |
| const LeagueID | id |
| std::string | name |
| const std::optional< LeagueID > | parent_league_id |
| TieBreakRule | tie_break |
| std::vector< TeamID > | team_ids |
| std::map< TeamID, uint16_t > | leaderboard |
Represents a football league containing teams and a leaderboard.
Full tables (goal difference, form, tie-breakers) are computed from the played fixtures by Standings::compute; the leaderboard here only mirrors the points. Leagues form pyramids through the parent league ID.
| League::League | ( | LeagueID | league_id, |
| const std::string & | league_name, | ||
| const std::vector< TeamID > & | initial_team_ids = {}, |
||
| std::optional< LeagueID > | parent = std::nullopt, |
||
| TieBreakRule | tie_break_rule = TieBreakRule::GOAL_DIFFERENCE |
||
| ) |
Constructs a League object.
| league_id | The unique ID for the league. |
| league_name | The name of the league. |
| initial_team_ids | Optional list of initial team IDs in the league. |
| parent | Optional parent league ID. |
| tie_break_rule | How teams level on points are ordered. |
| void League::addPoints | ( | TeamID | team_id, |
| uint16_t | points | ||
| ) |
Adds points to a specific team.
| team_id | The ID of the team. |
| points | The points to add. |
| void League::addTeamID | ( | TeamID | team_id | ) |
Adds a team to the league.
| team_id | The ID of the team to add. |
| uint8_t League::getId | ( | ) | const |
Gets the league ID.
| const std::map< TeamID, uint16_t > & League::getLeaderboard | ( | ) | const |
Gets the league leaderboard.
Points mirror of the fixture-derived table (see Standings::compute), refreshed by Game after every result.
| std::string League::getName | ( | ) | const |
Gets the name of the league.
| std::optional< LeagueID > League::getParentLeagueID | ( | ) | const |
Gets the parent league ID, if any.
| uint16_t League::getPoints | ( | TeamID | team_id | ) | const |
Gets the points of a specific team.
| team_id | The ID of the team. |
| const std::vector< TeamID > & League::getTeamIDs | ( | ) | const |
Gets the IDs of the teams in the league.
|
inline |
Ordering rule for teams level on points.
| void League::removeTeamID | ( | TeamID | team_id | ) |
Removes a team from the league.
| team_id | The ID of the team to remove. |
| void League::resetPoints | ( | ) |
Resets the points of all teams in the league to zero.
| void League::setPoints | ( | TeamID | team_id, |
| uint16_t | points | ||
| ) |
Sets the points of a specific team.
| team_id | The ID of the team. |
| points | The points to set. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |