Bind cup reports and linked competition phases to live engine data (by Codex)

This commit is contained in:
Codex committed 2026-10-28 23:03:36 +01:00
1 parent 545e16f153
commit 6b4aa9772d
26 files changed
+402 -33

No files matched your search

+22 -8
View File
@@ -38,7 +38,7 @@ std::string App::render_reports(const std::string &mode) {
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 &&
const bool opening = !engine_mode_ && mode == "other" && state.value("competition", 0) == 3 &&
snapshot.state.value("opening_created", false);
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"))
@@ -54,9 +54,11 @@ std::string App::render_reports(const std::string &mode) {
{"rank", "Pl. / Verein"}, {"played", "Sp."}, {"wins", "S"},
{"draw", "U"}, {"loss", "N"}, {"form", "Letzte 8"},
{"points", "Punkte"}, {"gf", "Tore"}, {"diff", "Diff."}};
const bool real_other=engine_mode_&&mode=="other";
const auto &fixture=real_other?engine_other_value_:engine_fixtures_value_;
std::vector<double> widths;
if (matches)
widths = {1224, 160, 1224}; // Match card has two 2dp borders.
widths = real_other?std::vector<double>{1184,240,1184}:std::vector<double>{1224,160,1224}; // Match card has two 2dp borders.
else if (strengths) {
widths.push_back(2612 * .38);
for (int i = 0; i < 5; ++i) widths.push_back(2612 * .62 / 5);
@@ -70,10 +72,11 @@ std::string App::render_reports(const std::string &mode) {
: rows.size() >= 20 ? (1682 - heading_height) / rows.size() : 80;
std::string body = "<div id=\"report-underlay\" class=\"report-underlay\">";
if (matches) {
const int round = engine_mode_?engine_fixtures_value_.at("round").get<int>()-1:std::clamp(state.value("round", 0), 0,
const int round = engine_mode_?fixture.at("round").get<int>()-1:std::clamp(state.value("round", 0), 0,
report_round_count(*world_, state, mode == "other") - 1);
std::string subtitle;
if(engine_mode_){const auto &l=engine_fixtures_value_.at("league");subtitle=(l.at("nationId").is_string()?world_->nation_name(l.at("nationId")):std::string())+" · "+l.at("name").get<std::string>();}
if(real_other)subtitle=fixture.at("name").get<std::string>();
else if(engine_mode_){const auto &l=fixture.at("league");subtitle=(l.at("nationId").is_string()?world_->nation_name(l.at("nationId")):std::string())+" · "+l.at("name").get<std::string>();}
else if (mode == "league" || state.value("competition", 0) == 0)
subtitle = (league ? world_->nation_name(league->value("nation", "")) : "") +
" · " + (league ? world_->name(*league) : "");
@@ -82,7 +85,7 @@ std::string App::render_reports(const std::string &mode) {
subtitle = choices.at(size_t(state.value("competition", 0))).second;
}
body += "<header class=\"report-match-heading\"><h2>" +
(opening ? std::string("1. Runde") : std::to_string(round + 1) + ". Spieltag") +
(real_other?fixture.at("heading").get<std::string>():opening ? std::string("1. Runde") : std::to_string(round + 1) + ". Spieltag") +
"</h2><p>" + esc(subtitle) + "</p></header>";
}
body += "<div id=\"report-list\" class=\"report-list " +
@@ -144,13 +147,24 @@ std::string App::render_reports(const std::string &mode) {
value = report_number(row["gf"]) + ":" + report_number(row["ga"]);
else
value = report_number(row.at(headings[column].first));
body += "<span class=\"report-value\">" + esc(value) + "</span>";
if(real_other&&matches) {
const auto phase=[](const Json &v){return v==1?std::string(" n.V."):v==2?std::string(" n.E."):std::string();};
value+=phase(row.at("phase"));
std::string detail;
if(row.at("secondLegVisible").get<bool>()) {
detail="Hin: "+(row.at("secondLeg").is_null()?std::string("–"):report_number(row.at("secondLeg")[0])+":"+report_number(row.at("secondLeg")[1])+phase(row.at("secondLegPhase")));
value="Rück: "+value;
} else if(row.at("status")=="scheduled"&&row.at("date").is_string())detail=row.at("date").get<std::string>();
body+="<div class=\"report-score-lines\"><span class=\"report-value\">"+esc(value)+"</span>"+(detail.empty()?"":"<span class=\"report-score-note\">"+esc(detail)+"</span>")+"</div>";
} else body += "<span class=\"report-value\">" + esc(value) + "</span>";
}
body += "</div>";
}
body += "</div>";
}
body += "</div></div>";
body += "</div>";
if(real_other&&rows.empty())body+="<p class=\"report-detail-empty\">"+std::string(!fixture.at("available").get<bool>()?"Diese Runde ist noch nicht ausgelost oder die vorherige Phase ist noch nicht abgeschlossen.":"Keine Paarungen vorhanden.")+"</p>";
body+="</div>";
if (!matches && !strengths && !engine_mode_) {
const auto legend = tier == 1
? std::vector<std::pair<std::string, std::string>>{
@@ -172,7 +186,7 @@ std::string App::render_reports(const std::string &mode) {
body += btn("report-round", i ? "›" : "‹", "report-round",
"id=\"report-round-" + std::string(i ? "next" : "previous") +
"\" data-id=\"" + (i ? "1" : "-1") + "\" style=\"" +
rect(i * 130, 0, 110, 94) + "\" " + ((opening||(engine_mode_&&(i?engine_fixtures_value_.at("round")==engine_fixtures_value_.at("rounds"):engine_fixtures_value_.at("round")==1))) ? "disabled" : ""));
rect(i * 130, 0, 110, 94) + "\" " + ((opening||(engine_mode_&&(i?fixture.at("round")==fixture.at("rounds"):fixture.at("round")==1))) ? "disabled" : ""));
body += mode == "league" ? report_picker("country", 260, 1060) + report_picker("league", 1340, 1272)
: report_picker("competition", 260, 2352);
} else if (strengths)