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

The human manager's career and the market for managers. More...

#include <manager_career.h>

Public Types

using PositionProvider = std::function< int(TeamID)>
 

Public Member Functions

 ManagerCareer (std::shared_ptr< GameData > gamedata)
 
bool hasProfile () const
 
const ManagerProfile & getProfile () const
 
bool isEmployed () const
 
void createProfile (const ManagerSetup &setup, const GameDateValue &date)
 
void ensureProfile (TeamID managed_team_id, const GameDateValue &date)
 
const std::vector< ManagerStint > & getStints () const
 
const std::vector< ManagerSeasonLine > & getSeasons () const
 
const std::vector< ManagerAward > & getAwards () const
 
void ensureClubManagers (const GameDateValue &date, TeamID managed_team_id)
 
const AiManager * clubManager (TeamID team_id) const
 
const std::vector< AiManager > & getAiManagers () const
 
const std::vector< Vacancy > & getVacancies () const
 
const Vacancy * findVacancy (TeamID team_id) const
 
const std::vector< JobApplication > & getApplications () const
 
const JobApplication * findApplication (TeamID team_id) const
 
const std::vector< JobOffer > & getOffers () const
 
const JobOffer * findOffer (std::uint32_t offer_id) const
 
ClubVision visionOf (TeamID team_id) const
 
float applicationChance (TeamID team_id) const
 
ApplyResult apply (TeamID team_id, const GameDateValue &date)
 
std::optional< InterviewResult > interview (TeamID team_id, std::span< const std::uint8_t > answers, const GameDateValue &date, Inbox &inbox)
 
OfferReply negotiate (std::uint32_t offer_id, std::int64_t weekly_wage, std::uint8_t years, const GameDateValue &date)
 
bool decline (std::uint32_t offer_id)
 
std::optional< JobOffer > takeOffer (std::uint32_t offer_id, const GameDateValue &date)
 
void startJob (TeamID team_id, const ManagerContract &contract, const GameDateValue &date)
 
std::int64_t leaveJob (DepartureReason reason, const GameDateValue &date, Inbox &inbox)
 
void payCompensation (TeamID from_club, TeamID to_club, std::int64_t amount, const GameDateValue &date)
 
bool dismissClubManager (TeamID team_id, const GameDateValue &date, Inbox &inbox)
 
void recordAward (ManagerAwardKind kind, std::uint16_t start_year, TeamID team_id)
 
void adjustReputation (float delta)
 
void addEarnings (std::int64_t amount)
 
void setInternationalDuty (bool in_charge)
 
bool hasInternationalDuty () const
 
ManagerContract contractFor (const JobOffer &offer, const GameDateValue &date) const
 
ManagerContract initialContract (TeamID team_id, const GameDateValue &date) const
 
CareerDayEvents onDayAdvanced (const GameDateValue &date, TeamID managed_team_id, float board_confidence, int board_expected_position, const PositionProvider &positions, Inbox &inbox)
 
void onMatchPlayed (const ManagerMatchEvent &match)
 
bool onSeasonEnd (const GameDateValue &date, TeamID managed_team_id, int expected_position, float board_confidence, const PositionProvider &positions, std::span< const SeasonHistoryEntry > finished, Inbox &inbox)
 
void load (const std::shared_ptr< DatabaseConnection > &db_conn)
 
void save (const std::shared_ptr< DatabaseConnection > &db_conn) const
 

Private Member Functions

void processApplications (const GameDateValue &date, Inbox &inbox, CareerDayEvents &events)
 
void fillVacancies (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox, CareerDayEvents &events)
 
void weeklyReviews (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox, CareerDayEvents &events)
 
void weeklyAiReviews (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox, CareerDayEvents &events)
 
void weeklyManagerReview (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox, CareerDayEvents &events)
 
void monthlyReviews (const GameDateValue &date, TeamID managed_team_id, float board_confidence, int board_expected_position, const PositionProvider &positions, Inbox &inbox, CareerDayEvents &events)
 
void monthlyAiReviews (const std::map< LeagueID, std::vector< std::pair< std::uint8_t, TeamID > > > &league_ranks, const PositionProvider &positions)
 
void monthlyManagerReview (const GameDateValue &date, TeamID managed_team_id, float board_confidence, int board_expected_position, const PositionProvider &positions, const std::map< LeagueID, std::vector< std::pair< std::uint8_t, TeamID > > > &league_ranks, Inbox &inbox, CareerDayEvents &events)
 
void reviewAiManagersAtSeasonEnd (const GameDateValue &date, TeamID managed_team_id, const PositionProvider &positions, Inbox &inbox)
 
void ageManagersAtSeasonEnd (const GameDateValue &date)
 
float applySeasonHonours (const ManagerSeasonLine &line, std::span< const SeasonHistoryEntry > finished, std::uint16_t start_year)
 
void dismissAi (AiManager &manager, const GameDateValue &date, Inbox &inbox, TeamID managed_team_id)
 
void openVacancy (TeamID team_id, const GameDateValue &date)
 
void leaveJobQuietly (DepartureReason reason, const GameDateValue &date)
 
bool makeOffer (TeamID team_id, const GameDateValue &date, bool unsolicited, float wage_factor, Inbox &inbox)
 
void topUpFreePool (const GameDateValue &date)
 
AiManager generateManager (TeamID team_id, float reputation, const GameDateValue &date)
 
std::uint8_t leagueTier (TeamID team_id) const
 
std::uint8_t clubReputation (TeamID team_id) const
 
std::string clubName (TeamID team_id) const
 
ManagerStint * currentStint ()
 

Private Attributes

std::shared_ptr< GameData > gamedata
 
ManagerProfile profile
 
std::vector< ManagerStint > stints
 
std::vector< ManagerSeasonLine > seasons
 
std::vector< ManagerAward > awards
 
std::vector< AiManager > managers
 
std::vector< Vacancy > vacancies
 
std::vector< JobApplication > applications
 
std::vector< JobOffer > offers
 
std::uint32_t next_manager_id = 1
 
std::uint32_t next_offer_id = 1
 
bool national_duty = false
 

Detailed Description

The human manager's career and the market for managers.

Owned by Game next to the world simulation. Every club has a manager: the human at the managed club, an AI manager elsewhere (generated for worlds that have none). AI managers lose their jobs when results stay below the board's expectation (weekly hazard during the season plus a season-end review); a vacancy stays open for a few weeks and is then filled by the free AI manager whose reputation fits the club best. The human applies for vacancies, is interviewed, receives offers (also unsolicited ones when overachieving or out of work for long), negotiates the contract, resigns, or is dismissed by the board. Out of work, time keeps running and the reputation fades slowly. All randomness comes from the Managers stream.

Member Typedef Documentation

◆ PositionProvider

using ManagerCareer::PositionProvider = std::function<int(TeamID)>

League position of a club in the current table (0 if unknown).

Constructor & Destructor Documentation

◆ ManagerCareer()

ManagerCareer::ManagerCareer ( std::shared_ptr< GameData >  gamedata)
explicit

Member Function Documentation

◆ addEarnings()

void ManagerCareer::addEarnings ( std::int64_t  amount)

Wages of a job outside the club game (a national team).

◆ adjustReputation()

void ManagerCareer::adjustReputation ( float  delta)

Results elsewhere (a national team) move the reputation (1-100).

◆ ageManagersAtSeasonEnd()

void ManagerCareer::ageManagersAtSeasonEnd ( const GameDateValue &  date)
private

◆ applicationChance()

float ManagerCareer::applicationChance ( TeamID  team_id) const

Chance of an interview invitation from team_id's board.

◆ apply()

ApplyResult ManagerCareer::apply ( TeamID  team_id,
const GameDateValue &  date 
)

◆ applySeasonHonours()

float ManagerCareer::applySeasonHonours ( const ManagerSeasonLine &  line,
std::span< const SeasonHistoryEntry >  finished,
std::uint16_t  start_year 
)
private

◆ clubManager()

const AiManager * ManagerCareer::clubManager ( TeamID  team_id) const

◆ clubName()

std::string ManagerCareer::clubName ( TeamID  team_id) const
private

◆ clubReputation()

std::uint8_t ManagerCareer::clubReputation ( TeamID  team_id) const
private

◆ contractFor()

ManagerContract ManagerCareer::contractFor ( const JobOffer &  offer,
const GameDateValue &  date 
) const

Contract agreed through offer, starting on date.

◆ createProfile()

void ManagerCareer::createProfile ( const ManagerSetup &  setup,
const GameDateValue &  date 
)

Creates the human manager from the new-game step.

◆ currentStint()

ManagerStint * ManagerCareer::currentStint ( )
private

◆ decline()

bool ManagerCareer::decline ( std::uint32_t  offer_id)

◆ dismissAi()

void ManagerCareer::dismissAi ( AiManager &  manager,
const GameDateValue &  date,
Inbox &  inbox,
TeamID  managed_team_id 
)
private

◆ dismissClubManager()

bool ManagerCareer::dismissClubManager ( TeamID  team_id,
const GameDateValue &  date,
Inbox &  inbox 
)

The board of team_id dismisses its AI manager (results, a takeover, a better candidate): a vacancy opens. False without an AI manager.

◆ ensureClubManagers()

void ManagerCareer::ensureClubManagers ( const GameDateValue &  date,
TeamID  managed_team_id 
)

Gives every club without one an AI manager and fills the free pool.

◆ ensureProfile()

void ManagerCareer::ensureProfile ( TeamID  managed_team_id,
const GameDateValue &  date 
)

A profile for careers started before the manager step existed.

◆ fillVacancies()

void ManagerCareer::fillVacancies ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

◆ findApplication()

const JobApplication * ManagerCareer::findApplication ( TeamID  team_id) const

◆ findOffer()

const JobOffer * ManagerCareer::findOffer ( std::uint32_t  offer_id) const

◆ findVacancy()

const Vacancy * ManagerCareer::findVacancy ( TeamID  team_id) const

◆ generateManager()

AiManager ManagerCareer::generateManager ( TeamID  team_id,
float  reputation,
const GameDateValue &  date 
)
private

◆ getAiManagers()

const std::vector< AiManager > & ManagerCareer::getAiManagers ( ) const
inline

◆ getApplications()

const std::vector< JobApplication > & ManagerCareer::getApplications ( ) const
inline

◆ getAwards()

const std::vector< ManagerAward > & ManagerCareer::getAwards ( ) const
inline

◆ getOffers()

const std::vector< JobOffer > & ManagerCareer::getOffers ( ) const
inline

◆ getProfile()

const ManagerProfile & ManagerCareer::getProfile ( ) const
inline

◆ getSeasons()

const std::vector< ManagerSeasonLine > & ManagerCareer::getSeasons ( ) const
inline

◆ getStints()

const std::vector< ManagerStint > & ManagerCareer::getStints ( ) const
inline

◆ getVacancies()

const std::vector< Vacancy > & ManagerCareer::getVacancies ( ) const
inline

◆ hasInternationalDuty()

bool ManagerCareer::hasInternationalDuty ( ) const
inline

◆ hasProfile()

bool ManagerCareer::hasProfile ( ) const
inline

◆ initialContract()

ManagerContract ManagerCareer::initialContract ( TeamID  team_id,
const GameDateValue &  date 
) const

Contract of a first appointment from the club choice.

◆ interview()

std::optional< InterviewResult > ManagerCareer::interview ( TeamID  team_id,
std::span< const std::uint8_t >  answers,
const GameDateValue &  date,
Inbox &  inbox 
)

Answers the four interview questions (one option index per topic). The board decides on the spot: an offer (terms shaped by the answers) or a polite refusal. nullopt without an interview invitation.

◆ isEmployed()

bool ManagerCareer::isEmployed ( ) const

◆ leagueTier()

std::uint8_t ManagerCareer::leagueTier ( TeamID  team_id) const
private

◆ leaveJob()

std::int64_t ManagerCareer::leaveJob ( DepartureReason  reason,
const GameDateValue &  date,
Inbox &  inbox 
)

The human leaves the managed club: the spell closes and the club gets a vacancy. A sacked manager receives the remaining wages (at most a year), booked on the club's ledger and announced in the inbox. Returns them.

◆ leaveJobQuietly()

void ManagerCareer::leaveJobQuietly ( DepartureReason  reason,
const GameDateValue &  date 
)
private

Closes the spell and opens the vacancy, without news or severance.

◆ load()

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

◆ makeOffer()

bool ManagerCareer::makeOffer ( TeamID  team_id,
const GameDateValue &  date,
bool  unsolicited,
float  wage_factor,
Inbox &  inbox 
)
private

◆ monthlyAiReviews()

void ManagerCareer::monthlyAiReviews ( const std::map< LeagueID, std::vector< std::pair< std::uint8_t, TeamID > > > &  league_ranks,
const PositionProvider &  positions 
)
private

◆ monthlyManagerReview()

void ManagerCareer::monthlyManagerReview ( const GameDateValue &  date,
TeamID  managed_team_id,
float  board_confidence,
int  board_expected_position,
const PositionProvider &  positions,
const std::map< LeagueID, std::vector< std::pair< std::uint8_t, TeamID > > > &  league_ranks,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

◆ monthlyReviews()

void ManagerCareer::monthlyReviews ( const GameDateValue &  date,
TeamID  managed_team_id,
float  board_confidence,
int  board_expected_position,
const PositionProvider &  positions,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

◆ negotiate()

OfferReply ManagerCareer::negotiate ( std::uint32_t  offer_id,
std::int64_t  weekly_wage,
std::uint8_t  years,
const GameDateValue &  date 
)

Counter-proposal on wage and length.

◆ onDayAdvanced()

CareerDayEvents ManagerCareer::onDayAdvanced ( const GameDateValue &  date,
TeamID  managed_team_id,
float  board_confidence,
int  board_expected_position,
const PositionProvider &  positions,
Inbox &  inbox 
)

Offers, applications, vacancies, AI sackings and reputation.

◆ onMatchPlayed()

void ManagerCareer::onMatchPlayed ( const ManagerMatchEvent &  match)

A competitive match: AI job security, the human's record.

◆ onSeasonEnd()

bool ManagerCareer::onSeasonEnd ( const GameDateValue &  date,
TeamID  managed_team_id,
int  expected_position,
float  board_confidence,
const PositionProvider &  positions,
std::span< const SeasonHistoryEntry >  finished,
Inbox &  inbox 
)

Season end: season line, honours, reputation, ageing and the boards' season reviews of AI managers. finished holds the history rows of the season that just ended, positions the final league positions (captured before promotion and relegation). An expiring contract is renewed while the board is content; returns true when it ran out.

◆ openVacancy()

void ManagerCareer::openVacancy ( TeamID  team_id,
const GameDateValue &  date 
)
private

◆ payCompensation()

void ManagerCareer::payCompensation ( TeamID  from_club,
TeamID  to_club,
std::int64_t  amount,
const GameDateValue &  date 
)

The club that hired the manager away pays his former club the release compensation of his contract (both ledgers).

◆ processApplications()

void ManagerCareer::processApplications ( const GameDateValue &  date,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

◆ recordAward()

void ManagerCareer::recordAward ( ManagerAwardKind  kind,
std::uint16_t  start_year,
TeamID  team_id 
)

Adds an honour decided elsewhere (e.g. a monthly award).

◆ reviewAiManagersAtSeasonEnd()

void ManagerCareer::reviewAiManagersAtSeasonEnd ( const GameDateValue &  date,
TeamID  managed_team_id,
const PositionProvider &  positions,
Inbox &  inbox 
)
private

◆ save()

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

◆ setInternationalDuty()

void ManagerCareer::setInternationalDuty ( bool  in_charge)
inline

In charge of a national team: the name does not fade out of work.

◆ startJob()

void ManagerCareer::startJob ( TeamID  team_id,
const ManagerContract &  contract,
const GameDateValue &  date 
)

The human takes charge of team_id: a new spell starts, the club's vacancy closes and its AI manager (if any) becomes available.

◆ takeOffer()

std::optional< JobOffer > ManagerCareer::takeOffer ( std::uint32_t  offer_id,
const GameDateValue &  date 
)

Removes and returns an offer that is still valid on date.

◆ topUpFreePool()

void ManagerCareer::topUpFreePool ( const GameDateValue &  date)
private

◆ visionOf()

ClubVision ManagerCareer::visionOf ( TeamID  team_id) const

◆ weeklyAiReviews()

void ManagerCareer::weeklyAiReviews ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

◆ weeklyManagerReview()

void ManagerCareer::weeklyManagerReview ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

◆ weeklyReviews()

void ManagerCareer::weeklyReviews ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox,
CareerDayEvents &  events 
)
private

Member Data Documentation

◆ applications

std::vector<JobApplication> ManagerCareer::applications
private

◆ awards

std::vector<ManagerAward> ManagerCareer::awards
private

◆ gamedata

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

◆ managers

std::vector<AiManager> ManagerCareer::managers
private

◆ national_duty

bool ManagerCareer::national_duty = false
private

◆ next_manager_id

std::uint32_t ManagerCareer::next_manager_id = 1
private

◆ next_offer_id

std::uint32_t ManagerCareer::next_offer_id = 1
private

◆ offers

std::vector<JobOffer> ManagerCareer::offers
private

◆ profile

ManagerProfile ManagerCareer::profile
private

◆ seasons

std::vector<ManagerSeasonLine> ManagerCareer::seasons
private

◆ stints

std::vector<ManagerStint> ManagerCareer::stints
private

◆ vacancies

std::vector<Vacancy> ManagerCareer::vacancies
private

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