Show recorded manager achievements and career history (by Codex)
This commit is contained in:
1 parent
179cd970ad
commit
9101770614
18 files changed
+442
-29
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
int App::career_max_page() const {
|
||||
if (!engine_mode_)
|
||||
return 4;
|
||||
const auto &r = engine_data_.at("achievements");
|
||||
return r.value("messageType", "") == "snapshot" &&
|
||||
!r.at("data").at("records").empty()
|
||||
? int((r.at("data").at("records").size() - 1) / 8)
|
||||
: 0;
|
||||
}
|
||||
Json App::achievements_data(int page) const {
|
||||
if (!engine_mode_) {
|
||||
const auto s = snap();
|
||||
return s.world ? demo_achievements(*s.world, s.state, page)
|
||||
: Json{{"ok", false}, {"available", false}};
|
||||
}
|
||||
const auto *club = world_->find(
|
||||
"clubs", engine_data_.at("desktop").at("meta").at("scope").at("teamId"));
|
||||
const auto nation = club ? club->value("nation", Json()) : Json();
|
||||
Json leagues = Json::object();
|
||||
for (const auto &l : world_->rows("competitions"))
|
||||
if (l.value("type", "") == "league" && l.value("nation", Json()) == nation)
|
||||
leagues[l.at("id").get<std::string>()] = {
|
||||
{"name", world_->name(l)}, {"tier", l.value("tier", Json())}};
|
||||
return engine_achievements_projection(engine_data_, leagues, page);
|
||||
}
|
||||
Reference in new issue
Block a user