Class which represents highscore database.
More...
#include <HighScore.h>
|
std::string | get_map_best_time (const std::string &map_id) |
| Gets string with the best time for map and with the name of user which beats this time. More...
|
|
std::string | get_user_best_time (const std::string &user, const std::string &map_id) |
| Gets string with the best user's time for map. More...
|
|
result | set_time (const std::string &user, const std::string &map_id, uint64_t time) |
| Set time for user on map. More...
|
|
void | to_stream (std::ofstream &ofs) |
| Writes high score database to the stream. More...
|
|
Class which represents highscore database.
◆ result
Enum which represents types of result for user on map according to the previous time of user.
Enumerator |
---|
bad_time | |
best_user_time | < Current time is worse than the previous.
|
best_map_time | < The best time of user.
< The best time for map.
|
◆ get_map_best_time()
std::string HighScore::get_map_best_time |
( |
const std::string & |
map_id | ) |
|
|
inline |
Gets string with the best time for map and with the name of user which beats this time.
- Parameters
-
- Returns
- The best time in format hh:mm:ss for map with the name of user which beats this time.
◆ get_user_best_time()
std::string HighScore::get_user_best_time |
( |
const std::string & |
user, |
|
|
const std::string & |
map_id |
|
) |
| |
|
inline |
Gets string with the best user's time for map.
- Parameters
-
user | Name of user. |
map_id | Identifier of map. |
- Returns
- The best time of user on map.
◆ set_time()
result HighScore::set_time |
( |
const std::string & |
user, |
|
|
const std::string & |
map_id, |
|
|
uint64_t |
time |
|
) |
| |
|
inline |
Set time for user on map.
Time is update if it is better than previous.
- Parameters
-
user | Name of user. |
map_id | Identifier of map. |
time | Time of user on map. |
- See also
- result TODO
- Returns
- Enum which represents if the best time was beaten and how.
◆ to_stream()
void HighScore::to_stream |
( |
std::ofstream & |
ofs | ) |
|
|
inline |
Writes high score database to the stream.
- Parameters
-
ofs | Stream which is highscore writen to. |
◆ map_highscore
std::unordered_map<std::string, std::string> HighScore::map_highscore |
|
private |
Unordered map.
Represents high score for map, for each map there is name of user which has the best time.
◆ user_highscore
std::unordered_map<std::string, std::unordered_map<std::string, uint64_t> > HighScore::user_highscore |
|
private |
Unordered map.
represents high score for user, for each user there is a unordered map with map and best time
The documentation for this class was generated from the following file: