|
Player12
An open source football management simulator
|
Represents the core game state and logic. More...
#include <game.h>
Classes | |
| struct | CupRun |
Public Member Functions | |
| Game (std::shared_ptr< class GameData > gd, std::shared_ptr< DatabaseConnection > conn) | |
| Constructs a new Game object. | |
| void | advanceDay () |
| Advances the game time by one day, simulating any matches or events scheduled for the current date. | |
| bool | setMatchResult (const GameDateValue &date, TeamID home_id, TeamID away_id, uint8_t home_score, uint8_t away_score) |
| bool | setMatchResult (const GameDateValue &date, TeamID home_id, TeamID away_id, MatchReport report, std::span< const PlayerMatchConsequence > consequences={}) |
| bool | isEligible (const Player &player, MatchType type, std::optional< GameDateValue > date=std::nullopt) const |
| std::vector< PlayerID > | ineligibleSelections (TeamID team_id, MatchType type) const |
| std::size_t | fixMatchdaySquad (TeamID team_id, MatchType type, std::optional< GameDateValue > date=std::nullopt) |
| std::vector< std::pair< PlayerID, PlayerID > > | previewMatchdaySquadFix (TeamID team_id, MatchType type) const |
| bool | canKickOff (TeamID team_id, MatchType type) const |
| void | setAssistantFixesLineup (bool enabled) |
| bool | getAssistantFixesLineup () const |
| CareerGuidance & | getGuidance () |
| const CareerGuidance & | getGuidance () const |
| MedicalDesk & | getMedical () |
| const MedicalDesk & | getMedical () const |
| const Supporters & | getSupporters () const |
| const CompetitionManager & | getCompetitions () const |
| const SeasonArchive & | getSeasonArchive () const |
| SeasonArchive & | getSeasonArchive () |
| int | youngRegulars (TeamID team_id) const |
| CupRun | cupRun (TeamID team_id) const |
| const NationalTeams & | getNationalTeams () const |
| NationalTeams & | getNationalTeams () |
| NationalManagement & | getNationalJob () |
| const NationalManagement & | getNationalJob () const |
| const NationalDayEvents & | getLastNationalEvents () const |
| WorldSimulation & | getWorld () |
| const WorldSimulation & | getWorld () const |
| TransferMarket & | getTransfers () |
| const TransferMarket & | getTransfers () const |
| ManagerCareer & | getCareer () |
| const ManagerCareer & | getCareer () const |
| const CareerDayEvents & | getLastCareerEvents () const |
| void | leaveManagedTeam (DepartureReason reason) |
| void | takeJob (TeamID team_id, const ManagerContract &contract) |
| SimulationProgress | getSimulationProgress () const |
| void | resetSimulationProgress () |
| void | setSimulationThreads (unsigned threads) |
| unsigned | getSimulationThreads () const |
| const GameDateValue & | getCurrentDate () const |
| Retrieves the current in-game date. | |
| const Calendar & | getCalendar () const |
| Retrieves the calendar containing all fixtures. | |
| Calendar & | getCalendar () |
| int | getCurrentSeason () const |
| Retrieves the current season number. | |
| uint16_t | getManagedTeamId () const |
| Retrieves the ID of the team currently managed by the user. | |
| void | setManagedTeamId (uint16_t id) |
| Sets the team managed by the user. | |
| void | saveGame () |
| Saves the current game state, including calendar and game variables, to the database. | |
Private Member Functions | |
| void | loadGame () |
| void | endSeason () |
| void | handleSeasonTransition () |
| void | startNewSeason () |
| void | beginSeasonReview (const std::map< LeagueID, std::vector< StandingRow > > &final_tables, std::uint16_t start_year) |
| void | judgeSeason (std::span< const SeasonHistoryEntry > finished) |
| void | finishSeasonReview () |
| void | fillLineupGap (Team &team, const Player &departed) |
| void | postLineupRepairs () |
| std::vector< UpcomingFixture > | upcomingFixtures (TeamID team_id) const |
| void | keepManagedSelectionEligible () |
| std::size_t | fillMatchdaySquad (Lineup &lineup, TeamID team_id, MatchType type, const GameDateValue &date, bool recall_regulars) const |
| void | runCareerDay () |
| void | recordCareerMatch (const Match &match) |
| void | simulateMatches (std::vector< Match > &matches, bool include_managed=false) |
| void | settleLevelTie (Match &match, MatchReport &report) |
| void | discoverExtensions () |
| void | serialize (bool probe) |
Private Attributes | |
| std::shared_ptr< DatabaseConnection > | db_conn |
| std::unique_ptr< RuntimeEditor::Extensions > | extensions |
| int | extensions_version = -1 |
| RuntimeEditor::Payloads | payload_extensions |
| std::shared_ptr< class GameData > | gamedata |
| Calendar | calendar |
| CompetitionManager | competitions |
| WorldSimulation | world |
| TransferMarket | transfers |
| ManagerCareer | career |
| CareerDayEvents | last_career_events |
| NationalTeams | international |
| NationalManagement | national_job |
| NationalDayEvents | last_national_events |
| MatchScheduler | scheduler |
| GameDateValue | currentDate = START_DATE |
| uint8_t | current_season = 1 |
| uint16_t | managed_team_id |
| CareerGuidance | guidance |
| MedicalDesk | medical |
| Supporters | supporters |
| SeasonArchive | season_archive |
| std::optional< SeasonReview > | closing_review |
| std::vector< std::pair< std::string, std::string > > | lineup_repairs |
Represents the core game state and logic.
The Game class orchestrates the simulation mechanics, handling the progression of time, saving and loading the game state, and triggering match simulations.
|
explicit |
Constructs a new Game object.
| gd | Shared pointer to the GameData instance. |
| conn | Shared pointer to the DatabaseConnection. |
| void Game::advanceDay | ( | ) |
Advances the game time by one day, simulating any matches or events scheduled for the current date.
|
private |
The managed club's season numbers, read from the final tables before promotion and relegation move the clubs.
Whether the club's selection may kick off as it is: it is exactly what fixMatchdaySquad() would pick, so players still listed by ineligibleSelections() are injured players nobody fit can replace.
| Game::CupRun Game::cupRun | ( | TeamID | team_id | ) | const |
|
private |
|
private |
Takes a departing managed player out of the line-up, filling only his place, and notes the change for postLineupRepairs().
|
private |
fixMatchdaySquad() applied to lineup, a selection of team_id; without recall_regulars recovered regulars stay where they are (the selection is only made eligible).
|
private |
Archives the review with next season's objectives.
| std::size_t Game::fixMatchdaySquad | ( | TeamID | team_id, |
| MatchType | type, | ||
| std::optional< GameDateValue > | date = std::nullopt |
||
| ) |
The assistant's matchday selection: regulars fit again take back their places from the players who stood in for them, then ineligible players are replaced by the best-fitting eligible squad and academy players, then by trialists, and the replacements are noted as stand-ins (Lineup::getStandIns()). When nobody fit is left for a starting place, injured players play through it (the least injured first), so a side always takes the field; players who may not play at all (suspended, on national duty) and cannot be replaced leave the XI and the side plays with the players it has. Availability is judged on date (default: today). Returns how many selections changed.
|
inline |
| Calendar & Game::getCalendar | ( | ) |
| const Calendar & Game::getCalendar | ( | ) | const |
Retrieves the calendar containing all fixtures.
|
inline |
The human manager's career and the market for managers.
|
inline |
|
inline |
Standings, cups, reports, player season stats and season history.
| const GameDateValue & Game::getCurrentDate | ( | ) | const |
Retrieves the current in-game date.
| int Game::getCurrentSeason | ( | ) | const |
Retrieves the current season number.
|
inline |
Checklist, delegation, opposition instructions, match analytics.
|
inline |
|
inline |
What the manager market did on the latest simulated day.
|
inline |
What the national-job market did on the latest simulated day.
| uint16_t Game::getManagedTeamId | ( | ) | const |
Retrieves the ID of the team currently managed by the user.
|
inline |
Rest and minute-limit flags, load log and warnings of the physios.
|
inline |
|
inline |
The manager's national-team job and the market for national jobs.
|
inline |
|
inline |
|
inline |
National teams: calendar, call-ups, finals, caps.
|
inline |
|
inline |
Final tables of past seasons and the managed club's season reviews.
|
inline |
Matches simulated / scheduled so far in the current advanceDay(). Safe to poll from another thread while advanceDay() runs.
|
inline |
|
inline |
The managed club's supporters and their weekly mood.
|
inline |
Deals, loans, pre-contracts, scheduled payments and transfer history.
|
inline |
|
inline |
Inbox, board, injuries, finances and development between matches.
|
inline |
|
private |
Selected players of a club who may not play a match of type.
| bool Game::isEligible | ( | const Player & | player, |
| MatchType | type, | ||
| std::optional< GameDateValue > | date = std::nullopt |
||
| ) | const |
Fit (not injured), outside friendlies not suspended for type, and not away with his national team on date (default: today).
|
private |
Outcome, board verdict and season news once the clubs have moved.
|
private |
Replaces unavailable managed players for the next managed fixture.
| void Game::leaveManagedTeam | ( | DepartureReason | reason | ) |
The manager leaves the managed club (sacked, resigned, contract expired, or moving on): the club gets a vacancy and an AI manager in due course, its board, shortlist, transfer talks and offers are dropped and no command reaches it any more. The inbox stays.
|
private |
|
private |
Tells the manager which starting places were filled.
| std::vector< std::pair< PlayerID, PlayerID > > Game::previewMatchdaySquadFix | ( | TeamID | team_id, |
| MatchType | type | ||
| ) | const |
What fixMatchdaySquad() would change: (replaced, replacement or 0).
|
private |
Job security of AI managers and the human's record.
|
inline |
|
private |
Manager market day and the board's verdict on the manager.
| void Game::saveGame | ( | ) |
Saves the current game state, including calendar and game variables, to the database.
|
private |
|
inline |
Whether the assistant keeps the managed selection eligible: after each day, and at kick-off, injured or suspended players are replaced.
| void Game::setManagedTeamId | ( | uint16_t | id | ) |
Sets the team managed by the user.
Taking charge of a new club sets the board's objective and budgets immediately and posts the day-one inbox (welcome, squad report, pre-season schedule, scouting suggestion).
| id | The ID of the team to manage. |
| bool Game::setMatchResult | ( | const GameDateValue & | date, |
| TeamID | home_id, | ||
| TeamID | away_id, | ||
| MatchReport | report, | ||
| std::span< const PlayerMatchConsequence > | consequences = {} |
||
| ) |
Records a managed match with its structured report (e.g. built from the live MatchEngine). A drawn cup tie is settled by extra time and penalties unless the report already carries them. consequences (MatchdaySquad::consequences of the engine) apply the measured condition and injuries exactly as for simulated matches.
| bool Game::setMatchResult | ( | const GameDateValue & | date, |
| TeamID | home_id, | ||
| TeamID | away_id, | ||
| uint8_t | home_score, | ||
| uint8_t | away_score | ||
| ) |
Records a managed match exactly once and applies its consequences.
|
inline |
Threads used to simulate a matchday (1 = one match after another).
|
private |
Fallback for a knockout tie recorded level without extra time (a score-only result, or a match abandoned before the engine could settle it): extra time and penalties are resolved from the squads and the extra-time goals credited to players who finished the match.
|
private |
|
private |
| void Game::takeJob | ( | TeamID | team_id, |
| const ManagerContract & | contract | ||
| ) |
The manager takes charge of team_id under contract (leaving the current club first): the board sets objectives and budgets for the new club, scouting starts afresh and the club's squad, line-up, tactics and training plan become the manager's.
|
private |
The club's fixtures from today up to its first competitive match.
| int Game::youngRegulars | ( | TeamID | team_id | ) | const |
Squad players aged 21 or under with ten or more appearances.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Starting places filled at the season end: (departed, replacement).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |