Player12
An open source football management simulator
Loading...
Searching...
No Matches
MatchRules Namespace Reference

Classes

struct  FoulContext
 
struct  Knockout
 
struct  StoppageLog
 
struct  TackleContext
 

Enumerations

enum class  FoulSanction : std::uint8_t { NONE , YELLOW , SECOND_YELLOW , RED }
 

Functions

int computeAddedMinutes (const StoppageLog &log, int period)
 
float periodStartMinute (int period)
 
float periodEndMinute (int period)
 
bool shootoutDecided (int homeGoals, int homeKicks, int awayGoals, int awayKicks)
 
float computeMatchRating (const PlayerMatchStats &stats, bool goalkeeper, bool defender, int teamGoalDifference)
 
float playerHeightMetres (std::uint8_t heightCentimetres)
 
float headerReachMetres (float heightMetres, float physicality)
 
float goalkeeperReachMetres (float heightMetres, float goalkeeping)
 
float goalkeeperHandlingRadiusMetres (float heightMetres, float goalkeeping, float ballHeightMetres, bool diving)
 
float aerialDuelStrength (float heightMetres, float physicality, float ballHeightMetres)
 
FoulSanction decideFoulSanction (const FoulContext &context)
 
float tackleWinChance (const TackleContext &context)
 
float tackleFoulPropensity (const TackleContext &context)
 
float staminaDrainPerSecond (float speedRatio, float endurance, float pressingIntensity)
 

Detailed Description

Pure, deterministic rules used by the match engine. Everything here is a function of its arguments (random rolls are passed in), so each rule can be unit tested without running a match.

Enumeration Type Documentation

◆ FoulSanction

enum class MatchRules::FoulSanction : std::uint8_t
strong
Enumerator
NONE 
YELLOW 
SECOND_YELLOW 
RED 

Function Documentation

◆ aerialDuelStrength()

float MatchRules::aerialDuelStrength ( float  heightMetres,
float  physicality,
float  ballHeightMetres 
)

Relative strength of a player in an aerial duel for a ball at a height.

◆ computeAddedMinutes()

int MatchRules::computeAddedMinutes ( const StoppageLog &  log,
int  period 
)

Whole added minutes for a period (1-2, or 3-4 in extra time) from its stoppages.

◆ computeMatchRating()

float MatchRules::computeMatchRating ( const PlayerMatchStats &  stats,
bool  goalkeeper,
bool  defender,
int  teamGoalDifference 
)

Event-driven match rating: 6.0 baseline, bounded to [3, 10]. teamGoalDifference is the player's team score minus the opponent's.

◆ decideFoulSanction()

FoulSanction MatchRules::decideFoulSanction ( const FoulContext &  context)

◆ goalkeeperHandlingRadiusMetres()

float MatchRules::goalkeeperHandlingRadiusMetres ( float  heightMetres,
float  goalkeeping,
float  ballHeightMetres,
bool  diving = false 
)

Horizontal hand reach from the current body position at a ball height.

◆ goalkeeperReachMetres()

float MatchRules::goalkeeperReachMetres ( float  heightMetres,
float  goalkeeping 
)

Highest ball height (metres) a goalkeeper can claim with the hands.

◆ headerReachMetres()

float MatchRules::headerReachMetres ( float  heightMetres,
float  physicality 
)

Highest ball height (metres) an outfield player can head.

◆ periodEndMinute()

float MatchRules::periodEndMinute ( int  period)

Clock minute at which a period's regulation time ends (45, 90, 105, 120).

◆ periodStartMinute()

float MatchRules::periodStartMinute ( int  period)

Clock minute at which a period starts (0, 45, 90, 105).

◆ playerHeightMetres()

float MatchRules::playerHeightMetres ( std::uint8_t  heightCentimetres)

Player height in metres; unknown (0) heights fall back to the default.

◆ shootoutDecided()

bool MatchRules::shootoutDecided ( int  homeGoals,
int  homeKicks,
int  awayGoals,
int  awayKicks 
)

Whether a penalty shootout is decided: one side can no longer be caught within the first MatchTuning::Timing::SHOOTOUT_KICKS kicks each, or, in sudden death, the sides have taken as many kicks and one has scored more.

◆ staminaDrainPerSecond()

float MatchRules::staminaDrainPerSecond ( float  speedRatio,
float  endurance,
float  pressingIntensity 
)
inline

Match condition drained per second for a player moving at speedRatio of their fresh top speed. endurance is the Stamina attribute in [0, 1].

◆ tackleFoulPropensity()

float MatchRules::tackleFoulPropensity ( const TackleContext &  context)

Propensity for the challenge to be a foul: applied in full to a missed challenge and scaled down for one that also reached the ball.

◆ tackleWinChance()

float MatchRules::tackleWinChance ( const TackleContext &  context)

Chance that a challenge reaches the ball first.