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

Deals, loans, pre-contracts, payments and history of the market. More...

#include <transfer_market.h>

Classes

struct  AiNeed
 
struct  Deal
 

Public Member Functions

 TransferMarket (std::shared_ptr< GameData > gamedata, WorldSimulation &world, const CompetitionManager &competitions)
 
void onDayAdvanced (const GameDateValue &date, TeamID managed_team_id)
 
void forgetRemovedPlayers ()
 
void load (const std::shared_ptr< DatabaseConnection > &db_conn)
 
void save (const std::shared_ptr< DatabaseConnection > &db_conn) const
 
void onSaved ()
 
TransferNegotiation::SaleContext saleContext (PlayerID player_id, TeamID buyer_id, const GameDateValue &date, std::uint32_t listing_price) const
 
TransferNegotiation::PlayerContext playerContext (PlayerID player_id, TeamID club_id, TransferNegotiation::ContractKind kind) const
 
SquadRole projectedRole (PlayerID player_id, TeamID club_id) const
 
bool wouldJoin (PlayerID player_id, TeamID club_id, TransferNegotiation::ContractKind kind) const
 
bool completeTransfer (const Deal &deal, const GameDateValue &date, TeamID managed_team_id)
 
bool startLoan (PlayerID player_id, TeamID borrower_id, const TransferNegotiation::LoanTerms &terms, const GameDateValue &date, TeamID managed_team_id)
 
bool endLoan (PlayerID player_id, const GameDateValue &date, TeamID managed_team_id, bool recalled)
 
bool exerciseLoanOption (PlayerID player_id, const GameDateValue &date, TeamID managed_team_id)
 
bool releasePlayer (PlayerID player_id, const GameDateValue &date, TeamID managed_team_id)
 
bool agreePreContract (PlayerID player_id, TeamID club_id, const TransferNegotiation::ContractOffer &terms, const GameDateValue &date, TeamID managed_team_id)
 
void recordLegacyTransfer (PlayerID player_id, TeamID from_team, TeamID to_team, std::uint32_t fee, const GameDateValue &date)
 
bool canBeTraded (PlayerID player_id) const
 
bool loanWithinLimits (PlayerID player_id, TeamID parent, TeamID borrower) const
 
std::int64_t committedPayables (TeamID team_id, const GameDateValue &date) const
 
std::int64_t spendableBudget (TeamID team_id, const GameDateValue &date) const
 
void removeFromLineup (Team &team, const Player &departed) const
 
std::int64_t wageRoom (TeamID club_id) const
 
std::int64_t nextSeasonWageRoom (TeamID club_id) const
 
std::int64_t committedPreContractCosts (TeamID club_id) const
 
bool keepsSquadFloor (TeamID club_id, PlayerID leaving, bool *goalkeeper=nullptr) const
 
bool keepsAiKeepers (TeamID club_id, PlayerID leaving) const
 
std::size_t seniorSquadSize (TeamID club_id) const
 
bool renewContract (PlayerID player_id, const TransferNegotiation::ContractOffer &offer, const GameDateValue &date)
 
std::uint32_t deservedWage (PlayerID player_id, TeamID club_id) const
 
LoanNegotiation::BorrowerContext borrowerContext (PlayerID player_id, TeamID club_id, const GameDateValue &date) const
 
std::uint16_t appearancesFor (PlayerID player_id, TeamID team_id) const
 
void seedReleaseClauses ()
 
void seedSummerFreeAgents ()
 
std::uint32_t releaseClause (PlayerID player_id) const
 
void setReleaseClause (PlayerID player_id, std::uint32_t clause)
 
bool payReleaseClause (TeamID club_id, PlayerID player_id, const GameDateValue &date, TeamID managed_team_id)
 
bool runAiClub (TeamID club_id, const std::unordered_map< PlayerID, TransferListing > &listings, const GameDateValue &date, TeamID managed_team_id, WorldRng &rng, bool free_agents_only)
 
void listLoanProspects (TeamID club_id)
 
void runAiPreContracts (const GameDateValue &date, TeamID managed_team_id, WorldRng &rng, int attempts)
 
void runAiApproach (TeamID club_id, const GameDateValue &date, TeamID managed_team_id, WorldRng &rng)
 
const std::vector< IncomingOffer > & incomingOffers () const
 
const IncomingOffer * findIncomingOffer (std::uint32_t offer_id) const
 
std::uint32_t addIncomingOffer (IncomingOffer offer)
 
bool updateIncomingOffer (const IncomingOffer &offer)
 
bool removeIncomingOffer (std::uint32_t offer_id)
 
std::vector< std::uint32_t > dueOfferReplies (const GameDateValue &date) const
 
std::uint8_t rivalBids (const IncomingOffer &offer) const
 
GameDateValue answerDeadline (TeamID buyer, const GameDateValue &date, int days) const
 
TransferNegotiation::WindowInfo clubWindow (TeamID club, const GameDateValue &date) const
 
void closeTalks (PlayerID player_id, TeamID buyer, const GameDateValue &date)
 
bool talksClosed (PlayerID player_id, TeamID buyer, const GameDateValue &date) const
 
const std::vector< TalksCooldown > & closedTalks () const
 
const std::unordered_map< PlayerID, Negotiation > & talks () const
 
const Negotiation * findNegotiation (PlayerID player_id) const
 
void setNegotiation (const Negotiation &negotiation)
 
void removeNegotiation (PlayerID player_id)
 
const PlayerMarketFlags * flags (PlayerID player_id) const
 
void setLoanListed (PlayerID player_id, bool listed)
 
bool isLoanListed (PlayerID player_id) const
 
void setNotForSale (PlayerID player_id, const GameDateValue &until)
 
bool isNotForSale (PlayerID player_id, const GameDateValue &date) const
 
const LoanDeal * findLoan (PlayerID player_id) const
 
const std::unordered_map< PlayerID, LoanDeal > & loans () const
 
const PreContractDeal * findPreContract (PlayerID player_id) const
 
const std::unordered_map< PlayerID, PreContractDeal > & preContracts () const
 
const std::vector< TransferRecord > & history () const
 
std::vector< TransferRecord > historyFor (PlayerID player_id) const
 
const std::vector< TransferObligation > & obligations () const
 

Static Public Member Functions

static std::uint32_t agentFee (const Deal &deal)
 
static bool affordsWage (const Team &club, std::uint32_t weekly_wage, std::int64_t room)
 

Static Public Attributes

static constexpr std::size_t MIN_SENIOR_SQUAD = 11
 

Private Member Functions

Player * mutablePlayer (PlayerID player_id)
 
std::string teamName (TeamID team_id) const
 
void movePlayer (PlayerID player_id, TeamID from_team, TeamID to_team, TeamID managed_team_id)
 
void pay (TeamID payer, TeamID payee, std::int64_t amount, const GameDateValue &date)
 
std::int64_t paySellOns (PlayerID player_id, TeamID seller, TeamID buyer, std::uint32_t fee, const GameDateValue &date)
 
void addRecord (const TransferRecord &record)
 
void post (const GameDateValue &date, InboxCategory category, std::string title_key, std::string body_key, std::vector< std::string > args, std::optional< PlayerID > player_id, std::optional< TeamID > team_id)
 
std::uint16_t careerCount (PlayerID player_id, TeamID team_id, ObligationKind kind) const
 
PlayerMarketFlags & mutableFlags (PlayerID player_id)
 
void pruneFlags (PlayerID player_id)
 
void clearOnMove (PlayerID player_id)
 
std::optional< AiNeed > assessNeed (const std::vector< std::pair< double, PlayerID > > &ranked, float level_boost=0.0f) const
 
std::int64_t aiWageRoom (TeamID club_id, bool next_season) const
 
std::int64_t preContractCosts (TeamID club_id) const
 
bool lastSeasonMove (TeamID club_id, bool promoted) const
 
bool endContract (PlayerID player_id, const GameDateValue &date, TeamID managed_team_id, bool severance_due)
 
void releaseOnRelegation (const GameDateValue &date, TeamID managed_team_id)
 
void lowerFreeAgentExpectations ()
 
void listLoanProspects (const std::vector< std::pair< double, PlayerID > > &ranked)
 
bool aiShedSurplus (TeamID club_id, const std::vector< std::pair< double, PlayerID > > &ranked, const GameDateValue &date, TeamID managed_team_id, WorldRng &rng)
 
bool aiSignFreeAgent (TeamID club_id, const AiNeed &need, std::int64_t wage_room, const GameDateValue &date, TeamID managed_team_id)
 
bool aiTakeLoan (TeamID club_id, const AiNeed &need, std::int64_t wage_room, const GameDateValue &date, TeamID managed_team_id, WorldRng &rng)
 
bool aiBuy (TeamID club_id, const AiNeed &need, std::int64_t wage_room, const std::unordered_map< PlayerID, TransferListing > &listings, const GameDateValue &date, TeamID managed_team_id, WorldRng &rng)
 
void payLoanWageShares (const GameDateValue &date)
 
void processLoanEnds (const GameDateValue &date, TeamID managed_team_id)
 
void executePreContracts (const GameDateValue &date, TeamID managed_team_id)
 
void payDueInstalments (const GameDateValue &date, TeamID managed_team_id)
 
void checkAddOns (const GameDateValue &date, TeamID managed_team_id)
 
void checkPromises (const GameDateValue &date, TeamID managed_team_id)
 
void expireOffers (const GameDateValue &date)
 
void postNewsDigest (const GameDateValue &date, TeamID managed_team_id)
 
void postDeadlineSummary (const GameDateValue &date, TeamID managed_team_id)
 
void applyWageRises (const GameDateValue &date)
 
void payAppearanceFees (const GameDateValue &date)
 
void addContractExtras (PlayerID player_id, TeamID club_id, const TransferNegotiation::ContractOffer &contract, const GameDateValue &start)
 
void settleLoanClause (const LoanDeal &loan, const GameDateValue &date, TeamID managed_team_id, bool charge)
 

Static Private Member Functions

static bool aiAffordsWage (const Team &club, std::uint32_t weekly_wage, std::int64_t room)
 

Private Attributes

std::shared_ptr< GameData > gamedata
 
WorldSimulation & world
 
const CompetitionManager & competitions
 
std::vector< TransferRecord > records
 
std::size_t persisted_records = 0
 
std::vector< TransferObligation > pending_obligations
 
std::unordered_map< PlayerID, LoanDeal > active_loans
 
std::unordered_map< PlayerID, PreContractDeal > pre_contracts
 
std::unordered_map< PlayerID, PlayerMarketFlags > player_flags
 
std::vector< IncomingOffer > incoming
 
std::unordered_map< PlayerID, Negotiation > negotiations
 
std::vector< TalksCooldown > cooldowns
 
std::uint32_t next_id = 1
 
std::mutex payables_cache_mutex
 
std::unordered_map< TeamID, std::int64_t > payables_cache
 
std::int32_t payables_day = -1
 
bool payables_dirty = true
 

Detailed Description

Deals, loans, pre-contracts, payments and history of the market.

Owned by Game next to the world simulation. It executes structured moves (fees with instalments, add-ons and sell-on clauses, agent fees, signing bonuses, loans and releases), runs the scheduled parts of existing deals every day and drives the AI moves that do not go through the transfer list (free agents, loans, releases, pre-contracts and approaches for the managed club's players). All randomness comes from world RNG streams.

Constructor & Destructor Documentation

◆ TransferMarket()

TransferMarket::TransferMarket ( std::shared_ptr< GameData >  gamedata,
WorldSimulation &  world,
const CompetitionManager &  competitions 
)

Member Function Documentation

◆ addContractExtras()

void TransferMarket::addContractExtras ( PlayerID  player_id,
TeamID  club_id,
const TransferNegotiation::ContractOffer &  contract,
const GameDateValue &  start 
)
private

Contract extras (rise, appearance money) of contract for the player at club_id from start; old clubs' extras lapse.

◆ addIncomingOffer()

std::uint32_t TransferMarket::addIncomingOffer ( IncomingOffer  offer)

Adds an offer with a fresh id; a transfer offer without history gets its opening bid as the first round, and a default patience.

◆ addRecord()

void TransferMarket::addRecord ( const TransferRecord &  record)
private

◆ affordsWage()

static bool TransferMarket::affordsWage ( const Team &  club,
std::uint32_t  weekly_wage,
std::int64_t  room 
)
inlinestatic

weekly_wage fits room and the single-player share of the club's wage budget.

◆ agentFee()

std::uint32_t TransferMarket::agentFee ( const Deal &  deal)
static

Agent fee paid by the buyer: the one agreed in the contract, else 10% of a fee, or weeks of wage.

◆ agreePreContract()

bool TransferMarket::agreePreContract ( PlayerID  player_id,
TeamID  club_id,
const TransferNegotiation::ContractOffer &  terms,
const GameDateValue &  date,
TeamID  managed_team_id 
)

◆ aiAffordsWage()

bool TransferMarket::aiAffordsWage ( const Team &  club,
std::uint32_t  weekly_wage,
std::int64_t  room 
)
staticprivate

A wage within room and the single-player share of the budget.

◆ aiBuy()

bool TransferMarket::aiBuy ( TeamID  club_id,
const AiNeed &  need,
std::int64_t  wage_room,
const std::unordered_map< PlayerID, TransferListing > &  listings,
const GameDateValue &  date,
TeamID  managed_team_id,
WorldRng &  rng 
)
private

◆ aiShedSurplus()

bool TransferMarket::aiShedSurplus ( TeamID  club_id,
const std::vector< std::pair< double, PlayerID > > &  ranked,
const GameDateValue &  date,
TeamID  managed_team_id,
WorldRng &  rng 
)
private

◆ aiSignFreeAgent()

bool TransferMarket::aiSignFreeAgent ( TeamID  club_id,
const AiNeed &  need,
std::int64_t  wage_room,
const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ aiTakeLoan()

bool TransferMarket::aiTakeLoan ( TeamID  club_id,
const AiNeed &  need,
std::int64_t  wage_room,
const GameDateValue &  date,
TeamID  managed_team_id,
WorldRng &  rng 
)
private

◆ aiWageRoom()

std::int64_t TransferMarket::aiWageRoom ( TeamID  club_id,
bool  next_season 
) const
private

Weekly wages an AI club can still commit: its wage budget less the payroll and the wages of the pre-contracts it has agreed. With next_season only contracts that run beyond this season count, and its players out on loan are back.

◆ answerDeadline()

GameDateValue TransferMarket::answerDeadline ( TeamID  buyer,
const GameDateValue &  date,
int  days 
) const

Last day to answer an offer of buyer made on date: days later, but never after the buyer's transfer window closes.

◆ appearancesFor()

std::uint16_t TransferMarket::appearancesFor ( PlayerID  player_id,
TeamID  team_id 
) const
inline

Appearances for team_id in his career (competitive matches).

◆ applyWageRises()

void TransferMarket::applyWageRises ( const GameDateValue &  date)
private

Yearly rises due on date and weekly appearance money.

◆ assessNeed()

std::optional< TransferMarket::AiNeed > TransferMarket::assessNeed ( const std::vector< std::pair< double, PlayerID > > &  ranked,
float  level_boost = 0.0f 
) const
private

level_boost raises the level starters are measured against.

< Slots in a typical XI.

< Squad players wanted.

◆ borrowerContext()

LoanNegotiation::BorrowerContext TransferMarket::borrowerContext ( PlayerID  player_id,
TeamID  club_id,
const GameDateValue &  date 
) const

Context of club_id borrowing player_id from today (budget, wage room, how often he would play); ceiling and talks state left at 0.

◆ canBeTraded()

bool TransferMarket::canBeTraded ( PlayerID  player_id) const

Not on loan and not committed to another club.

◆ careerCount()

std::uint16_t TransferMarket::careerCount ( PlayerID  player_id,
TeamID  team_id,
ObligationKind  kind 
) const
private

◆ checkAddOns()

void TransferMarket::checkAddOns ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ checkPromises()

void TransferMarket::checkPromises ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ clearOnMove()

void TransferMarket::clearOnMove ( PlayerID  player_id)
private

◆ closedTalks()

const std::vector< TalksCooldown > & TransferMarket::closedTalks ( ) const
inline

◆ closeTalks()

void TransferMarket::closeTalks ( PlayerID  player_id,
TeamID  buyer,
const GameDateValue &  date 
)

Talks of buyer for player_id ended on date: the club does not come back for him for a while (at most until the window closes).

◆ clubWindow()

WindowInfo TransferMarket::clubWindow ( TeamID  club,
const GameDateValue &  date 
) const

Transfer window of club's country on date: the buying club's window decides whether it can sign a player (TransferWindows).

◆ committedPayables()

std::int64_t TransferMarket::committedPayables ( TeamID  team_id,
const GameDateValue &  date 
) const

Instalments a club owes from date until the season ends.

◆ committedPreContractCosts()

std::int64_t TransferMarket::committedPreContractCosts ( TeamID  club_id) const
inline

Signing bonuses and agent fees due on the club's agreed pre-contracts.

◆ completeTransfer()

bool TransferMarket::completeTransfer ( const Deal &  deal,
const GameDateValue &  date,
TeamID  managed_team_id 
)

Fee or free move with the full deal structure; false if invalid.

◆ deservedWage()

std::uint32_t TransferMarket::deservedWage ( PlayerID  player_id,
TeamID  club_id 
) const

What players of his ability and age earn at club_id (the club's pay scale applied to his wage index); 0 when unknown.

◆ dueOfferReplies()

std::vector< std::uint32_t > TransferMarket::dueOfferReplies ( const GameDateValue &  date) const

Transfer offers whose buyer answers on or before date, by id.

◆ endContract()

bool TransferMarket::endContract ( PlayerID  player_id,
const GameDateValue &  date,
TeamID  managed_team_id,
bool  severance_due 
)
private

Terminates a contract; severance_due pays the remaining wages (a relegation clause ends it for free).

◆ endLoan()

bool TransferMarket::endLoan ( PlayerID  player_id,
const GameDateValue &  date,
TeamID  managed_team_id,
bool  recalled 
)

Sends a loanee back (end of term or recall).

◆ executePreContracts()

void TransferMarket::executePreContracts ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ exerciseLoanOption()

bool TransferMarket::exerciseLoanOption ( PlayerID  player_id,
const GameDateValue &  date,
TeamID  managed_team_id 
)

Borrower buys the loanee for the option fee.

◆ expireOffers()

void TransferMarket::expireOffers ( const GameDateValue &  date)
private

◆ findIncomingOffer()

const IncomingOffer * TransferMarket::findIncomingOffer ( std::uint32_t  offer_id) const

◆ findLoan()

const LoanDeal * TransferMarket::findLoan ( PlayerID  player_id) const

◆ findNegotiation()

const Negotiation * TransferMarket::findNegotiation ( PlayerID  player_id) const

◆ findPreContract()

const PreContractDeal * TransferMarket::findPreContract ( PlayerID  player_id) const

◆ flags()

const PlayerMarketFlags * TransferMarket::flags ( PlayerID  player_id) const

◆ forgetRemovedPlayers()

void TransferMarket::forgetRemovedPlayers ( )

Drops offers, talks, flags and cooldowns of players who no longer exist (retirement, youth releases).

◆ history()

const std::vector< TransferRecord > & TransferMarket::history ( ) const
inline

Every move, oldest first.

◆ historyFor()

std::vector< TransferRecord > TransferMarket::historyFor ( PlayerID  player_id) const

Moves of one player, oldest first.

◆ incomingOffers()

const std::vector< IncomingOffer > & TransferMarket::incomingOffers ( ) const
inline

◆ isLoanListed()

bool TransferMarket::isLoanListed ( PlayerID  player_id) const

◆ isNotForSale()

bool TransferMarket::isNotForSale ( PlayerID  player_id,
const GameDateValue &  date 
) const

◆ keepsAiKeepers()

bool TransferMarket::keepsAiKeepers ( TeamID  club_id,
PlayerID  leaving 
) const

False when leaving is a senior goalkeeper and club_id would keep fewer than Market::MIN_AI_SENIOR_KEEPERS of them (applied to the AI's sales, loans and releases).

◆ keepsSquadFloor()

bool TransferMarket::keepsSquadFloor ( TeamID  club_id,
PlayerID  leaving,
bool *  goalkeeper = nullptr 
) const

False when leaving going would leave club_id fewer than MIN_SENIOR_SQUAD senior players or no senior goalkeeper; goalkeeper tells which (null to ignore).

◆ lastSeasonMove()

bool TransferMarket::lastSeasonMove ( TeamID  club_id,
bool  promoted 
) const
private

Clubs promoted or relegated at the last season's close.

◆ listLoanProspects() [1/2]

void TransferMarket::listLoanProspects ( const std::vector< std::pair< double, PlayerID > > &  ranked)
private

◆ listLoanProspects() [2/2]

void TransferMarket::listLoanProspects ( TeamID  club_id)

Offers an AI club's surplus prospects for loan (no move).

◆ load()

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

◆ loans()

const std::unordered_map< PlayerID, LoanDeal > & TransferMarket::loans ( ) const
inline

◆ loanWithinLimits()

bool TransferMarket::loanWithinLimits ( PlayerID  player_id,
TeamID  parent,
TeamID  borrower 
) const

◆ lowerFreeAgentExpectations()

void TransferMarket::lowerFreeAgentExpectations ( )
private

◆ movePlayer()

void TransferMarket::movePlayer ( PlayerID  player_id,
TeamID  from_team,
TeamID  to_team,
TeamID  managed_team_id 
)
private

◆ mutableFlags()

PlayerMarketFlags & TransferMarket::mutableFlags ( PlayerID  player_id)
private

◆ mutablePlayer()

Player * TransferMarket::mutablePlayer ( PlayerID  player_id)
private

◆ nextSeasonWageRoom()

std::int64_t TransferMarket::nextSeasonWageRoom ( TeamID  club_id) const
inline

Wage room next season: contracts running past 30 June and agreed pre-contracts count, players in their final year do not.

◆ obligations()

const std::vector< TransferObligation > & TransferMarket::obligations ( ) const
inline

◆ onDayAdvanced()

void TransferMarket::onDayAdvanced ( const GameDateValue &  date,
TeamID  managed_team_id 
)

Loan wages and returns, pre-contracts (1 July), instalments, add-ons, promises, offer expiry and the weekly news digest. Offers and talks of players who left football (retired, released youngsters) are dropped first.

◆ onSaved()

void TransferMarket::onSaved ( )

◆ pay()

void TransferMarket::pay ( TeamID  payer,
TeamID  payee,
std::int64_t  amount,
const GameDateValue &  date 
)
private

◆ payAppearanceFees()

void TransferMarket::payAppearanceFees ( const GameDateValue &  date)
private

◆ payDueInstalments()

void TransferMarket::payDueInstalments ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ payLoanWageShares()

void TransferMarket::payLoanWageShares ( const GameDateValue &  date)
private

◆ payReleaseClause()

bool TransferMarket::payReleaseClause ( TeamID  club_id,
PlayerID  player_id,
const GameDateValue &  date,
TeamID  managed_team_id 
)

An AI club pays a player's release clause in cash (within its budget and wage room; never leaving the managed squad short): his club cannot refuse and he joins on the terms he demands. True if he moved.

◆ paySellOns()

std::int64_t TransferMarket::paySellOns ( PlayerID  player_id,
TeamID  seller,
TeamID  buyer,
std::uint32_t  fee,
const GameDateValue &  date 
)
private

Pays the sell-on clauses of seller's sale to buyer; a clause whose beneficiary is the buyer itself lapses unpaid.

◆ playerContext()

PlayerContext TransferMarket::playerContext ( PlayerID  player_id,
TeamID  club_id,
TransferNegotiation::ContractKind  kind 
) const

◆ post()

void TransferMarket::post ( const GameDateValue &  date,
InboxCategory  category,
std::string  title_key,
std::string  body_key,
std::vector< std::string >  args,
std::optional< PlayerID >  player_id,
std::optional< TeamID >  team_id 
)
private

◆ postDeadlineSummary()

void TransferMarket::postDeadlineSummary ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

On the day a window shuts: the deals of its last days.

◆ postNewsDigest()

void TransferMarket::postNewsDigest ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ preContractCosts()

std::int64_t TransferMarket::preContractCosts ( TeamID  club_id) const
private

Signing bonuses and agent fees due on the club's pre-contracts.

◆ preContracts()

const std::unordered_map< PlayerID, PreContractDeal > & TransferMarket::preContracts ( ) const
inline

◆ processLoanEnds()

void TransferMarket::processLoanEnds ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ projectedRole()

SquadRole TransferMarket::projectedRole ( PlayerID  player_id,
TeamID  club_id 
) const

Role the player would have by ability rank at club_id.

◆ pruneFlags()

void TransferMarket::pruneFlags ( PlayerID  player_id)
private

◆ recordLegacyTransfer()

void TransferMarket::recordLegacyTransfer ( PlayerID  player_id,
TeamID  from_team,
TeamID  to_team,
std::uint32_t  fee,
const GameDateValue &  date 
)

History and sell-on clauses of a move made by the legacy path.

◆ releaseClause()

std::uint32_t TransferMarket::releaseClause ( PlayerID  player_id) const

Release clause of a player (0 = none).

◆ releaseOnRelegation()

void TransferMarket::releaseOnRelegation ( const GameDateValue &  date,
TeamID  managed_team_id 
)
private

◆ releasePlayer()

bool TransferMarket::releasePlayer ( PlayerID  player_id,
const GameDateValue &  date,
TeamID  managed_team_id 
)

Terminates the contract, paying the remaining wages.

◆ removeFromLineup()

void TransferMarket::removeFromLineup ( Team &  team,
const Player &  departed 
) const

Takes a departed player out of the managed club's line-up, filling his place without rebuilding the rest of the manager's selection.

◆ removeIncomingOffer()

bool TransferMarket::removeIncomingOffer ( std::uint32_t  offer_id)

◆ removeNegotiation()

void TransferMarket::removeNegotiation ( PlayerID  player_id)

◆ renewContract()

bool TransferMarket::renewContract ( PlayerID  player_id,
const TransferNegotiation::ContractOffer &  offer,
const GameDateValue &  date 
)

Renews a player's contract at his club with offer: wage, seasons (the current one included), extras, release clause and promise; the signing bonus and agent fee are paid today. False if invalid.

◆ rivalBids()

std::uint8_t TransferMarket::rivalBids ( const IncomingOffer &  offer) const

Other clubs with a transfer offer for the same player.

◆ runAiApproach()

void TransferMarket::runAiApproach ( TeamID  club_id,
const GameDateValue &  date,
TeamID  managed_team_id,
WorldRng &  rng 
)

An AI club may bid for one of the managed club's players.

◆ runAiClub()

bool TransferMarket::runAiClub ( TeamID  club_id,
const std::unordered_map< PlayerID, TransferListing > &  listings,
const GameDateValue &  date,
TeamID  managed_team_id,
WorldRng &  rng,
bool  free_agents_only 
)

One AI club's business on a visit: sheds surplus (loan-listing prospects, releasing veterans), then fills its biggest need (a missing position or a weak starter) with a free agent, a loan or a structured fee deal with another AI club. Returns true when a player moved.

◆ runAiPreContracts()

void TransferMarket::runAiPreContracts ( const GameDateValue &  date,
TeamID  managed_team_id,
WorldRng &  rng,
int  attempts 
)

AI clubs agree pre-contracts (1 January - 30 June).

◆ saleContext()

SaleContext TransferMarket::saleContext ( PlayerID  player_id,
TeamID  buyer_id,
const GameDateValue &  date,
std::uint32_t  listing_price 
) const

◆ save()

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

Writes the market state inside the caller's transaction.

◆ seedReleaseClauses()

void TransferMarket::seedReleaseClauses ( )

Gives some ambitious players at modest clubs a release clause in a new world (deterministic from the world seed).

◆ seedSummerFreeAgents()

void TransferMarket::seedSummerFreeAgents ( )

The 30 June expiries of a new world: some players outside each club's matchday squad start without a club (deterministic from the world seed; no history, no money).

◆ seniorSquadSize()

std::size_t TransferMarket::seniorSquadSize ( TeamID  club_id) const

Senior players of a club plus the pre-contracts joining it.

◆ setLoanListed()

void TransferMarket::setLoanListed ( PlayerID  player_id,
bool  listed 
)

◆ setNegotiation()

void TransferMarket::setNegotiation ( const Negotiation &  negotiation)

◆ setNotForSale()

void TransferMarket::setNotForSale ( PlayerID  player_id,
const GameDateValue &  until 
)

Clubs are told the player is not for sale until until (they do not approach him before then).

◆ setReleaseClause()

void TransferMarket::setReleaseClause ( PlayerID  player_id,
std::uint32_t  clause 
)

◆ settleLoanClause()

void TransferMarket::settleLoanClause ( const LoanDeal &  loan,
const GameDateValue &  date,
TeamID  managed_team_id,
bool  charge 
)
private

Settles the appearance clause of a loan ending on date (paid only when charge and he played too little).

◆ spendableBudget()

std::int64_t TransferMarket::spendableBudget ( TeamID  team_id,
const GameDateValue &  date 
) const

Transfer money a club can commit on date: the board's allowance capped by the cash left after the payroll reserve and the instalments still owed this season (ClubEconomy::availableTransferBudget); zero under a transfer embargo.

◆ startLoan()

bool TransferMarket::startLoan ( PlayerID  player_id,
TeamID  borrower_id,
const TransferNegotiation::LoanTerms &  terms,
const GameDateValue &  date,
TeamID  managed_team_id 
)

◆ talks()

const std::unordered_map< PlayerID, Negotiation > & TransferMarket::talks ( ) const
inline

Open talks of the managed club by player.

◆ talksClosed()

bool TransferMarket::talksClosed ( PlayerID  player_id,
TeamID  buyer,
const GameDateValue &  date 
) const

◆ teamName()

std::string TransferMarket::teamName ( TeamID  team_id) const
private

◆ updateIncomingOffer()

bool TransferMarket::updateIncomingOffer ( const IncomingOffer &  offer)

◆ wageRoom()

std::int64_t TransferMarket::wageRoom ( TeamID  club_id) const
inline

Weekly wages a club can still commit (budget less payroll and the wages of its agreed pre-contracts).

◆ wouldJoin()

bool TransferMarket::wouldJoin ( PlayerID  player_id,
TeamID  club_id,
TransferNegotiation::ContractKind  kind 
) const

True if the player accepts the terms he demands from club_id.

Member Data Documentation

◆ active_loans

std::unordered_map<PlayerID, LoanDeal> TransferMarket::active_loans
private

◆ competitions

const CompetitionManager& TransferMarket::competitions
private

◆ cooldowns

std::vector<TalksCooldown> TransferMarket::cooldowns
private

◆ gamedata

std::shared_ptr<GameData> TransferMarket::gamedata
private

◆ incoming

std::vector<IncomingOffer> TransferMarket::incoming
private

◆ MIN_SENIOR_SQUAD

constexpr std::size_t TransferMarket::MIN_SENIOR_SQUAD = 11
staticconstexpr

Fewest senior players a managed squad may keep after a release or a sale.

◆ negotiations

std::unordered_map<PlayerID, Negotiation> TransferMarket::negotiations
private

◆ next_id

std::uint32_t TransferMarket::next_id = 1
private

◆ payables_cache

std::unordered_map<TeamID, std::int64_t> TransferMarket::payables_cache
mutableprivate

◆ payables_cache_mutex

std::mutex TransferMarket::payables_cache_mutex
mutableprivate

◆ payables_day

std::int32_t TransferMarket::payables_day = -1
mutableprivate

◆ payables_dirty

bool TransferMarket::payables_dirty = true
mutableprivate

◆ pending_obligations

std::vector<TransferObligation> TransferMarket::pending_obligations
private

◆ persisted_records

std::size_t TransferMarket::persisted_records = 0
private

◆ player_flags

std::unordered_map<PlayerID, PlayerMarketFlags> TransferMarket::player_flags
private

◆ pre_contracts

std::unordered_map<PlayerID, PreContractDeal> TransferMarket::pre_contracts
private

◆ records

std::vector<TransferRecord> TransferMarket::records
private

◆ world

WorldSimulation& TransferMarket::world
private

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