Player12
An open source football management simulator
Loading...
Searching...
No Matches
data_hub.h File Reference
#include <array>
#include <cstdint>
#include <optional>
#include <span>
#include <string>
#include <utility>
#include <vector>
#include "global/types.h"
#include "model/gamedate.h"
#include "model/match_analysis.h"
#include "model/match_insights.h"
#include "model/match_report.h"

Go to the source code of this file.

Classes

struct  PlayerMatchSnapshot
 Pass and shot involvement of a managed player in one match. More...
 
struct  ManagedMatchSnapshot
 Detail of a managed match that the persisted report does not keep: shot positions, set pieces and per-player passing. Captured from the live engine when the result is recorded. Index 0 of the arrays is the managed club, 1 the opponent. More...
 
struct  TeamTrendPoint
 One played match of the analysed club. More...
 
struct  MetricComparison
 The club's value against the league average and its rank. More...
 
struct  SetPieceSummary
 Set-piece shots and goals in tracked (snapshot) matches. More...
 
struct  TeamAnalytics
 Team analytics of the data hub. More...
 
struct  PlayerAnalyticsRow
 One player of the analysed club. More...
 
struct  DataHubInput
 Everything the data hub aggregates. More...
 

Namespaces

namespace  DataHub
 

Enumerations

enum class  HubMetric : std::uint8_t {
  GoalsFor = 0 , GoalsAgainst , XgFor , XgAgainst ,
  ShotsFor , ShotsAgainst , PassCompletion , Finishing ,
  GoalsPrevented , SetPieceShare , COUNT
}
 Metrics compared with the league (per team and match). More...
 
enum class  LeaderMetric : std::uint8_t {
  ExpectedGoals = 0 , ExpectedAssists , ProgressivePasses , Pressures ,
  COUNT
}
 Player leaderboards of the data hub. More...
 

Functions

ManagedMatchSnapshot captureSnapshot (const MatchEngine &engine, const GameDateValue &date, TeamID home_id, TeamID away_id, bool managed_home)
 
TeamAnalytics DataHub::buildTeamAnalytics (const DataHubInput &input)
 
std::vector< PlayerAnalyticsRow > DataHub::buildPlayerAnalytics (const DataHubInput &input)
 
bool DataHub::hasStatistics (const MatchReport &report)
 
float DataHub::leaderValue (const PlayerAnalyticsRow &row, LeaderMetric metric)
 
int DataHub::leaderMinutes (const PlayerAnalyticsRow &row, LeaderMetric metric)
 
std::vector< std::size_t > DataHub::leaders (std::span< const PlayerAnalyticsRow > rows, LeaderMetric metric)
 
const char * leaderMetricKey (LeaderMetric metric)
 
const char * hubMetricKey (HubMetric metric)
 
const char * hubMetricHelpKey (HubMetric metric)
 

Variables

constexpr std::size_t HUB_METRIC_COUNT
 
constexpr int DataHub::MIN_MATCHES = 3
 
constexpr std::size_t DataHub::ROLLING_WINDOW = 5
 
constexpr std::size_t DataHub::RATING_HISTORY = 10
 
constexpr std::size_t LEADER_METRIC_COUNT
 
constexpr std::size_t DataHub::LEADERS = 5
 
constexpr int DataHub::LEADER_MIN_MINUTES = 90
 

Enumeration Type Documentation

◆ HubMetric

enum class HubMetric : std::uint8_t
strong

Metrics compared with the league (per team and match).

Enumerator
GoalsFor 
GoalsAgainst 
XgFor 
XgAgainst 
ShotsFor 
ShotsAgainst 
PassCompletion 
Finishing 

Goals minus xG per match (finishing above or below the chances).

GoalsPrevented 

Goals a league-average keeper would have conceded from the shots on target faced, minus those conceded, per match.

SetPieceShare 

Share of the shots that came from set pieces.

COUNT 

◆ LeaderMetric

enum class LeaderMetric : std::uint8_t
strong

Player leaderboards of the data hub.

Enumerator
ExpectedGoals 
ExpectedAssists 
ProgressivePasses 
Pressures 
COUNT 

Function Documentation

◆ captureSnapshot()

ManagedMatchSnapshot captureSnapshot ( const MatchEngine &  engine,
const GameDateValue &  date,
TeamID  home_id,
TeamID  away_id,
bool  managed_home 
)

Captures the snapshot of a finished (or running) live match.

◆ hubMetricHelpKey()

const char * hubMetricHelpKey ( HubMetric  metric)

◆ hubMetricKey()

const char * hubMetricKey ( HubMetric  metric)

Language key of a metric's name / definition.

◆ leaderMetricKey()

const char * leaderMetricKey ( LeaderMetric  metric)

Variable Documentation

◆ HUB_METRIC_COUNT

constexpr std::size_t HUB_METRIC_COUNT
inlineconstexpr
Initial value:
=
static_cast<std::size_t>(std::to_underlying(HubMetric::COUNT))

◆ LEADER_METRIC_COUNT

constexpr std::size_t LEADER_METRIC_COUNT
inlineconstexpr
Initial value:
=
static_cast<std::size_t>(std::to_underlying(LeaderMetric::COUNT))