25 std::chrono::steady_clock::time_point
until;
38 using Clock = std::chrono::steady_clock;
57 void prune(Clock::time_point now);
61 [[nodiscard]]
const std::vector<PlayerNotice>&
shown() const noexcept;
67 void add(std::uint8_t player, std::
string text,
Clock::time_point now);
68 [[nodiscard]] std::
string name_of(std::uint8_t player) const;
70 std::array<std::
string, tuning::max_players> names_;
72 std::optional<std::uint32_t> first_tick_;
Turns PlayerJoined and PlayerLeft events into messages for the players who stay.
Definition player_notices.hpp:35
void remember(const std::array< std::optional< RemotePlayer >, tuning::max_players > &players)
Keeps the names of the players, for the next PlayerLeft.
const std::vector< PlayerNotice > & shown() const noexcept
Messages to show, oldest first.
void prune(Clock::time_point now)
Drops the messages whose time is over.
static constexpr std::size_t max_shown
Most messages shown at once: a new one pushes out the oldest.
Definition player_notices.hpp:42
static constexpr std::chrono::seconds shown_for
How long a message stays.
Definition player_notices.hpp:40
void clear() noexcept
Forgets the messages and names, for a new session.
void handle(const GameEvent &event, Clock::time_point now)
Adds the message of an event, if it is a PlayerJoined or a PlayerLeft.
std::chrono::steady_clock Clock
Clock of the messages.
Definition player_notices.hpp:38
The client's copy of the server's world, built from snapshots and events.
Gameplay events sent to the clients (RFC section 4.4): spawns, destructions, deaths,...
constexpr std::size_t max_players
Players in one game, as the subject requires.
Definition tuning.hpp:33
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
LeaveReason
Why a player left the game, in PlayerLeft.
Definition events.hpp:49
std::variant< SpawnEvent, DestroyEvent, DeathEvent, PlayerJoinedEvent, PlayerLeftEvent > GameEvent
One of the gameplay events the server sends.
Definition events.hpp:160
std::string left_message(const std::string &name, LeaveReason reason)
Sentence telling why a player left.
A message about a player, shown for a few seconds.
Definition player_notices.hpp:19
std::chrono::steady_clock::time_point until
When the message goes away.
Definition player_notices.hpp:25
std::string text
Sentence shown, such as "Lolo left the game".
Definition player_notices.hpp:23
std::uint8_t player
Player number, 0 to 3, for the color of its slot.
Definition player_notices.hpp:21
Gameplay values of R-Type: play area, speeds, sizes, health, lives and scores.