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

Chronological list of messages with read tracking. More...

#include <inbox.h>

Public Member Functions

std::uint32_t add (InboxMessage message)
 
const InboxView & getView () const
 
void setView (const InboxView &updated)
 
bool markRead (std::uint32_t id)
 
void markAllRead ()
 
std::size_t unreadCount () const
 
const std::vector< InboxMessage > & getMessages () const
 
void restore (std::vector< InboxMessage > messages)
 

Static Public Member Functions

static bool isRoutine (const std::string &title_key)
 
static bool isDigested (const std::string &title_key)
 
static InboxAction actionFor (const std::string &title_key)
 
static bool isDecision (InboxAction action)
 
static bool isArchived (const InboxMessage &message, const GameDateValue &today)
 
static bool matchesView (const InboxMessage &message, const InboxView &view, std::span< const PlayerID > followed)
 

Static Public Attributes

static constexpr std::size_t MAX_MESSAGES = 400
 
static constexpr std::int32_t DIGEST_DAYS = 7
 
static constexpr std::int32_t ARCHIVE_DAYS = 14
 

Private Attributes

std::vector< InboxMessage > messages
 
std::uint32_t next_id = 1
 
InboxView view
 

Detailed Description

Chronological list of messages with read tracking.

The inbox keeps the newest MAX_MESSAGES messages; older ones are dropped. Only news that needs the manager's attention arrives unread: routine round-ups (transfer news, instalments) are filed as read, and repeated offers of the same kind (bids and loan offers for the club's players) are grouped into a weekly digest with a single unread message.

Member Function Documentation

◆ actionFor()

InboxAction Inbox::actionFor ( const std::string &  title_key)
static

Action offered by messages with this title key.

◆ add()

std::uint32_t Inbox::add ( InboxMessage  message)

Appends a message, assigns its id and returns it.

◆ getMessages()

const std::vector< InboxMessage > & Inbox::getMessages ( ) const

Messages, oldest first.

◆ getView()

const InboxView & Inbox::getView ( ) const
inline

Saved filters of the inbox screen.

◆ isArchived()

bool Inbox::isArchived ( const InboxMessage &  message,
const GameDateValue &  today 
)
static

Read information older than ARCHIVE_DAYS on today.

◆ isDecision()

bool Inbox::isDecision ( InboxAction  action)
static

Actions that ask for a decision (pinned while pending).

◆ isDigested()

bool Inbox::isDigested ( const std::string &  title_key)
static

Messages grouped into a weekly digest (one unread per week).

◆ isRoutine()

bool Inbox::isRoutine ( const std::string &  title_key)
static

Routine news that is filed as read on arrival.

◆ markAllRead()

void Inbox::markAllRead ( )

Marks every message as read.

◆ markRead()

bool Inbox::markRead ( std::uint32_t  id)

Marks a message as read; false if the id is unknown.

◆ matchesView()

bool Inbox::matchesView ( const InboxMessage &  message,
const InboxView &  view,
std::span< const PlayerID >  followed 
)
static

True when message passes the information filters of view: category, unread, the chosen player or club, and the followed players (followed) when followed_only is set.

◆ restore()

void Inbox::restore ( std::vector< InboxMessage >  messages)

Replaces the content with persisted messages.

◆ setView()

void Inbox::setView ( const InboxView &  updated)
inline

◆ unreadCount()

std::size_t Inbox::unreadCount ( ) const

Number of unread messages.

Member Data Documentation

◆ ARCHIVE_DAYS

constexpr std::int32_t Inbox::ARCHIVE_DAYS = 14
staticconstexpr

Days after which read information leaves the main list.

◆ DIGEST_DAYS

constexpr std::int32_t Inbox::DIGEST_DAYS = 7
staticconstexpr

Window of the weekly digest of repeated offers and workload advice.

◆ MAX_MESSAGES

constexpr std::size_t Inbox::MAX_MESSAGES = 400
staticconstexpr

◆ messages

std::vector<InboxMessage> Inbox::messages
private

◆ next_id

std::uint32_t Inbox::next_id = 1
private

◆ view

InboxView Inbox::view
private

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