|
Player12
An open source football management simulator
|
Represents a football match between two teams. More...
#include <match.h>
Public Member Functions | |
| Match (TeamID home_id, TeamID away_id, GameDateValue date, MatchType type, LeagueID competition=0, uint8_t stage=0) | |
| Constructs a Match object. | |
| void | simulate (const GameData &game_data, MatchReport *report=nullptr, std::vector< PlayerMatchConsequence > *consequences=nullptr) |
| Simulates the match using the provided game data. | |
| std::optional< MatchSimulationInput > | prepareSimulation (const GameData &game_data) const |
| MatchReport | applySimulation (MatchSimulationResult result) |
| TeamID | getHomeTeamId () const |
| Gets the ID of the home team. | |
| TeamID | getAwayTeamId () const |
| Gets the ID of the away team. | |
| uint8_t | getHomeScore () const |
| Gets the home team's score. | |
| uint8_t | getAwayScore () const |
| Gets the away team's score. | |
| MatchType | getMatchType () const |
| Gets the type of the match. | |
| const GameDateValue & | getDate () const |
| Gets the date of the match. | |
| bool | isPlayed () const |
| Checks if the match has been played. | |
| void | setPlayedResult (uint8_t h, uint8_t a) |
| void | setKnockoutResult (uint8_t h, uint8_t a, bool extra_time, std::optional< std::pair< uint8_t, uint8_t > > penalties) |
| uint16_t | getKickoff () const |
| void | setKickoff (uint16_t minutes) |
| uint16_t | getScheduledKickoff () const |
| LeagueID | getCompetitionId () const |
| void | setCompetitionId (LeagueID id) |
| uint8_t | getStage () const |
| bool | isKnockout () const |
| bool | wentToExtraTime () const |
| bool | wentToPenalties () const |
| uint8_t | getHomePenalties () const |
| uint8_t | getAwayPenalties () const |
| std::optional< TeamID > | getWinnerId () const |
| uint32_t | getSeed () const |
| void | writeResultTo (MatchReport &report) const |
Private Attributes | |
| TeamID | home_team_id |
| TeamID | away_team_id |
| GameDateValue | match_date |
| MatchType | match_type |
| uint8_t | home_score |
| uint8_t | away_score = 0 |
| LeagueID | competition_id |
| uint8_t | stage |
| uint16_t | kickoff = 0 |
| uint8_t | home_penalties = 0 |
| uint8_t | away_penalties = 0 |
| bool | extra_time = false |
| bool | penalties = false |
| bool | _played = false |
Represents a football match between two teams.
| Match::Match | ( | TeamID | home_id, |
| TeamID | away_id, | ||
| GameDateValue | date, | ||
| MatchType | type, | ||
| LeagueID | competition = 0, |
||
| uint8_t | stage = 0 |
||
| ) |
Constructs a Match object.
| home_id | The ID of the home team. |
| away_id | The ID of the away team. |
| date | The date of the match. |
| type | The type of the match (e.g., league, friendly). |
| competition | League ID (league matches) or country root league ID (cup matches); 0 for friendlies. |
| stage | League round or cup round, 1-based; 0 when unknown. |
| MatchReport Match::applySimulation | ( | MatchSimulationResult | result | ) |
Records a simulated result. Returns its report with the identity and final result filled in.
|
inline |
| uint8_t Match::getAwayScore | ( | ) | const |
Gets the away team's score.
| uint16_t Match::getAwayTeamId | ( | ) | const |
Gets the ID of the away team.
|
inline |
| const GameDateValue & Match::getDate | ( | ) | const |
Gets the date of the match.
|
inline |
| uint8_t Match::getHomeScore | ( | ) | const |
Gets the home team's score.
| uint16_t Match::getHomeTeamId | ( | ) | const |
Gets the ID of the home team.
| uint16_t Match::getKickoff | ( | ) | const |
Kick-off time in minutes after midnight (local time at the venue). Fixtures scheduled without one (cup ties, continental matches, fixtures of older saves) report the usual time for their competition and weekday.
| MatchType Match::getMatchType | ( | ) | const |
Gets the type of the match.
|
inline |
Kick-off chosen when the fixture was scheduled; 0 when defaulted.
| uint32_t Match::getSeed | ( | ) | const |
Deterministic per-fixture seed (teams and date).
|
inline |
| std::optional< TeamID > Match::getWinnerId | ( | ) | const |
Winner of a played match; nullopt for unplayed matches and draws.
|
inline |
True for knockout ties that cannot end in a draw.
| bool Match::isPlayed | ( | ) | const |
Checks if the match has been played.
| std::optional< MatchSimulationInput > Match::prepareSimulation | ( | const GameData & | game_data | ) | const |
Captures lineups, strategies, seed and (for cup ties) the extra-time resolution, so the match can be simulated off this thread with MatchSimulation::run(). nullopt when played or a team is missing.
|
inline |
|
inline |
Scheduled kick-off in minutes after midnight; 0 restores the default.
| void Match::setKnockoutResult | ( | uint8_t | h, |
| uint8_t | a, | ||
| bool | extra_time, | ||
| std::optional< std::pair< uint8_t, uint8_t > > | penalties | ||
| ) |
Records the final score after extra time plus an optional shootout.
| void Match::setPlayedResult | ( | uint8_t | h, |
| uint8_t | a | ||
| ) |
| void Match::simulate | ( | const GameData & | game_data, |
| MatchReport * | report = nullptr, |
||
| std::vector< PlayerMatchConsequence > * | consequences = nullptr |
||
| ) |
Simulates the match using the provided game data.
Drawn cup matches are decided by extra time and, if still level, a penalty shootout. Players start with their persistent condition.
| game_data | Reference to the GameData used for simulation. |
| report | Optional report filled with the structured match summary. |
| consequences | Optional physical outcome of every participant (engine end condition and injuries) for WorldSimulation. |
|
inline |
|
inline |
| void Match::writeResultTo | ( | MatchReport & | report | ) | const |
Copies identity and final result (incl. extra time) into a report.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |