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

Relations, promises, requests and team talks of the managed club. More...

#include <interactions.h>

Classes

struct  TeamTalkRecord
 

Public Member Functions

 InteractionSystem (std::shared_ptr< GameData > gamedata, std::function< SquadRole(PlayerID)> role_of)
 
void onDayAdvanced (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox)
 
void onWeek (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox)
 
void onMatchPlayed (const MatchReport &report, TeamID managed_team_id)
 
void onTransferCompleted (const GameDateValue &date, PlayerID player_id, TeamID from_team_id, TeamID to_team_id, TeamID managed_team_id, Inbox &inbox)
 
float onBidRejected (const GameDateValue &date, PlayerID player_id, const std::string &buyer_name, float morale_delta, float trust_delta, bool transfer_request, Inbox &inbox)
 
float adjustTrust (PlayerID player_id, float delta)
 
float moraleTargetOffset (PlayerID player_id) const
 
std::vector< TalkOptionView > options (PlayerID player_id, const GameDateValue &date, TeamID managed_team_id, float manager_standing) const
 
std::optional< TalkOutcome > talk (PlayerID player_id, TalkOption option, const GameDateValue &date, TeamID managed_team_id, float manager_standing)
 
TeamTalkContext teamTalkContext (TeamID team_id, TeamTalkMoment moment, const GameDateValue &date) const
 
bool canGiveTeamTalk (TeamID team_id, TeamTalkMoment moment, const GameDateValue &date) const
 
std::optional< TeamTalkResult > giveTeamTalk (const TeamTalkContext &context, TeamID team_id, TeamTalkTone tone)
 
float teamTalkModifier (TeamID team_id, const GameDateValue &date, int half) const
 
DressingRoom dressingRoom (TeamID team_id, const GameDateValue &date) const
 
float cohesionModifier (TeamID team_id, const GameDateValue &date) const
 
const PlayerRelation * relation (PlayerID player_id) const
 
std::vector< Promise > promisesFor (PlayerID player_id) const
 
const std::vector< Promise > & promises () const
 
std::vector< PlayerID > pendingRequests () const
 
const InteractionState & getState () const
 
void restore (InteractionState restored)
 
void load (const std::shared_ptr< DatabaseConnection > &db_conn)
 
void save (const std::shared_ptr< DatabaseConnection > &db_conn) const
 

Static Public Member Functions

static std::optional< GameDateValue > signingDeadline (const GameDateValue &date, LeagueID league)
 

Private Member Functions

TalkContext contextFor (const Player &player, const GameDateValue &date, float manager_standing) const
 
TalkBlock blockFor (const Player &player, TalkOption option, const TalkContext &context, const GameDateValue &date, TeamID managed_team_id, std::int32_t &cooldown) const
 
TalkBlock optionBlockFor (const Player &player, TalkOption option, const TalkContext &context, const GameDateValue &date, TeamID managed_team_id) const
 
bool hasActivePromise (PlayerID player_id, PromiseType type) const
 
void evaluatePromises (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox)
 
void evaluatePromise (Promise &promise, const Player &player, bool due, const GameDateValue &date, std::int32_t today, Inbox &inbox)
 
void evaluatePlayingTimePromise (Promise &promise, const Player &player, bool due, const GameDateValue &date, std::int32_t today, Inbox &inbox)
 
void evaluateContractPromise (Promise &promise, const Player &player, bool due, const GameDateValue &date, Inbox &inbox)
 
void evaluateSigningPromise (Promise &promise, bool due, const GameDateValue &date, Inbox &inbox)
 
void resolvePromise (Promise &promise, PromiseState outcome, PromiseVoidReason reason, const GameDateValue &date, Inbox &inbox)
 
void raiseRequests (const GameDateValue &date, TeamID managed_team_id, Inbox &inbox)
 
bool resolveIgnoredRequest (Player &player, PlayerDynamics &dynamics, PlayerRelation &relation, const GameDateValue &date, std::int32_t today, Inbox &inbox)
 
TalkRequest requestForPlayer (const Player &player, const PlayerDynamics &dynamics, const PlayerRelation &relation, const GameDateValue &date, std::int32_t today) const
 
void spreadLeaderMood (TeamID managed_team_id, const GameDateValue &date)
 
PlayerRelation & relationFor (PlayerID player_id)
 
float firstTeamThreshold (TeamID team_id) const
 

Private Attributes

std::shared_ptr< GameData > gamedata
 
std::function< SquadRole(PlayerID)> role_of
 
InteractionState state
 
std::unordered_map< TeamID, TeamTalkRecord > team_talks
 

Detailed Description

Relations, promises, requests and team talks of the managed club.

Owned by WorldSimulation; all randomness is keyed by the world seed, the day and the player so that a reloaded save continues identically.

Constructor & Destructor Documentation

◆ InteractionSystem()

InteractionSystem::InteractionSystem ( std::shared_ptr< GameData >  gamedata,
std::function< SquadRole(PlayerID)>  role_of 
)

role_of gives a player's playing-time expectation in his squad.

Member Function Documentation

◆ adjustTrust()

float InteractionSystem::adjustTrust ( PlayerID  player_id,
float  delta 
)

Moves a player's trust by delta (decision moments); returns the change applied after clamping.

◆ blockFor()

TalkBlock InteractionSystem::blockFor ( const Player &  player,
TalkOption  option,
const TalkContext &  context,
const GameDateValue &  date,
TeamID  managed_team_id,
std::int32_t &  cooldown 
) const
private

◆ canGiveTeamTalk()

bool InteractionSystem::canGiveTeamTalk ( TeamID  team_id,
TeamTalkMoment  moment,
const GameDateValue &  date 
) const

True when this moment's talk has not been given for this match.

◆ cohesionModifier()

float InteractionSystem::cohesionModifier ( TeamID  team_id,
const GameDateValue &  date 
) const

Cohesion modifier of a club (0 when unknown / not managed).

◆ contextFor()

TalkContext InteractionSystem::contextFor ( const Player &  player,
const GameDateValue &  date,
float  manager_standing 
) const
private

◆ dressingRoom()

DressingRoom InteractionSystem::dressingRoom ( TeamID  team_id,
const GameDateValue &  date 
) const

◆ evaluateContractPromise()

void InteractionSystem::evaluateContractPromise ( Promise &  promise,
const Player &  player,
bool  due,
const GameDateValue &  date,
Inbox &  inbox 
)
private

◆ evaluatePlayingTimePromise()

void InteractionSystem::evaluatePlayingTimePromise ( Promise &  promise,
const Player &  player,
bool  due,
const GameDateValue &  date,
std::int32_t  today,
Inbox &  inbox 
)
private

◆ evaluatePromise()

void InteractionSystem::evaluatePromise ( Promise &  promise,
const Player &  player,
bool  due,
const GameDateValue &  date,
std::int32_t  today,
Inbox &  inbox 
)
private

◆ evaluatePromises()

void InteractionSystem::evaluatePromises ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox 
)
private

◆ evaluateSigningPromise()

void InteractionSystem::evaluateSigningPromise ( Promise &  promise,
bool  due,
const GameDateValue &  date,
Inbox &  inbox 
)
private

◆ firstTeamThreshold()

float InteractionSystem::firstTeamThreshold ( TeamID  team_id) const
private

◆ getState()

const InteractionState & InteractionSystem::getState ( ) const
inline

◆ giveTeamTalk()

std::optional< TeamTalkResult > InteractionSystem::giveTeamTalk ( const TeamTalkContext &  context,
TeamID  team_id,
TeamTalkTone  tone 
)

Gives the talk once per moment and match; applies morale changes.

◆ hasActivePromise()

bool InteractionSystem::hasActivePromise ( PlayerID  player_id,
PromiseType  type 
) const
private

◆ load()

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

◆ moraleTargetOffset()

float InteractionSystem::moraleTargetOffset ( PlayerID  player_id) const

Weekly morale target offset of a player (trust and open requests).

◆ onBidRejected()

float InteractionSystem::onBidRejected ( const GameDateValue &  date,
PlayerID  player_id,
const std::string &  buyer_name,
float  morale_delta,
float  trust_delta,
bool  transfer_request,
Inbox &  inbox 
)

The club turned down a bid the player wanted to hear more about: his morale falls by morale_delta scaled by his temperament, trust by trust_delta, and with transfer_request he asks to leave. Posts his reaction to the inbox. Returns the morale change applied.

◆ onDayAdvanced()

void InteractionSystem::onDayAdvanced ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox 
)

Daily promise evaluation (exactly once per day) and weekly requests.

◆ onMatchPlayed()

void InteractionSystem::onMatchPlayed ( const MatchReport &  report,
TeamID  managed_team_id 
)

Playing-time promise progress; clears the match's team talks.

◆ onTransferCompleted()

void InteractionSystem::onTransferCompleted ( const GameDateValue &  date,
PlayerID  player_id,
TeamID  from_team_id,
TeamID  to_team_id,
TeamID  managed_team_id,
Inbox &  inbox 
)

Arrival dates, voided promises, signing promises.

◆ onWeek()

void InteractionSystem::onWeek ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox 
)

Weekly: trust drift, leader influence, request lifecycle.

◆ optionBlockFor()

TalkBlock InteractionSystem::optionBlockFor ( const Player &  player,
TalkOption  option,
const TalkContext &  context,
const GameDateValue &  date,
TeamID  managed_team_id 
) const
private

◆ options()

std::vector< TalkOptionView > InteractionSystem::options ( PlayerID  player_id,
const GameDateValue &  date,
TeamID  managed_team_id,
float  manager_standing 
) const

Options for a managed player with availability and hints.

◆ pendingRequests()

std::vector< PlayerID > InteractionSystem::pendingRequests ( ) const

Managed players with an unanswered request.

◆ promises()

const std::vector< Promise > & InteractionSystem::promises ( ) const
inline

◆ promisesFor()

std::vector< Promise > InteractionSystem::promisesFor ( PlayerID  player_id) const

Promises made to a player (all states), newest first.

◆ raiseRequests()

void InteractionSystem::raiseRequests ( const GameDateValue &  date,
TeamID  managed_team_id,
Inbox &  inbox 
)
private

◆ relation()

const PlayerRelation * InteractionSystem::relation ( PlayerID  player_id) const

◆ relationFor()

PlayerRelation & InteractionSystem::relationFor ( PlayerID  player_id)
private

◆ requestForPlayer()

TalkRequest InteractionSystem::requestForPlayer ( const Player &  player,
const PlayerDynamics &  dynamics,
const PlayerRelation &  relation,
const GameDateValue &  date,
std::int32_t  today 
) const
private

◆ resolveIgnoredRequest()

bool InteractionSystem::resolveIgnoredRequest ( Player &  player,
PlayerDynamics &  dynamics,
PlayerRelation &  relation,
const GameDateValue &  date,
std::int32_t  today,
Inbox &  inbox 
)
private

◆ resolvePromise()

void InteractionSystem::resolvePromise ( Promise &  promise,
PromiseState  outcome,
PromiseVoidReason  reason,
const GameDateValue &  date,
Inbox &  inbox 
)
private

◆ restore()

void InteractionSystem::restore ( InteractionState  restored)

◆ save()

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

◆ signingDeadline()

std::optional< GameDateValue > InteractionSystem::signingDeadline ( const GameDateValue &  date,
LeagueID  league 
)
static

Deadline of a signing promise made on date by a club of league (end of its next window within 120 days), nullopt if no window is that close.

◆ spreadLeaderMood()

void InteractionSystem::spreadLeaderMood ( TeamID  managed_team_id,
const GameDateValue &  date 
)
private

◆ talk()

std::optional< TalkOutcome > InteractionSystem::talk ( PlayerID  player_id,
TalkOption  option,
const GameDateValue &  date,
TeamID  managed_team_id,
float  manager_standing 
)

Holds the conversation line and applies morale, trust, promises and request changes. Returns nullopt when the option is not available. Listing the player (list_player) is left to the caller.

◆ teamTalkContext()

TeamTalkContext InteractionSystem::teamTalkContext ( TeamID  team_id,
TeamTalkMoment  moment,
const GameDateValue &  date 
) const

Listeners of the managed club's talk: its selected XI.

◆ teamTalkModifier()

float InteractionSystem::teamTalkModifier ( TeamID  team_id,
const GameDateValue &  date,
int  half 
) const

Execution-quality modifier of the team's talks for half (1 or 2) of its match on date: the pre-match talk counts fully in the first half and half in the second, where the half-time talk adds; the total is capped at +-TOTAL_CAP. 0 on any other day.

Member Data Documentation

◆ gamedata

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

◆ role_of

std::function<SquadRole(PlayerID)> InteractionSystem::role_of
private

◆ state

InteractionState InteractionSystem::state
private

◆ team_talks

std::unordered_map<TeamID, TeamTalkRecord> InteractionSystem::team_talks
private

Transient.


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