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

The medical staff's day-to-day work for the managed club: rest and minute-limit instructions, the 28-day load log behind the load chart, aggravated injuries of players who play through pain and the staff's warnings in the inbox. More...

#include <medical_centre.h>

Classes

struct  LoadLog
 

Public Member Functions

std::uint8_t flags (PlayerID player_id) const
 
bool hasFlag (PlayerID player_id, MedicalFlag flag) const
 
void setFlag (PlayerID player_id, MedicalFlag flag, bool enabled)
 
bool isRested (PlayerID player_id) const
 
bool afterMatch (GameData &gamedata, const GameDateValue &date, PlayerID player_id, int minutes, bool engine_injured, TeamID managed_team_id, Inbox &inbox) const
 
void onDayEnd (GameData &gamedata, const GameDateValue &date, TeamID managed_team_id, Inbox &inbox)
 
std::array< LoadChartDay, MedicalCentre::LOAD_CHART_DAYS > loadChart (PlayerID player_id, std::int32_t today) const
 
void load (const std::shared_ptr< DatabaseConnection > &db_conn)
 
void save (const std::shared_ptr< DatabaseConnection > &db_conn) const
 

Private Member Functions

void record (PlayerID player_id, std::int32_t day, float load, float ratio)
 

Private Attributes

std::unordered_map< PlayerID, std::uint8_t > player_flags
 
std::unordered_map< PlayerID, std::int32_t > warned
 
std::unordered_map< PlayerID, LoadLog > logs
 

Detailed Description

The medical staff's day-to-day work for the managed club: rest and minute-limit instructions, the 28-day load log behind the load chart, aggravated injuries of players who play through pain and the staff's warnings in the inbox.

Persisted in MedicalFlags and MedicalLoad (assets/db/schema.sql) inside the game's save transaction.

Member Function Documentation

◆ afterMatch()

bool MedicalDesk::afterMatch ( GameData &  gamedata,
const GameDateValue &  date,
PlayerID  player_id,
int  minutes,
bool  engine_injured,
TeamID  managed_team_id,
Inbox &  inbox 
) const

A player's match was applied (WorldSimulation::applyMatchConsequences returned true). If he played carrying an injury he may aggravate it: the chance is InjuryModel::aggravationChance() for his minutes, and certain when the match engine injured him again. The layoff is drawn by InjuryModel::aggravate() and shortened by the club's medical staff.

Returns
Whether the injury was aggravated.

◆ flags()

std::uint8_t MedicalDesk::flags ( PlayerID  player_id) const

Flags of player_id (MEDICAL_FLAG_NONE when he has none).

◆ hasFlag()

bool MedicalDesk::hasFlag ( PlayerID  player_id,
MedicalFlag  flag 
) const
inline

◆ isRested()

bool MedicalDesk::isRested ( PlayerID  player_id) const
inline

Players the staff wants rested (not picked by the assistant).

◆ load()

void MedicalDesk::load ( const std::shared_ptr< DatabaseConnection > &  db_conn)

◆ loadChart()

std::array< LoadChartDay, MedicalCentre::LOAD_CHART_DAYS > MedicalDesk::loadChart ( PlayerID  player_id,
std::int32_t  today 
) const

The last LOAD_CHART_DAYS days up to today, oldest first.

◆ onDayEnd()

void MedicalDesk::onDayEnd ( GameData &  gamedata,
const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox 
)

Closes date (before the calendar moves on, so the day's training and match loads are complete): logs every managed player's load and acute:chronic ratio, forgets players who left and warns once a week per player about load spikes and players selected while injured.

◆ record()

void MedicalDesk::record ( PlayerID  player_id,
std::int32_t  day,
float  load,
float  ratio 
)
private

◆ save()

void MedicalDesk::save ( const std::shared_ptr< DatabaseConnection > &  db_conn) const

Writes the state; must run inside the caller's transaction.

◆ setFlag()

void MedicalDesk::setFlag ( PlayerID  player_id,
MedicalFlag  flag,
bool  enabled 
)

Member Data Documentation

◆ logs

std::unordered_map<PlayerID, LoadLog> MedicalDesk::logs
private

◆ player_flags

std::unordered_map<PlayerID, std::uint8_t> MedicalDesk::player_flags
private

◆ warned

std::unordered_map<PlayerID, std::int32_t> MedicalDesk::warned
private

Day of the last warning about each player.


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