Player12
An open source football management simulator
Loading...
Searching...
No Matches
Match Class Reference

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
 

Detailed Description

Represents a football match between two teams.

Constructor & Destructor Documentation

◆ Match()

Match::Match ( TeamID  home_id,
TeamID  away_id,
GameDateValue  date,
MatchType  type,
LeagueID  competition = 0,
uint8_t  stage = 0 
)

Constructs a Match object.

Parameters
home_idThe ID of the home team.
away_idThe ID of the away team.
dateThe date of the match.
typeThe type of the match (e.g., league, friendly).
competitionLeague ID (league matches) or country root league ID (cup matches); 0 for friendlies.
stageLeague round or cup round, 1-based; 0 when unknown.

Member Function Documentation

◆ applySimulation()

MatchReport Match::applySimulation ( MatchSimulationResult  result)

Records a simulated result. Returns its report with the identity and final result filled in.

◆ getAwayPenalties()

uint8_t Match::getAwayPenalties ( ) const
inline

◆ getAwayScore()

uint8_t Match::getAwayScore ( ) const

Gets the away team's score.

Returns
The score of the away team.

◆ getAwayTeamId()

uint16_t Match::getAwayTeamId ( ) const

Gets the ID of the away team.

Returns
The away team's ID.

◆ getCompetitionId()

LeagueID Match::getCompetitionId ( ) const
inline

◆ getDate()

const GameDateValue & Match::getDate ( ) const

Gets the date of the match.

Returns
The date value.

◆ getHomePenalties()

uint8_t Match::getHomePenalties ( ) const
inline

◆ getHomeScore()

uint8_t Match::getHomeScore ( ) const

Gets the home team's score.

Returns
The score of the home team.

◆ getHomeTeamId()

uint16_t Match::getHomeTeamId ( ) const

Gets the ID of the home team.

Returns
The home team's ID.

◆ getKickoff()

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.

◆ getMatchType()

MatchType Match::getMatchType ( ) const

Gets the type of the match.

Returns
The match type.

◆ getScheduledKickoff()

uint16_t Match::getScheduledKickoff ( ) const
inline

Kick-off chosen when the fixture was scheduled; 0 when defaulted.

◆ getSeed()

uint32_t Match::getSeed ( ) const

Deterministic per-fixture seed (teams and date).

◆ getStage()

uint8_t Match::getStage ( ) const
inline

◆ getWinnerId()

std::optional< TeamID > Match::getWinnerId ( ) const

Winner of a played match; nullopt for unplayed matches and draws.

◆ isKnockout()

bool Match::isKnockout ( ) const
inline

True for knockout ties that cannot end in a draw.

◆ isPlayed()

bool Match::isPlayed ( ) const

Checks if the match has been played.

Returns
True if the match has been played, false otherwise.

◆ prepareSimulation()

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.

◆ setCompetitionId()

void Match::setCompetitionId ( LeagueID  id)
inline

◆ setKickoff()

void Match::setKickoff ( uint16_t  minutes)
inline

Scheduled kick-off in minutes after midnight; 0 restores the default.

◆ setKnockoutResult()

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.

◆ setPlayedResult()

void Match::setPlayedResult ( uint8_t  h,
uint8_t  a 
)

◆ simulate()

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.

Parameters
game_dataReference to the GameData used for simulation.
reportOptional report filled with the structured match summary.
consequencesOptional physical outcome of every participant (engine end condition and injuries) for WorldSimulation.

◆ wentToExtraTime()

bool Match::wentToExtraTime ( ) const
inline

◆ wentToPenalties()

bool Match::wentToPenalties ( ) const
inline

◆ writeResultTo()

void Match::writeResultTo ( MatchReport &  report) const

Copies identity and final result (incl. extra time) into a report.

Member Data Documentation

◆ _played

bool Match::_played = false
private

◆ away_penalties

uint8_t Match::away_penalties = 0
private

◆ away_score

uint8_t Match::away_score = 0
private

◆ away_team_id

TeamID Match::away_team_id
private

◆ competition_id

LeagueID Match::competition_id
private

◆ extra_time

bool Match::extra_time = false
private

◆ home_penalties

uint8_t Match::home_penalties = 0
private

◆ home_score

uint8_t Match::home_score
private

◆ home_team_id

TeamID Match::home_team_id
private

◆ kickoff

uint16_t Match::kickoff = 0
private

◆ match_date

GameDateValue Match::match_date
private

◆ match_type

MatchType Match::match_type
private

◆ penalties

bool Match::penalties = false
private

◆ stage

uint8_t Match::stage
private

The documentation for this class was generated from the following files: