Definition at line 157 of file main.cpp.
◆ HighScores() [1/3]
| anonymous_namespace{main.cpp}::HighScores::HighScores |
( |
std::filesystem::path | file_path | ) |
|
|
inlineexplicit |
Definition at line 159 of file main.cpp.
160 : file_path(std::move(file_path)) {
161 load();
162 }
◆ HighScores() [2/3]
| anonymous_namespace{main.cpp}::HighScores::HighScores |
( |
std::filesystem::path | file_path | ) |
|
|
inlineexplicit |
Definition at line 106 of file main.cpp.
107 : file_path(std::move(file_path)) {
108 load();
109 }
◆ HighScores() [3/3]
| anonymous_namespace{main.cpp}::HighScores::HighScores |
( |
std::string | filePath | ) |
|
|
inlineexplicit |
Definition at line 171 of file main.cpp.
172 : filePath(std::move(filePath)) {
173 read();
174 }
◆ ~HighScores()
| anonymous_namespace{main.cpp}::HighScores::~HighScores |
( |
| ) |
|
|
inline |
◆ add() [1/2]
| void anonymous_namespace{main.cpp}::HighScores::add |
( |
std::string | name, |
|
|
int | score ) |
|
inline |
Definition at line 164 of file main.cpp.
164 {
165 normalize(name);
166 entries.push_back({std::move(name), score});
167 sortAndTrim();
168 save();
169 }
◆ add() [2/2]
| void anonymous_namespace{main.cpp}::HighScores::add |
( |
std::string | name, |
|
|
int | score ) |
|
inline |
Definition at line 111 of file main.cpp.
111 {
112 normalize(name);
113 entries.push_back({std::move(name), score});
114 sortAndTrim();
115 save();
116 }
◆ addScore()
| void anonymous_namespace{main.cpp}::HighScores::addScore |
( |
const std::string & | name, |
|
|
int | shots ) |
|
inline |
Definition at line 180 of file main.cpp.
180 {
181 entries.push_back({name, shots});
182 sort();
183 if (entries.size() > 10) {
184 entries.resize(10);
185 }
186 }
◆ list() [1/3]
| const std::vector< ScoreEntry > & anonymous_namespace{main.cpp}::HighScores::list |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 178 of file main.cpp.
178 {
179 return entries;
180 }
◆ list() [2/3]
| const std::vector< ScoreEntry > & anonymous_namespace{main.cpp}::HighScores::list |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 125 of file main.cpp.
125 {
126 return entries;
127 }
◆ list() [3/3]
| const std::vector< Score > & anonymous_namespace{main.cpp}::HighScores::list |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 195 of file main.cpp.
195 {
196 return entries;
197 }
◆ qualifies() [1/3]
| bool anonymous_namespace{main.cpp}::HighScores::qualifies |
( |
int | score | ) |
const |
|
inlinenodiscard |
Definition at line 171 of file main.cpp.
171 {
173 return true;
174 }
175 return score > entries.back().score;
176 }
◆ qualifies() [2/3]
| bool anonymous_namespace{main.cpp}::HighScores::qualifies |
( |
int | score | ) |
const |
|
inlinenodiscard |
Definition at line 118 of file main.cpp.
118 {
120 return true;
121 }
122 return score > entries.back().score;
123 }
◆ qualifies() [3/3]
| bool anonymous_namespace{main.cpp}::HighScores::qualifies |
( |
int | shots | ) |
const |
|
inlinenodiscard |
Definition at line 188 of file main.cpp.
188 {
189 if (entries.size() < 10) {
190 return true;
191 }
192 return shots < entries.back().shots;
193 }
◆ write()
| void anonymous_namespace{main.cpp}::HighScores::write |
( |
| ) |
const |
|
inline |
Definition at line 199 of file main.cpp.
199 {
200 std::ofstream out(filePath);
201 if (!out.is_open()) {
202 return;
203 }
204 for (const auto &entry : entries) {
205 out << entry.name << ':' << entry.shots << '\n';
206 }
207 }
The documentation for this class was generated from the following files: