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.
120 : filePath(std::move(filePath)) {
121 load();
122 }
◆ addScore()
| void anonymous_namespace{tetris.cpp}::HighScores::addScore |
( |
std::string | name, |
|
|
int | score ) |
|
inline |
Definition at line 124 of file tetris.cpp.
124 {
125 normalizeName(name);
126 scoreEntries.push_back({std::move(name), score});
127 sortAndTrim();
129 }
◆ bestScore()
| int anonymous_namespace{tetris.cpp}::HighScores::bestScore |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 142 of file tetris.cpp.
142 {
143 return scoreEntries.empty() ? 0 : scoreEntries.front().score;
144 }
◆ entries()
| const std::vector< HighScoreEntry > & anonymous_namespace{tetris.cpp}::HighScores::entries |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 138 of file tetris.cpp.
138 {
139 return scoreEntries;
140 }
◆ qualifies()
| bool anonymous_namespace{tetris.cpp}::HighScores::qualifies |
( |
int | score | ) |
const |
|
inlinenodiscard |
Definition at line 131 of file tetris.cpp.
131 {
132 if (scoreEntries.size() < MAX_ENTRIES) {
133 return true;
134 }
135 return score > scoreEntries.back().score;
136 }
◆ write()
| void anonymous_namespace{tetris.cpp}::HighScores::write |
( |
| ) |
const |
|
inline |
Definition at line 146 of file tetris.cpp.
146 {
147 std::ofstream out(filePath, std::ios::trunc);
148 if (!out.is_open()) {
149 return;
150 }
151
152 for (const HighScoreEntry &entry : scoreEntries) {
153 out << entry.name << ':' << entry.score << '\n';
154 }
155 }
The documentation for this class was generated from the following file: