Definition at line 117 of file tetris.cpp.
◆ HighScores()
| anonymous_namespace{tetris.cpp}::HighScores::HighScores |
( |
std::filesystem::path | filePath | ) |
|
|
inlineexplicit |
Definition at line 119 of file tetris.cpp.
119: filePath(std::move(filePath)) { load(); }
◆ addScore()
| void anonymous_namespace{tetris.cpp}::HighScores::addScore |
( |
std::string | name, |
|
|
int | score ) |
|
inline |
Definition at line 121 of file tetris.cpp.
121 {
122 normalizeName(name);
123 scoreEntries.push_back({std::move(name), score});
124 sortAndTrim();
126 }
◆ bestScore()
| int anonymous_namespace{tetris.cpp}::HighScores::bestScore |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 137 of file tetris.cpp.
137{ return scoreEntries.empty() ? 0 : scoreEntries.front().score; }
◆ entries()
| const std::vector< HighScoreEntry > & anonymous_namespace{tetris.cpp}::HighScores::entries |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 135 of file tetris.cpp.
135{ return scoreEntries; }
◆ qualifies()
| bool anonymous_namespace{tetris.cpp}::HighScores::qualifies |
( |
int | score | ) |
const |
|
inlinenodiscard |
Definition at line 128 of file tetris.cpp.
128 {
129 if (scoreEntries.size() < MAX_ENTRIES) {
130 return true;
131 }
132 return score > scoreEntries.back().score;
133 }
◆ write()
| void anonymous_namespace{tetris.cpp}::HighScores::write |
( |
| ) |
const |
|
inline |
Definition at line 139 of file tetris.cpp.
139 {
140 std::ofstream out(filePath, std::ios::trunc);
141 if (!out.is_open()) {
142 return;
143 }
144
145 for (const HighScoreEntry &entry : scoreEntries) {
146 out << entry.name << ':' << entry.score << '\n';
147 }
148 }
The documentation for this class was generated from the following file: