Player12
An open source football management simulator
Loading...
Searching...
No Matches
competition_view.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 <optional>
14#include <string>
15#include <vector>
16
17#include "global/types.h"
18#include "gui/widgets/widgets.h"
19#include "model/gamedate.h"
20
21class GameController;
22
29namespace CompetitionView
30{
31
32constexpr size_t FORM_LENGTH = 5;
33
36{
38 std::string name;
39 int played = 0;
40 int won = 0;
41 int drawn = 0;
42 int lost = 0;
43 int goals_for = 0;
45 int points = 0;
46 std::array<UI::Outcome, FORM_LENGTH> form{};
47 uint8_t form_count = 0;
49 [[nodiscard]] int goalDifference() const { return goals_for - goals_against; }
50};
51
54{
58 std::string home_name;
59 std::string away_name;
61 bool played = false;
62 uint8_t home_score = 0;
63 uint8_t away_score = 0;
64 int round = 0;
65 uint16_t kickoff = 0;
66};
67
69struct Zones
70{
71 size_t promotion = 0;
72 size_t relegation = 0;
73};
74
79std::vector<StandingRow> buildStandings(const GameController& controller,
80 LeagueID leagueId);
81
83Zones zonesFor(const GameController& controller, LeagueID leagueId);
84
86std::vector<FixtureRow> buildLeagueFixtures(const GameController& controller,
87 LeagueID leagueId);
88
90std::vector<FixtureRow> buildClubFixtures(const GameController& controller,
91 TeamID teamId);
92
94std::optional<FixtureRow> nextFixture(const GameController& controller,
95 TeamID teamId);
96
98const char* matchTypeKey(MatchType type);
99
101UI::Outcome outcomeFor(const FixtureRow& fixture, TeamID teamId);
102
103} // namespace CompetitionView
Manages the core game logic, interacting with teams, leagues, and players.
Definition game_controller.h:70
Read-only view models for league tables and fixture lists.
Definition competition_view.cpp:58
std::vector< FixtureRow > buildLeagueFixtures(const GameController &controller, LeagueID leagueId)
All league fixtures of a league in date order, with rounds.
Definition competition_view.cpp:122
constexpr size_t FORM_LENGTH
Definition competition_view.h:32
Zones zonesFor(const GameController &controller, LeagueID leagueId)
Promotion (top) and relegation (bottom) places of a league.
Definition competition_view.cpp:93
std::optional< FixtureRow > nextFixture(const GameController &controller, TeamID teamId)
The club's next unplayed fixture on or after the current date.
Definition competition_view.cpp:152
std::vector< FixtureRow > buildClubFixtures(const GameController &controller, TeamID teamId)
Every fixture (all competitions) of one club in date order.
Definition competition_view.cpp:138
const char * matchTypeKey(MatchType type)
Localisation key naming a competition type.
Definition competition_view.cpp:171
std::vector< StandingRow > buildStandings(const GameController &controller, LeagueID leagueId)
League table for one league in the competitions model's order (points, goal difference,...
Definition competition_view.cpp:60
UI::Outcome outcomeFor(const FixtureRow &fixture, TeamID teamId)
Outcome of a played fixture from one club's perspective.
Definition competition_view.cpp:188
Outcome
Match outcome for form strips.
Definition widgets.h:87
One scheduled or played match.
Definition competition_view.h:54
uint8_t away_score
Definition competition_view.h:63
bool played
Definition competition_view.h:61
std::string away_name
Definition competition_view.h:59
TeamID away_id
Definition competition_view.h:57
uint16_t kickoff
Definition competition_view.h:65
MatchType type
Definition competition_view.h:60
uint8_t home_score
Definition competition_view.h:62
int round
Definition competition_view.h:64
GameDateValue date
Definition competition_view.h:55
TeamID home_id
Definition competition_view.h:56
std::string home_name
Definition competition_view.h:58
One row of a league table.
Definition competition_view.h:36
int goals_for
Definition competition_view.h:43
int won
Definition competition_view.h:40
int drawn
Definition competition_view.h:41
std::string name
Definition competition_view.h:38
int goalDifference() const
Definition competition_view.h:49
int lost
Definition competition_view.h:42
int goals_against
Definition competition_view.h:44
uint8_t form_count
Definition competition_view.h:47
std::array< UI::Outcome, FORM_LENGTH > form
Definition competition_view.h:46
int played
Definition competition_view.h:39
int points
Definition competition_view.h:45
TeamID team_id
Definition competition_view.h:37
Number of promotion and relegation places in a league table.
Definition competition_view.h:70
size_t promotion
Definition competition_view.h:71
size_t relegation
Definition competition_view.h:72
Represents a specific date in the game world.
Definition gamedate.h:20
MatchType
Represents the type or category of a match.
Definition types.h:40
uint8_t LeagueID
Type alias for League identifiers.
Definition types.h:15
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18