|
Player12
An open source football management simulator
|
Detects story triggers for the managed club and posts them. More...
#include <stories.h>
Public Member Functions | |
| StoryEngine (std::shared_ptr< GameData > gamedata) | |
| void | setCareerProvider (std::function< CareerTotals(PlayerID)> provider) |
| void | onDayAdvanced (const GameDateValue &date, TeamID managed_team_id, const InteractionSystem &interactions, Inbox &inbox, const StoryDayContext &context={}) |
| void | onMatchPlayed (const MatchReport &report, TeamID managed_team_id, const std::string &recent_form, Inbox &inbox) |
| void | onTransferBid (const GameDateValue &date, PlayerID player_id, TeamID bidder_id, bool key_player, TeamID managed_team_id, Inbox &inbox) |
| void | onPlayerLeft (PlayerID player_id) |
| void | onSeasonStart () |
| std::optional< TeamID > | rivalOf (TeamID team_id) const |
| std::optional< StoryChoice > | choiceFor (PlayerID player_id, std::int32_t today) const |
| void | resolveChoice (PlayerID player_id) |
| const Dilemma * | openDilemma () const |
| const Dilemma * | dilemmaOn (std::int32_t day) const |
| std::optional< DilemmaEffects > | previewDilemma (int option, TeamID managed_team_id) const |
| bool | resolveDilemma (int option, const GameDateValue &date, TeamID managed_team_id, InteractionSystem &interactions, Inbox &inbox) |
| bool | follow (PlayerID player_id, const GameDateValue &date) |
| bool | unfollow (PlayerID player_id) |
| bool | isFollowed (PlayerID player_id) const |
| const std::vector< FollowedPlayer > & | getFollows () const |
| const StoryState & | getState () const |
| void | restore (StoryState restored) |
| void | load (const std::shared_ptr< DatabaseConnection > &db_conn) |
| void | save (const std::shared_ptr< DatabaseConnection > &db_conn) const |
Private Member Functions | |
| bool | fired (StoryKind kind, std::uint32_t entity, std::uint32_t key) const |
| bool | firedSince (StoryKind kind, std::uint32_t entity, std::int32_t since_day) const |
| bool | post (const GameDateValue &date, StoryKind kind, std::uint32_t entity, std::uint32_t key, const char *title_key, const char *body_key, std::vector< std::string > args, std::optional< PlayerID > player_id, std::optional< TeamID > team_id, Inbox &inbox, bool with_choice=false) |
| CareerTotals | careerBefore (PlayerID player_id) |
| void | trackFollows (const GameDateValue &date, TeamID managed_team_id, const AwardSystem *awards, Inbox &inbox) |
| void | followMatch (const MatchReport &report, TeamID managed_team_id, Inbox &inbox) |
| void | raiseDilemma (const GameDateValue &date, TeamID managed_team_id, const InteractionSystem &interactions, const StoryDayContext &context, Inbox &inbox) |
Private Attributes | |
| std::shared_ptr< GameData > | gamedata |
| StoryState | state |
| std::function< CareerTotals(PlayerID)> | career_provider |
| std::unordered_map< PlayerID, CareerTotals > | career_cache |
| std::unordered_map< TeamID, std::optional< TeamID > > | rivals |
Detects story triggers for the managed club and posts them.
|
explicit |
|
private |
| std::optional< StoryChoice > StoryEngine::choiceFor | ( | PlayerID | player_id, |
| std::int32_t | today | ||
| ) | const |
Open decision for a player, if any.
| const Dilemma * StoryEngine::dilemmaOn | ( | std::int32_t | day | ) | const |
The moment raised on day (open or not).
|
private |
|
private |
| bool StoryEngine::follow | ( | PlayerID | player_id, |
| const GameDateValue & | date | ||
| ) |
Starts following player_id (false if unknown, followed or full).
|
private |
|
inline |
|
inline |
| bool StoryEngine::isFollowed | ( | PlayerID | player_id | ) | const |
| void StoryEngine::load | ( | const std::shared_ptr< DatabaseConnection > & | db_conn | ) |
| void StoryEngine::onDayAdvanced | ( | const GameDateValue & | date, |
| TeamID | managed_team_id, | ||
| const InteractionSystem & | interactions, | ||
| Inbox & | inbox, | ||
| const StoryDayContext & | context = {} |
||
| ) |
Daily: long-injury tracking, captain disputes (weekly), expiries, followed players' news and decision moments (never on match day).
| void StoryEngine::onMatchPlayed | ( | const MatchReport & | report, |
| TeamID | managed_team_id, | ||
| const std::string & | recent_form, | ||
| Inbox & | inbox | ||
| ) |
Debut, breakout, milestones, comeback, poor run and rivalry of the managed club; big matches of followed players anywhere.
| void StoryEngine::onPlayerLeft | ( | PlayerID | player_id | ) |
A player left: his open choices lapse.
| void StoryEngine::onSeasonStart | ( | ) |
Rivals are recomputed at the start of each season.
| void StoryEngine::onTransferBid | ( | const GameDateValue & | date, |
| PlayerID | player_id, | ||
| TeamID | bidder_id, | ||
| bool | key_player, | ||
| TeamID | managed_team_id, | ||
| Inbox & | inbox | ||
| ) |
Transfer saga: a second bid within a month for a key player.
| const Dilemma * StoryEngine::openDilemma | ( | ) | const |
The open decision moment, if any.
|
private |
Posts when the weekly cap allows; records the story either way.
| std::optional< DilemmaEffects > StoryEngine::previewDilemma | ( | int | option, |
| TeamID | managed_team_id | ||
| ) | const |
Effects of option for the open moment of managed_team_id.
|
private |
| void StoryEngine::resolveChoice | ( | PlayerID | player_id | ) |
The manager answered (or dismissed) the player's story.
| bool StoryEngine::resolveDilemma | ( | int | option, |
| const GameDateValue & | date, | ||
| TeamID | managed_team_id, | ||
| InteractionSystem & | interactions, | ||
| Inbox & | inbox | ||
| ) |
Answers the open moment with option (0 or 1): applies its effects to the players, their trust (through interactions) and the club's ledger, records the answer and files a note. False when nothing is open or the option is invalid.
| void StoryEngine::restore | ( | StoryState | restored | ) |
Same-league club of the nearest reputation (lower id on ties).
| void StoryEngine::save | ( | const std::shared_ptr< DatabaseConnection > & | db_conn | ) | const |
| void StoryEngine::setCareerProvider | ( | std::function< CareerTotals(PlayerID)> | provider | ) |
Competitive career totals before the match being processed (the competitions record a result after the world simulation). Queried once per player and session, then kept up to date from match reports.
|
private |
| bool StoryEngine::unfollow | ( | PlayerID | player_id | ) |
|
private |
Transient cache of career totals, advanced from match reports.
|
private |
|
private |
|
private |