Player12
An open source football management simulator
Loading...
Searching...
No Matches
Discipline Class Reference

Yellow-card accumulation and red-card suspensions. More...

#include <discipline.h>

Public Member Functions

 Discipline (DisciplineRules competition_rules={})
 
void processMatch (const MatchReport &report, const GameData &gamedata)
 Serves one match of every ban of the two teams, then books the cards of this match (so a red card is not served by the same match).
 
bool isSuspended (PlayerID player_id, MatchType scope) const
 
uint8_t banMatches (PlayerID player_id, MatchType scope) const
 
std::vector< DisciplinaryRecord > suspendedPlayers (TeamID team_id, const GameData &gamedata) const
 
void resetSeason ()
 
std::vector< DisciplinaryRecord > records () const
 
void restore (const std::vector< DisciplinaryRecord > &stored)
 

Private Types

using Key = std::pair< PlayerID, MatchType >
 

Private Member Functions

void book (DisciplinaryRecord &record, unsigned yellows, unsigned reds) const
 

Private Attributes

DisciplineRules rules
 
std::map< Key, DisciplinaryRecord > by_player
 
std::set< Key > active_bans
 

Detailed Description

Yellow-card accumulation and red-card suspensions.

League and cup are separate scopes: cards collected in one are served in the same competition type. Friendlies never count. Card counts reset every season; outstanding bans carry over.

Member Typedef Documentation

◆ Key

using Discipline::Key = std::pair<PlayerID, MatchType>
private

Constructor & Destructor Documentation

◆ Discipline()

Discipline::Discipline ( DisciplineRules  competition_rules = {})
inlineexplicit

Member Function Documentation

◆ banMatches()

uint8_t Discipline::banMatches ( PlayerID  player_id,
MatchType  scope 
) const

◆ book()

void Discipline::book ( DisciplinaryRecord &  record,
unsigned  yellows,
unsigned  reds 
) const
private

◆ isSuspended()

bool Discipline::isSuspended ( PlayerID  player_id,
MatchType  scope 
) const

◆ processMatch()

void Discipline::processMatch ( const MatchReport &  report,
const GameData &  gamedata 
)

Serves one match of every ban of the two teams, then books the cards of this match (so a red card is not served by the same match).

◆ records()

std::vector< DisciplinaryRecord > Discipline::records ( ) const

◆ resetSeason()

void Discipline::resetSeason ( )

Clears the season card counts; outstanding bans are kept.

◆ restore()

void Discipline::restore ( const std::vector< DisciplinaryRecord > &  stored)

◆ suspendedPlayers()

std::vector< DisciplinaryRecord > Discipline::suspendedPlayers ( TeamID  team_id,
const GameData &  gamedata 
) const

Players of a team with an outstanding ban (any scope).

Member Data Documentation

◆ active_bans

std::set<Key> Discipline::active_bans
private

Records with ban_matches > 0, so serving bans skips everyone else.

◆ by_player

std::map<Key, DisciplinaryRecord> Discipline::by_player
private

◆ rules

DisciplineRules Discipline::rules
private

The documentation for this class was generated from the following files: