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

Manages the match calendar for a season. More...

#include <calendar.h>

Public Member Functions

 Calendar ()=default
 Default constructor.
 
void generate (const class GameData &gamedata, const GameDateValue &startDate)
 Generates the full calendar of the season starting on a date.
 
void addMatch (const Match &match)
 Adds a single match to the calendar.
 
const std::map< GameDateValue, std::vector< Match > > & getFullCalendar () const
 Gets the full calendar schedule.
 
const std::vector< Match > & getMatchesForDate (const GameDateValue &date) const
 Gets the matches scheduled for a specific date.
 
std::vector< Match > & getMatchesForDateMutable (const GameDateValue &date)
 
const Match * findMatch (const GameDateValue &date, TeamID home_id, TeamID away_id) const
 Finds a fixture by its natural key (date, home, away).
 
Match * findMatch (const GameDateValue &date, TeamID home_id, TeamID away_id)
 
std::vector< Match > getTeamFixtures (TeamID team_id) const
 All fixtures of a team in date order.
 
size_t protectRest (const GameDateValue &after)
 Keeps clubs rested around cup and continental ties.
 
void markRestChecked ()
 Treats the current fixtures as already checked by protectRest() (fixtures loaded from a save keep their dates).
 

Private Member Functions

void generateSeasonFixtures (const class GameData &gamedata, uint16_t season_year)
 
void generateFriendlies (const class GameData &gamedata, const GameDateValue &startDate, size_t numFriendlies)
 

Private Attributes

std::map< GameDateValue, std::vector< Match > > schedule
 
bool rest_check_pending = false
 

Detailed Description

Manages the match calendar for a season.

This class is responsible for generating and storing the match schedule, including season fixtures, cup ties and friendlies.

Constructor & Destructor Documentation

◆ Calendar()

Calendar::Calendar ( )
default

Default constructor.

Member Function Documentation

◆ addMatch()

void Calendar::addMatch ( const Match &  match)

Adds a single match to the calendar.

Parameters
matchThe match to add.

◆ findMatch() [1/2]

Match * Calendar::findMatch ( const GameDateValue &  date,
TeamID  home_id,
TeamID  away_id 
)

◆ findMatch() [2/2]

const Match * Calendar::findMatch ( const GameDateValue &  date,
TeamID  home_id,
TeamID  away_id 
) const

Finds a fixture by its natural key (date, home, away).

◆ generate()

void Calendar::generate ( const class GameData &  gamedata,
const GameDateValue &  startDate 
)

Generates the full calendar of the season starting on a date.

Parameters
startDateFirst day of the season (early July).

◆ generateFriendlies()

void Calendar::generateFriendlies ( const class GameData &  gamedata,
const GameDateValue &  startDate,
size_t  numFriendlies 
)
private

◆ generateSeasonFixtures()

void Calendar::generateSeasonFixtures ( const class GameData &  gamedata,
uint16_t  season_year 
)
private

◆ getFullCalendar()

const std::map< GameDateValue, std::vector< Match > > & Calendar::getFullCalendar ( ) const

Gets the full calendar schedule.

Returns
A map containing all scheduled matches grouped by date.

◆ getMatchesForDate()

const std::vector< Match > & Calendar::getMatchesForDate ( const GameDateValue &  date) const

Gets the matches scheduled for a specific date.

Parameters
dateThe date to query.
Returns
A vector of matches scheduled for the given date.

◆ getMatchesForDateMutable()

std::vector< Match > & Calendar::getMatchesForDateMutable ( const GameDateValue &  date)

◆ getTeamFixtures()

std::vector< Match > Calendar::getTeamFixtures ( TeamID  team_id) const

All fixtures of a team in date order.

◆ markRestChecked()

void Calendar::markRestChecked ( )
inline

Treats the current fixtures as already checked by protectRest() (fixtures loaded from a save keep their dates).

◆ protectRest()

size_t Calendar::protectRest ( const GameDateValue &  after)

Keeps clubs rested around cup and continental ties.

When cup or continental fixtures were added since the last call, every unplayed league fixture after after that leaves a club less than MIN_REST_BEFORE_TIE days before such a tie (or less than MIN_REST_DAYS from any other competitive match) moves to the nearest day of its round (Friday-Monday, or Tuesday-Thursday for midweek rounds) that suits both clubs. Deterministic; a no-op when nothing was added.

Returns
Number of league fixtures moved.

Member Data Documentation

◆ rest_check_pending

bool Calendar::rest_check_pending = false
private

◆ schedule

std::map<GameDateValue, std::vector<Match> > Calendar::schedule
private

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