Player12
An open source football management simulator
Loading...
Searching...
No Matches
standings_race.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <array>
12#include <cstdint>
13#include <string>
14#include <vector>
15
16#include "global/types.h"
17#include "model/league.h"
18
19class Calendar;
21class GameData;
22
34namespace Standings
35{
38{
41 bool played = false;
42 uint8_t home_goals = 0;
43 uint8_t away_goals = 0;
44};
45
48{
49 std::vector<TeamID> teams;
50 std::vector<std::string> names;
51 std::vector<RaceFixture> fixtures;
53};
54
62{
63 uint16_t promotion = 0;
64 uint16_t play_off = 0;
65 uint16_t continental_top = 0;
66 uint16_t continental = 0;
67 uint16_t relegation = 0;
68};
69
71enum class Race : uint8_t
72{
73 TITLE,
79};
80inline constexpr size_t RACE_COUNT = 6;
81
82enum class RaceState : uint8_t
83{
84 NONE,
85 OPEN,
86 SECURED,
87 LOST
88};
89
91enum class Clinch : uint8_t
92{
93 OPEN,
99 SAFE,
101};
102
105{
107 std::array<RaceState, RACE_COUNT> races{};
109};
110
113{
114 enum class Kind : uint8_t
115 {
116 IN_HANDS,
118 };
121 uint16_t points = 0;
122 uint16_t games_left = 0;
124 bool next_at_home = false;
125};
126
128uint16_t raceCutoff(Race race, const RacePlaces& places, size_t clubs);
129
131ClinchReport clinchReport(const RaceInput& input, const RacePlaces& places,
132 TeamID team);
133
135Clinch clinchStatus(const RaceInput& input, const RacePlaces& places,
136 TeamID team);
137
139std::vector<ClinchReport> clinchReports(const RaceInput& input,
140 const RacePlaces& places);
141
149std::vector<RaceNeed> whatYouNeed(const RaceInput& input,
150 const RacePlaces& places, TeamID team);
151inline constexpr uint16_t MAX_NEED_GAMES = 6;
152
154RaceInput raceInput(const League& league, const Calendar& calendar,
155 const GameData& gamedata);
156
163RacePlaces racePlaces(const GameData& gamedata,
164 const ContinentalCompetitions* continental,
165 LeagueID league_id);
166} // namespace Standings
Manages the match calendar for a season.
Definition calendar.h:133
Seasons, draws, knockouts, prize money and coefficients of the continental club competitions.
Definition continental.h:238
Singleton class that acts as an in-memory cache for the database state.
Definition gamedata.h:43
Represents a football league containing teams and a leaderboard.
Definition league.h:41
TieBreakRule
How teams level on points are ordered (varies by country).
Definition league.h:24
Run-in maths of a league table: which outcomes are mathematically decided (title, promotion,...
Definition standings.h:42
constexpr size_t RACE_COUNT
Definition standings_race.h:80
Clinch clinchStatus(const RaceInput &input, const RacePlaces &places, TeamID team)
Definition standings_race.cpp:721
RaceState
Definition standings_race.h:83
constexpr uint16_t MAX_NEED_GAMES
Definition standings_race.h:151
RaceInput raceInput(const League &league, const Calendar &calendar, const GameData &gamedata)
Definition standings_race.cpp:801
std::vector< RaceNeed > whatYouNeed(const RaceInput &input, const RacePlaces &places, TeamID team)
What team needs in its still open races, most ambitious first.
Definition standings_race.cpp:738
Race
Definition standings_race.h:72
uint16_t raceCutoff(Race race, const RacePlaces &places, size_t clubs)
Definition standings_race.cpp:672
Clinch
Definition standings_race.h:92
ClinchReport clinchReport(const RaceInput &input, const RacePlaces &places, TeamID team)
Definition standings_race.cpp:706
std::vector< ClinchReport > clinchReports(const RaceInput &input, const RacePlaces &places)
Definition standings_race.cpp:727
RacePlaces racePlaces(const GameData &gamedata, const ContinentalCompetitions *continental, LeagueID league_id)
Deciding places of a league: promotion and relegation as the season-end movements apply them; contine...
Definition standings_race.cpp:838
Definition standings_race.h:105
TeamID team_id
Definition standings_race.h:106
std::array< RaceState, RACE_COUNT > races
Definition standings_race.h:107
Clinch status
Definition standings_race.h:108
Definition standings_race.h:38
uint8_t home_goals
Definition standings_race.h:42
TeamID away_id
Definition standings_race.h:40
bool played
Definition standings_race.h:41
TeamID home_id
Definition standings_race.h:39
uint8_t away_goals
Definition standings_race.h:43
Definition standings_race.h:48
std::vector< TeamID > teams
Definition standings_race.h:49
TieBreakRule rule
Definition standings_race.h:52
std::vector< std::string > names
Definition standings_race.h:50
std::vector< RaceFixture > fixtures
Definition standings_race.h:51
Definition standings_race.h:113
Kind kind
Definition standings_race.h:120
bool next_at_home
Definition standings_race.h:124
Kind
Definition standings_race.h:115
uint16_t games_left
Definition standings_race.h:122
TeamID next_opponent
Definition standings_race.h:123
uint16_t points
Definition standings_race.h:121
Race race
Definition standings_race.h:119
Table places that decide something. Promotion, play-off and continental places count from the top (pl...
Definition standings_race.h:62
uint16_t promotion
Definition standings_race.h:63
uint16_t continental
Definition standings_race.h:66
uint16_t play_off
Definition standings_race.h:64
uint16_t relegation
Definition standings_race.h:67
uint16_t continental_top
Definition standings_race.h:65
uint8_t LeagueID
Type alias for League identifiers.
Definition types.h:15
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18