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

Statuses the manager gave players of his club. More...

#include <squad_status.h>

Classes

struct  Entry
 

Public Member Functions

void set (PlayerID player_id, TeamID team_id, std::optional< SquadStatus > status)
 
std::optional< SquadStatus > get (PlayerID player_id, TeamID current_team_id) const
 
std::size_t size () const
 
template<typename TeamOf >
void prune (TeamOf &&team_of)
 
void load (const DatabaseConnection &db_conn)
 
void save (const DatabaseConnection &db_conn) const
 

Private Attributes

std::unordered_map< PlayerID, Entry > entries
 

Detailed Description

Statuses the manager gave players of his club.

An entry only counts while the player is still at the club that set it, so transfers and a change of club reset statuses without bookkeeping.

Member Function Documentation

◆ get()

std::optional< SquadStatus > SquadStatusBook::get ( PlayerID  player_id,
TeamID  current_team_id 
) const

Status of a player who still plays for current_team_id.

◆ load()

void SquadStatusBook::load ( const DatabaseConnection &  db_conn)

Replaces the book with the SquadStatuses table.

◆ prune()

template<typename TeamOf >
void SquadStatusBook::prune ( TeamOf &&  team_of)
inline

Drops entries whose player no longer plays for the club that set them.

◆ save()

void SquadStatusBook::save ( const DatabaseConnection &  db_conn) const

Rewrites the SquadStatuses table (inside the caller's transaction).

◆ set()

void SquadStatusBook::set ( PlayerID  player_id,
TeamID  team_id,
std::optional< SquadStatus >  status 
)

Sets (or with nullopt clears) the status of a player of team_id.

◆ size()

std::size_t SquadStatusBook::size ( ) const
inline

Number of stored entries (stale ones included until pruned).

Member Data Documentation

◆ entries

std::unordered_map<PlayerID, Entry> SquadStatusBook::entries
private

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