Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
game_log.h
Go to the documentation of this file.
1#ifndef LOG_H
2#define LOG_H
3
4#include "message.h"
5
6#include <SFML/System.hpp>
7
8#include <vector>
9
14{
15public:
17 explicit game_log(const double display_time_secs);
18
20 void add_message(const message& m) noexcept;
21
25 std::string get_last_messages(const chess_color color) const;
26
28 void tick();
29
30private:
31 using elapsed_time_secs = float;
32
34 std::vector<std::pair<elapsed_time_secs, message>> m_timed_messages;
35
37 sf::Clock m_clock;
38
40 double m_display_time_secs;
41};
42
44std::string get_last_log_messages(
45 const game_log& l,
46 const chess_color color
47) noexcept;
48
50void test_log();
51
52#endif // LOG_H
chess_color
A chess piece color.
Definition chess_color.h:10
The text log in the game.
Definition game_log.h:14
void tick()
Update, so old messages are removed.
Definition game_log.cpp:84
void add_message(const message &m) noexcept
Add a message, timestamp will be added.
Definition game_log.cpp:15
std::string get_last_messages(const chess_color color) const
Get the last messages that were emitted at most 'max_elapsed_time_secs' seconds ago,...
Definition game_log.cpp:35
A message.
Definition message.h:15
void test_log()
Test this class and its free function.
Definition game_log.cpp:49
std::string get_last_log_messages(const game_log &l, const chess_color color) noexcept
Get the log messages for a specific color.
Definition game_log.cpp:27