Bind league tables strengths and live profiles to engine reads (by Codex)

This commit is contained in:
Codex committed 2026-10-28 21:53:18 +01:00
1 parent f9e8719b2d
commit 1c35698dbe
24 files changed
+463 -20

No files matched your search

+9 -8
View File
@@ -20,26 +20,27 @@ std::string report_zone(int rank, int count, int tier) {
std::string App::report_club_button(const std::string &id, bool name_first) {
const auto *c = world_->find("clubs", id);
if (!c)
const auto live=engine_mode_?engine_report_team(id):Json();
if ((engine_mode_&&live.is_null())||(!engine_mode_&&!c))
return "<span>—</span>";
const auto name = esc(world_->name(*c));
const auto name = esc(engine_mode_?live.at("name").get<std::string>():world_->name(*c));
const auto text = "<span class=\"report-club-name\" title=\"" + name +
"\">" + name + "</span>";
return btn("club-detail", name_first ? text + crest(c, 42) : crest(c, 42) + text,
std::string("report-club-button ") + (name_first ? "name-first " : "") +
(snap().state.at("career").value("role","club")=="club"&&manager(snap()).value("club", "") == id ? "current" : ""),
((engine_mode_?engine_data_.at("desktop").at("meta").at("scope").at("teamId")==id:snap().state.at("career").value("role","club")=="club"&&manager(snap()).value("club", "") == id) ? "current" : ""),
"id=\"report-club-" + esc(id) + "\" data-id=\"" + esc(id) + "\"");
}
std::string App::render_reports(const std::string &mode) {
const auto snapshot = snap();
const auto &state = snapshot.state.at("reports");
const auto snapshot = engine_mode_?Snapshot{}:snap();
const auto state = engine_mode_?engine_reports_state_:snapshot.state.at("reports");
const auto *league = world_->find("competitions", state.value("league", ""));
const int tier = league ? league->value("tier", 1) : 1;
const bool strengths = mode == "strengths", matches = mode == "league" || mode == "other";
const bool opening = mode == "other" && state.value("competition", 0) == 3 &&
snapshot.state.value("opening_created", false);
const auto rows = matches ? (opening ? report_opening_pairs(*world_, snapshot.state.at("opening_flow"))
const auto rows = engine_mode_?engine_reports_rows(mode):matches ? (opening ? report_opening_pairs(*world_, snapshot.state.at("opening_flow"))
: report_match_rows(*world_, state, mode == "other"))
: strengths ? report_strength_rows(*world_, state)
: report_table_rows(*world_, state);
@@ -126,7 +127,7 @@ std::string App::render_reports(const std::string &mode) {
body += report_club_button(row.at(column == 0 ? "home" : "away").get<std::string>(), column == 0);
else if (!matches && column == 0) {
if (!strengths) {
const auto zone = report_zone(row.value("rank", 0), int(rows.size()), tier);
const auto zone = engine_mode_?std::string():report_zone(row.value("rank", 0), int(rows.size()), tier);
body += "<span class=\"report-zone " + zone + "\"></span><span class=\"report-rank\"><span>" +
std::to_string(row.value("rank", 0)) + ".</span></span>";
}
@@ -149,7 +150,7 @@ std::string App::render_reports(const std::string &mode) {
body += "</div>";
}
body += "</div></div>";
if (!matches && !strengths) {
if (!matches && !strengths && !engine_mode_) {
const auto legend = tier == 1
? std::vector<std::pair<std::string, std::string>>{
{"champions", "Champions League"}, {"europa", "Europa League"},