|
Player12
An open source football management simulator
|
Persistent career identity, attributes, traits and day-to-day state. More...
#include <player.h>
Classes | |
| struct | MarketValueCache |
Public Member Functions | |
| Player (PlayerID new_id, TeamID new_team_id, std::string_view new_first_name, std::string_view new_last_name, PlayerRole new_role, Language new_nationality, uint32_t new_wage, uint32_t new_status, uint8_t new_age, uint8_t new_contract_years, uint8_t new_height, Foot new_foot, std::map< std::string, float > new_stats) | |
| Constructs a Player object. | |
| PlayerID | getId () const |
| Gets the player's ID. | |
| TeamID | getTeamId () const |
| Gets the ID of the player's team. | |
| void | setTeamId (TeamID id) |
| Sets the ID of the player's team. | |
| std::string | getName () const |
| Gets the player's full name. | |
| const std::string & | getFirstName () const |
| Gets the player's first name. | |
| const std::string & | getLastName () const |
| Gets the player's last name. | |
| int | getAge () const |
| Gets the player's age. | |
| void | setAge (uint8_t new_age) |
| Sets the player's age. | |
| PlayerRole | getRole () const |
| Gets the player's role. | |
| Language | getNationality () const |
| Gets the player's nationality. | |
| uint32_t | getWage () const |
| Gets the player's wage. | |
| void | setWage (uint32_t wage) |
| uint8_t | getContractYears () const |
| Gets the player's remaining contract years. | |
| void | setContractYears (uint8_t years) |
| bool | advanceContractYear () |
| uint8_t | getHeight () const |
| Gets the player's height. | |
| Foot | getFoot () const |
| Gets the player's preferred foot. | |
| uint32_t | getStatus () const |
| Gets the player's status. | |
| double | getOverall (const StatsConfig &stats_config) const |
| Calculates the player's overall rating based on stats and configuration. | |
| const std::map< std::string, float > & | getStats () const |
| Gets the player's stats map. | |
| void | setStats (const std::map< std::string, float > &new_stats) |
| Sets the player's stats map. | |
| void | agePlayer () |
| Increases the player's age by 1 and applies yearly ageing. | |
| void | train (const std::vector< std::string > &focus_stats, float amount=PLAYER_STAT_INCREASE_BASE) |
Improves every listed stat by amount (clamped to the maximum). | |
| float | getPotential () const |
| Hidden potential on the overall-rating scale (never shown raw). | |
| void | setPotential (float potential) |
| Sets the hidden potential. | |
| const PlayerTraits & | getTraits () const |
| Hidden personality traits. | |
| void | setTraits (const PlayerTraits &traits) |
| Replaces the hidden personality traits. | |
| const PlayerDynamics & | getDynamics () const |
| Condition, sharpness, morale, injury and form state. | |
| PlayerDynamics & | mutableDynamics () |
| Mutable dynamic state for the world simulation. | |
| bool | isAvailable () const |
| True when the player is fit enough to be selected. | |
| float | getForm () const |
| Average of the recent match ratings, 0 when none. | |
| void | pushMatchRating (float rating) |
| Records a match rating (1-10) in the recent form window. | |
| uint32_t | getMarketValue () const |
| Gets the player's market value. | |
| void | updateMarketValue (const StatsConfig &stats_config) const |
| Updates the player's market value. | |
| void | setTransferStatus (TransferStatus status) |
| Sets the player's transfer status. | |
| TransferStatus | getTransferStatus () const |
| Gets the player's transfer status. | |
| void | setAcademyPlayer (bool academy) |
| Marks the player as part of his club's academy: he is not a first-team player (squad counts, automatic line-ups). | |
| bool | isAcademyPlayer () const |
| True for U18 players and intake trialists. | |
| std::uint8_t | getSquadNumber () const |
| Squad number (1-99), 0 when he has none (academy players). | |
| void | setSquadNumber (std::uint8_t number) |
| Sets the squad number; uniqueness is kept by GameData. | |
Static Public Member Functions | |
| static double | valueFor (double overall, double potential, int age, double contract_years) |
| Market value model shared by own players and scouting estimates: ability, an inverted-U age curve, a potential premium that fades out between 22 and 25, and the remaining contract length. | |
Static Public Attributes | |
| static constexpr uint32_t | TRANSFER_LISTED_BIT = 0x01U |
| Bitmask bit for transfer-listed status. | |
| static constexpr uint32_t | ACADEMY_BIT = 0x02U |
| Bitmask bit for players of a youth academy (U18 or trialist). | |
Private Attributes | |
| PlayerID | _id |
| TeamID | _team_id |
| uint32_t | _wage |
| uint32_t | _status |
| MarketValueCache | _cached_market_value |
| std::string | _first_name |
| std::string | _last_name |
| PlayerRole | _role |
| Language | _nationality |
| TransferStatus | _transfer_status = TransferStatus::NotListed |
| uint8_t | _age |
| uint8_t | _contract_years |
| uint8_t | _height |
| Foot | _foot |
| std::uint8_t | _squad_number = 0 |
| float | _potential = 0.0f |
| PlayerTraits | _traits |
| PlayerDynamics | _dynamics |
| std::map< std::string, float > | _stats |
Persistent career identity, attributes, traits and day-to-day state.
On-pitch positions, intentions and live fatigue belong to MatchPlayer in match_engine.h. The engine borrows this Player as read-only input and the career later applies its match consequences. PlayerAgent models contract negotiations, not on-pitch AI. See docs/development/player-behavior.md. Concurrent const queries may refresh the price cache. Attribute mutations require exclusive career ownership, as with other persistent model state.
| Player::Player | ( | PlayerID | new_id, |
| TeamID | new_team_id, | ||
| std::string_view | new_first_name, | ||
| std::string_view | new_last_name, | ||
| PlayerRole | new_role, | ||
| Language | new_nationality, | ||
| uint32_t | new_wage, | ||
| uint32_t | new_status, | ||
| uint8_t | new_age, | ||
| uint8_t | new_contract_years, | ||
| uint8_t | new_height, | ||
| Foot | new_foot, | ||
| std::map< std::string, float > | new_stats | ||
| ) |
Constructs a Player object.
| new_id | The unique ID for the player. |
| new_team_id | The ID of the team the player belongs to. |
| new_first_name | The player's first name. |
| new_last_name | The player's last name. |
| new_role | The player's role (e.g., ST, CB). |
| new_nationality | The player's nationality. |
| new_wage | The player's wage. |
| new_status | The player's status. |
| new_age | The player's age. |
| new_contract_years | Years remaining on the contract. |
| new_height | The player's height in cm. |
| new_foot | The player's preferred foot. |
| new_stats | A map of the player's attributes/stats. |
| bool Player::advanceContractYear | ( | ) |
Decrements a non-zero contract and returns true when it expires.
| void Player::agePlayer | ( | ) |
Increases the player's age by 1 and applies yearly ageing.
Physical attributes decline first (-1%/year at 30-32, -3%/year after 32, stamina at half rate), technical attributes from 32 and vision from 35. Professional players decline more slowly.
| int Player::getAge | ( | ) | const |
Gets the player's age.
| uint8_t Player::getContractYears | ( | ) | const |
Gets the player's remaining contract years.
| const PlayerDynamics & Player::getDynamics | ( | ) | const |
Condition, sharpness, morale, injury and form state.
| const std::string & Player::getFirstName | ( | ) | const |
Gets the player's first name.
| Foot Player::getFoot | ( | ) | const |
Gets the player's preferred foot.
| float Player::getForm | ( | ) | const |
Average of the recent match ratings, 0 when none.
| uint8_t Player::getHeight | ( | ) | const |
Gets the player's height.
| uint32_t Player::getId | ( | ) | const |
Gets the player's ID.
| const std::string & Player::getLastName | ( | ) | const |
Gets the player's last name.
| uint32_t Player::getMarketValue | ( | ) | const |
Gets the player's market value.
| std::string Player::getName | ( | ) | const |
Gets the player's full name.
| Language Player::getNationality | ( | ) | const |
Gets the player's nationality.
| double Player::getOverall | ( | const StatsConfig & | stats_config | ) | const |
Calculates the player's overall rating based on stats and configuration.
| stats_config | Configuration weights for the stats. |
| float Player::getPotential | ( | ) | const |
Hidden potential on the overall-rating scale (never shown raw).
| PlayerRole Player::getRole | ( | ) | const |
Gets the player's role.
|
inline |
Squad number (1-99), 0 when he has none (academy players).
| const std::map< std::string, float > & Player::getStats | ( | ) | const |
Gets the player's stats map.
| uint32_t Player::getStatus | ( | ) | const |
Gets the player's status.
| TeamID Player::getTeamId | ( | ) | const |
Gets the ID of the player's team.
| const PlayerTraits & Player::getTraits | ( | ) | const |
Hidden personality traits.
| TransferStatus Player::getTransferStatus | ( | ) | const |
Gets the player's transfer status.
| uint32_t Player::getWage | ( | ) | const |
Gets the player's wage.
| bool Player::isAcademyPlayer | ( | ) | const |
True for U18 players and intake trialists.
| bool Player::isAvailable | ( | ) | const |
True when the player is fit enough to be selected.
| PlayerDynamics & Player::mutableDynamics | ( | ) |
Mutable dynamic state for the world simulation.
| void Player::pushMatchRating | ( | float | rating | ) |
Records a match rating (1-10) in the recent form window.
| void Player::setAcademyPlayer | ( | bool | academy | ) |
Marks the player as part of his club's academy: he is not a first-team player (squad counts, automatic line-ups).
| void Player::setAge | ( | uint8_t | new_age | ) |
Sets the player's age.
| void Player::setContractYears | ( | uint8_t | years | ) |
Updates the remaining contract duration.
| void Player::setPotential | ( | float | potential | ) |
Sets the hidden potential.
|
inline |
Sets the squad number; uniqueness is kept by GameData.
| void Player::setStats | ( | const std::map< std::string, float > & | new_stats | ) |
Sets the player's stats map.
| void Player::setTeamId | ( | TeamID | id | ) |
Sets the ID of the player's team.
| void Player::setTraits | ( | const PlayerTraits & | traits | ) |
Replaces the hidden personality traits.
| void Player::setTransferStatus | ( | TransferStatus | status | ) |
Sets the player's transfer status.
| void Player::setWage | ( | uint32_t | wage | ) |
Updates the weekly wage after a successful contract negotiation.
| void Player::train | ( | const std::vector< std::string > & | focus_stats, |
| float | amount = PLAYER_STAT_INCREASE_BASE |
||
| ) |
Improves every listed stat by amount (clamped to the maximum).
Because role weights sum to one, training all of a role's focus stats by x raises the overall rating by x.
| void Player::updateMarketValue | ( | const StatsConfig & | stats_config | ) | const |
Updates the player's market value.
| stats_config | The stats configuration to use for the calculation. |
|
static |
Market value model shared by own players and scouting estimates: ability, an inverted-U age curve, a potential premium that fades out between 22 and 25, and the remaining contract length.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
Bitmask bit for players of a youth academy (U18 or trialist).
|
staticconstexpr |
Bitmask bit for transfer-listed status.