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

Represents a football team. More...

#include <team.h>

Public Member Functions

 Team (TeamID team_id, uint8_t team_league_id, std::string_view team_name, int64_t initial_balance, const std::vector< PlayerID > &initial_player_ids={}, const Strategy &strategy=Strategy{}, const Lineup &lineup_data=Lineup{})
 Constructs a Team object.
 
TeamID getId () const
 Gets the team's ID.
 
LeagueID getLeagueId () const
 Gets the ID of the team's league.
 
void setLeagueId (LeagueID new_league_id)
 Moves the team to another league (promotion/relegation).
 
const std::string & getName () const
 Gets the name of the team.
 
const std::vector< PlayerID > & getPlayerIDs () const
 Player IDs of the senior squad (academy players excluded).
 
const std::vector< PlayerID > & getAcademyIDs () const
 Player IDs of the club's academy (U18 squad and trialists).
 
void addPlayerID (PlayerID id)
 Adds a player to the team.
 
void addAcademyID (PlayerID id)
 Adds a player to the club's academy.
 
void setAcademyMember (PlayerID id, bool academy)
 Moves a club player between the senior squad and the academy (use GameData::setAcademyMember, which keeps the player's flag too).
 
bool removePlayerID (PlayerID id)
 Removes a player from the team (senior squad or academy).
 
Lineup & getLineup ()
 Gets the team's lineup (non-const).
 
const Lineup & getLineup () const
 Gets the team's lineup (const).
 
Strategy & getStrategy ()
 Gets the team's strategy (non-const).
 
const Strategy & getStrategy () const
 Gets the team's strategy (const).
 
void setStrategy (const Strategy &strategy)
 Sets the team's strategy.
 
void generateStartingXI (const class GameData &gamedata, const StatsConfig &stats_config)
 Generates the best starting XI automatically based on stats.
 
Finances & getFinances () noexcept
 Gets the team's finances (non-const).
 
const Finances & getFinances () const noexcept
 Gets the team's finances (const).
 
const ClubProfile & getProfile () const noexcept
 Reputation, stadium, ticket price and facilities.
 
void setProfile (const ClubProfile &profile)
 Replaces the club profile.
 
std::uint8_t getReputation () const noexcept
 Club reputation (1-100).
 
std::uint32_t getStadiumCapacity () const noexcept
 Stadium capacity in seats.
 
const std::string & getRecentForm () const noexcept
 Last results, newest first ("WDL..."), at most 5 letters.
 
void setRecentForm (std::string_view form)
 Restores the recent-form string (persistence).
 
void pushResult (MatchOutcome outcome)
 Prepends a result to the recent form.
 

Private Attributes

TeamID id
 
LeagueID league_id
 
std::string name
 
std::vector< PlayerID > player_ids
 
std::vector< PlayerID > academy_ids
 
Strategy team_strategy
 
Lineup lineup
 
Finances finances
 
ClubProfile profile
 
std::string recent_form
 

Detailed Description

Represents a football team.

Constructor & Destructor Documentation

◆ Team()

Team::Team ( TeamID  team_id,
uint8_t  team_league_id,
std::string_view  team_name,
int64_t  initial_balance,
const std::vector< PlayerID > &  initial_player_ids = {},
const Strategy &  strategy = Strategy{},
const Lineup &  lineup_data = Lineup{} 
)

Constructs a Team object.

Parameters
team_idThe unique ID for the team.
team_league_idThe ID of the league the team belongs to.
team_nameThe name of the team.
initial_balanceThe initial financial balance.
initial_player_idsOptional list of initial player IDs.
strategyOptional strategy for the team.
lineup_dataOptional lineup data for the team.

Member Function Documentation

◆ addAcademyID()

void Team::addAcademyID ( PlayerID  id)

Adds a player to the club's academy.

◆ addPlayerID()

void Team::addPlayerID ( PlayerID  id)

Adds a player to the team.

Parameters
idThe player's ID.

◆ generateStartingXI()

void Team::generateStartingXI ( const class GameData &  gamedata,
const StatsConfig &  stats_config 
)

Generates the best starting XI automatically based on stats.

Injured players are left out.

Parameters
stats_configThe configuration used to evaluate players.

◆ getAcademyIDs()

const std::vector< PlayerID > & Team::getAcademyIDs ( ) const

Player IDs of the club's academy (U18 squad and trialists).

◆ getFinances() [1/2]

const Finances & Team::getFinances ( ) const
noexcept

Gets the team's finances (const).

◆ getFinances() [2/2]

Finances & Team::getFinances ( )
noexcept

Gets the team's finances (non-const).

◆ getId()

uint16_t Team::getId ( ) const

Gets the team's ID.

◆ getLeagueId()

uint8_t Team::getLeagueId ( ) const

Gets the ID of the team's league.

◆ getLineup() [1/2]

Lineup & Team::getLineup ( )

Gets the team's lineup (non-const).

◆ getLineup() [2/2]

const Lineup & Team::getLineup ( ) const

Gets the team's lineup (const).

◆ getName()

const std::string & Team::getName ( ) const

Gets the name of the team.

◆ getPlayerIDs()

const std::vector< PlayerID > & Team::getPlayerIDs ( ) const

Player IDs of the senior squad (academy players excluded).

◆ getProfile()

const ClubProfile & Team::getProfile ( ) const
noexcept

Reputation, stadium, ticket price and facilities.

◆ getRecentForm()

const std::string & Team::getRecentForm ( ) const
noexcept

Last results, newest first ("WDL..."), at most 5 letters.

◆ getReputation()

std::uint8_t Team::getReputation ( ) const
noexcept

Club reputation (1-100).

◆ getStadiumCapacity()

std::uint32_t Team::getStadiumCapacity ( ) const
noexcept

Stadium capacity in seats.

◆ getStrategy() [1/2]

Strategy & Team::getStrategy ( )

Gets the team's strategy (non-const).

◆ getStrategy() [2/2]

const Strategy & Team::getStrategy ( ) const

Gets the team's strategy (const).

◆ pushResult()

void Team::pushResult ( MatchOutcome  outcome)

Prepends a result to the recent form.

◆ removePlayerID()

bool Team::removePlayerID ( PlayerID  id)

Removes a player from the team (senior squad or academy).

Parameters
idThe player's ID.
Returns
True if successful, false otherwise.

◆ setAcademyMember()

void Team::setAcademyMember ( PlayerID  id,
bool  academy 
)

Moves a club player between the senior squad and the academy (use GameData::setAcademyMember, which keeps the player's flag too).

◆ setLeagueId()

void Team::setLeagueId ( LeagueID  new_league_id)

Moves the team to another league (promotion/relegation).

◆ setProfile()

void Team::setProfile ( const ClubProfile &  profile)

Replaces the club profile.

◆ setRecentForm()

void Team::setRecentForm ( std::string_view  form)

Restores the recent-form string (persistence).

◆ setStrategy()

void Team::setStrategy ( const Strategy &  strategy)

Sets the team's strategy.

Member Data Documentation

◆ academy_ids

std::vector<PlayerID> Team::academy_ids
private

◆ finances

Finances Team::finances
private

◆ id

TeamID Team::id
private

◆ league_id

LeagueID Team::league_id
private

◆ lineup

Lineup Team::lineup
private

◆ name

std::string Team::name
private

◆ player_ids

std::vector<PlayerID> Team::player_ids
private

◆ profile

ClubProfile Team::profile
private

◆ recent_form

std::string Team::recent_form
private

◆ team_strategy

Strategy Team::team_strategy
private

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