| 19 | } |
| 20 | |
| 21 | void Statistics::writeStatistics() { |
| 22 | auto versioningDatabase = Root::singleton().versioningDatabase(); |
| 23 | String filename = File::relativeTo(m_storageDirectory, "statistics"); |
| 24 | |
| 25 | Json stats = JsonObject::from(m_stats.pairs().transformed([](auto const& entry) { |
| 26 | return make_pair(entry.first, entry.second.toJson()); |
| 27 | })); |
| 28 | JsonObject storage = { |
| 29 | { "stats", stats }, |
| 30 | { "achievements", jsonFromStringSet(m_achievements) } |
| 31 | }; |
| 32 | |
| 33 | auto versionedStorage = versioningDatabase->makeCurrentVersionedJson("Statistics", storage); |
| 34 | VersionedJson::writeFile(versionedStorage, filename); |
| 35 | } |
| 36 | |
| 37 | Json Statistics::stat(String const& name, Json def) const { |
| 38 | if (m_stats.contains(name)) |
no test coverage detected