108std::vector<GameDateValue>
leagueRoundDates(uint16_t season_year,
size_t rounds,
109 uint8_t variant = 0);
112std::vector<GameDateValue>
cupRoundDates(uint16_t season_year,
size_t rounds);
156 const std::map<GameDateValue, std::vector<Match>>&
getFullCalendar()
const;
193 uint16_t season_year);
198 std::map<GameDateValue, std::vector<Match>>
schedule;
Manages the match calendar for a season.
Definition calendar.h:133
size_t protectRest(const GameDateValue &after)
Keeps clubs rested around cup and continental ties.
Definition calendar.cpp:1171
std::map< GameDateValue, std::vector< Match > > schedule
Definition calendar.h:198
void markRestChecked()
Treats the current fixtures as already checked by protectRest() (fixtures loaded from a save keep the...
Definition calendar.h:189
void addMatch(const Match &match)
Adds a single match to the calendar.
Definition calendar.cpp:854
const std::vector< Match > & getMatchesForDate(const GameDateValue &date) const
Gets the matches scheduled for a specific date.
Definition calendar.cpp:868
Calendar()=default
Default constructor.
bool rest_check_pending
Definition calendar.h:199
void generate(const class GameData &gamedata, const GameDateValue &startDate)
Generates the full calendar of the season starting on a date.
Definition calendar.cpp:840
void generateFriendlies(const class GameData &gamedata, const GameDateValue &startDate, size_t numFriendlies)
Definition calendar.cpp:1334
const std::map< GameDateValue, std::vector< Match > > & getFullCalendar() const
Gets the full calendar schedule.
Definition calendar.cpp:862
std::vector< Match > getTeamFixtures(TeamID team_id) const
All fixtures of a team in date order.
Definition calendar.cpp:916
std::vector< Match > & getMatchesForDateMutable(const GameDateValue &date)
Definition calendar.cpp:880
const Match * findMatch(const GameDateValue &date, TeamID home_id, TeamID away_id) const
Finds a fixture by its natural key (date, home, away).
Definition calendar.cpp:886
void generateSeasonFixtures(const class GameData &gamedata, uint16_t season_year)
Definition calendar.cpp:930
Singleton class that acts as an in-memory cache for the database state.
Definition gamedata.h:43
Represents a football match between two teams.
Definition match.h:38
Season date rules shared by the calendar and the competitions.
Definition calendar.h:31
constexpr uint8_t FRIDAY
Definition calendar.h:36
std::vector< InternationalWindow > internationalWindows(uint16_t season_year)
Windows of the season starting in season_year, by date.
Definition calendar.cpp:279
GameDateValue leagueEnd(uint16_t season_year)
Last regular league Saturday (on or before 24 May).
Definition calendar.cpp:272
GameDateValue nextFreeMidweek(const GameDateValue &date)
First Wednesday after date that is not in a break.
Definition calendar.cpp:466
constexpr size_t CONTINENTAL_WEEKS
Definition calendar.h:85
bool isInternationalBreak(const GameDateValue &date)
Definition calendar.cpp:303
bool isWinterBreak(const GameDateValue &date)
Definition calendar.cpp:334
bool isContinentalWeek(const GameDateValue &date)
True from Tuesday to Thursday of a continental club week.
Definition calendar.cpp:329
constexpr size_t PRESEASON_FRIENDLIES
Definition calendar.h:51
GameDateValue leagueStart(uint16_t season_year)
First league Saturday (first Saturday on or after 15 August).
Definition calendar.cpp:266
constexpr int MIN_REST_BEFORE_TIE
Definition calendar.h:43
constexpr uint8_t WEDNESDAY
Definition calendar.h:34
constexpr uint8_t THURSDAY
Definition calendar.h:35
std::vector< GameDateValue > leagueRoundDates(uint16_t season_year, size_t rounds, uint8_t variant=0)
Anchor date of each league round: a Saturday for weekend rounds (matches spread from Friday to Monday...
Definition calendar.cpp:374
constexpr uint8_t TUESDAY
Definition calendar.h:33
bool isBlackout(const GameDateValue &date)
No competitive fixtures may be scheduled on this date.
Definition calendar.cpp:342
constexpr int MIN_REST_DAYS
Definition calendar.h:40
std::vector< GameDateValue > continentalWeeks(uint16_t season_year)
Tuesday of every continental club week (see CONTINENTAL_WEEKS). Continental matches are played Tuesda...
Definition calendar.cpp:320
constexpr size_t MAX_CUP_ROUNDS
Definition calendar.h:50
uint16_t seasonStartYear(const GameDateValue &date)
Calendar year in which the season containing date started.
Definition calendar.cpp:259
constexpr uint8_t SEASON_START_MONTH
Definition calendar.h:49
constexpr uint8_t SATURDAY
Definition calendar.h:37
std::vector< GameDateValue > friendlyDates(const GameDateValue &from, size_t count)
Saturdays of the pre-season friendly weeks after from and before the league; each week's friendlies a...
Definition calendar.cpp:445
GameDateValue addDays(const GameDateValue &date, int days)
Adds (or subtracts) days in O(1).
Definition calendar.cpp:254
int restDays(MatchType earlier, MatchType later)
Definition calendar.cpp:458
std::vector< GameDateValue > cupRoundDates(uint16_t season_year, size_t rounds)
Date of each cup round; the last one (the final) is a Saturday.
Definition calendar.cpp:347
uint8_t dayOfWeek(const GameDateValue &date)
Weekday of a date, 0 = Monday ... 6 = Sunday.
Definition calendar.cpp:249
constexpr uint8_t SUNDAY
Definition calendar.h:38
constexpr uint8_t MONDAY
Definition calendar.h:32
Represents a specific date in the game world.
Definition gamedate.h:20
Days in which clubs release players to their national teams.
Definition calendar.h:70
bool summer
Definition calendar.h:74
GameDateValue end
Definition calendar.h:72
std::vector< GameDateValue > match_days
Definition calendar.h:73
GameDateValue start
Definition calendar.h:71
MatchType
Represents the type or category of a match.
Definition types.h:40
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18