Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_report.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 <cstdint>
12#include <optional>
13#include <string>
14#include <vector>
15
16#include "gamedate.h"
17#include "global/types.h"
18
19class Lineup;
20class MatchEngine;
21
23enum class MatchEventKind : uint8_t
24{
25 GOAL = 0,
26 OWN_GOAL = 1,
27 YELLOW_CARD = 3,
28 RED_CARD = 4,
29 SECOND_YELLOW = 5
30};
31
48
51{
52 uint16_t shots = 0;
53 uint16_t shots_on_target = 0;
54 uint16_t corners = 0;
55 uint16_t fouls = 0;
56 uint16_t yellow_cards = 0;
57 uint16_t red_cards = 0;
58 uint16_t offsides = 0;
59 uint16_t saves = 0;
60 uint16_t passes_attempted = 0;
61 uint16_t passes_completed = 0;
62 float possession = 50.0f;
63 float expected_goals = 0.0f;
66 bool set_pieces_known = false;
67 uint16_t set_piece_shots = 0;
68 uint16_t set_piece_goals = 0;
69};
70
73{
76 bool started = true;
77 uint8_t minutes = 0;
78 uint8_t goals = 0;
79 uint8_t assists = 0;
80 uint8_t yellow_cards = 0;
81 uint8_t red_cards = 0;
82 float rating = 0.0f;
83};
84
93{
99 uint8_t stage = 0;
100 uint16_t season = 0;
101 uint8_t home_goals = 0;
102 uint8_t away_goals = 0;
103 bool extra_time = false;
104 bool penalties = false;
105 uint8_t home_penalties = 0;
106 uint8_t away_penalties = 0;
107 uint32_t attendance = 0;
110 std::vector<MatchReportEvent> events;
111 std::vector<PlayerMatchLine> players;
117 std::optional<bool> played_home;
118 float played_share = 0.0f;
119
124 void fillFromEngine(const MatchEngine& engine, TeamID home_id,
125 TeamID away_id);
126
131 void addLineupAppearances(const Lineup& lineup, TeamID team_id);
132
142 void creditExtraTimeGoals(const Lineup& lineup, TeamID team_id, bool home,
143 uint8_t goals, uint32_t seed);
144
145 std::string eventsToJson() const;
146 std::string playersToJson() const;
147 std::string statsToJson() const;
148 void eventsFromJson(const std::string& json);
149 void playersFromJson(const std::string& json);
150 void statsFromJson(const std::string& json);
151};
Manages the starting XI and reserves of a team.
Definition lineup.h:85
Definition match_engine.h:517
nlohmann::json json
Definition datagenerator.cpp:38
MatchEventKind
Kind of a structured, persisted match event.
Definition match_report.h:24
Represents a specific date in the game world.
Definition gamedate.h:20
One structured event of a finished match (scorer, card...).
Definition match_report.h:40
bool home
Definition match_report.h:44
PlayerID assist
Definition match_report.h:46
uint8_t added_minute
Definition match_report.h:42
MatchEventKind kind
Definition match_report.h:43
PlayerID player
Definition match_report.h:45
uint8_t minute
Definition match_report.h:41
Structured summary of a played fixture, persisted per fixture.
Definition match_report.h:93
TeamMatchStats away_stats
Definition match_report.h:109
std::string playersToJson() const
Definition match_report.cpp:337
std::vector< PlayerMatchLine > players
Definition match_report.h:111
TeamID away_team_id
Definition match_report.h:96
void eventsFromJson(const std::string &json)
Definition match_report.cpp:364
void playersFromJson(const std::string &json)
Definition match_report.cpp:383
uint8_t home_goals
Definition match_report.h:101
bool extra_time
Definition match_report.h:103
uint8_t home_penalties
Definition match_report.h:105
std::vector< MatchReportEvent > events
Definition match_report.h:110
std::string statsToJson() const
Definition match_report.cpp:355
std::string eventsToJson() const
Definition match_report.cpp:322
void creditExtraTimeGoals(const Lineup &lineup, TeamID team_id, bool home, uint8_t goals, uint32_t seed)
Definition match_report.cpp:268
TeamMatchStats home_stats
Definition match_report.h:108
uint8_t away_penalties
Definition match_report.h:106
uint8_t stage
Definition match_report.h:99
float played_share
Definition match_report.h:118
bool penalties
Definition match_report.h:104
void fillFromEngine(const MatchEngine &engine, TeamID home_id, TeamID away_id)
Definition match_report.cpp:128
uint16_t season
Definition match_report.h:100
uint32_t attendance
Definition match_report.h:107
void addLineupAppearances(const Lineup &lineup, TeamID team_id)
Definition match_report.cpp:246
TeamID home_team_id
Definition match_report.h:95
uint8_t away_goals
Definition match_report.h:102
GameDateValue date
Definition match_report.h:94
MatchType match_type
Definition match_report.h:97
std::optional< bool > played_home
Definition match_report.h:117
LeagueID competition_id
Definition match_report.h:98
void statsFromJson(const std::string &json)
Definition match_report.cpp:405
Per-player line of a finished match.
Definition match_report.h:73
TeamID team_id
Definition match_report.h:75
bool started
Definition match_report.h:76
uint8_t goals
Definition match_report.h:78
float rating
Definition match_report.h:82
uint8_t red_cards
Definition match_report.h:81
uint8_t yellow_cards
Definition match_report.h:80
uint8_t assists
Definition match_report.h:79
uint8_t minutes
Definition match_report.h:77
PlayerID player_id
Definition match_report.h:74
Team totals of a finished match.
Definition match_report.h:51
float expected_goals
Definition match_report.h:63
bool set_pieces_known
Definition match_report.h:66
float possession
Definition match_report.h:62
uint16_t corners
Definition match_report.h:54
uint16_t set_piece_shots
Definition match_report.h:67
uint16_t set_piece_goals
Definition match_report.h:68
uint16_t passes_attempted
Definition match_report.h:60
uint16_t red_cards
Definition match_report.h:57
uint16_t fouls
Definition match_report.h:55
uint16_t shots_on_target
Definition match_report.h:53
uint16_t shots
Definition match_report.h:52
uint16_t yellow_cards
Definition match_report.h:56
uint16_t offsides
Definition match_report.h:58
uint16_t passes_completed
Definition match_report.h:61
uint16_t saves
Definition match_report.h:59
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
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21