Bind league fixtures and round navigation to live engine data (by Codex)

This commit is contained in:
Codex committed 2026-10-28 22:23:59 +01:00
1 parent 1c35698dbe
commit 545e16f153
21 files changed
+207 -31

No files matched your search

+6 -4
View File
@@ -165,13 +165,15 @@ J fixtures(const ModernState& g, int league, int matchday) {
const size_t at = size_t(league) * kResultsPerLeague + size_t(matchday - 1) * 10 + m;
const uint8_t r = at < g.results.size() ? g.results[at] : kNotPlayed;
O match{{"home", club_json(g, fx[m].home)}, {"away", club_json(g, fx[m].away)}};
if (r == kNotPlayed) {
match["result"] = nullptr, match["status"] = "open";
} else if (r == 0xcd) {
match["result"] = nullptr, match["status"] = "postponed";
if ((r & 0xcc) == 0xcc) {
const uint8_t marker = r & 0xcf;
match["result"] = nullptr;
match["status"] = marker == 0xcc ? "open" : marker == 0xcd ? "postponed"
: marker == 0xce ? "rescheduled" : "unavailable";
} else {
match["result"] = A{J(int(r >> 4)), J(int(r & 0xf))}, match["status"] = "played";
}
match["id"] = "fixture:league-" + std::to_string(league) + "-" + std::to_string(matchday) + "-" + std::to_string(m);
out.push_back(std::move(match));
}
return O{{"ok", true}, {"league", league_json(g, league)}, {"matchday", matchday}, {"matches", std::move(out)}};
+3
View File
@@ -9,6 +9,9 @@
// {kind: "leagues"} the leagues with size, matchdays and progress
// {kind: "table", league} a league's current table
// {kind: "fixtures", league, matchday?} a matchday's pairings and results
// Each match has a stable id, home/away club refs, status and result.
// Only played matches have [home, away] scores; open/postponed/rescheduled/
// unavailable matches have null results, including packed status variants.
// {kind: "squad", club?} a squad with names, values and fitness
#include "cli/json.hpp"
+15
View File
@@ -487,6 +487,21 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
A leagues;for(int l=0;l<kLeagueCount;++l)leagues.push_back(report_league(g,l,team_of(g,c.manager)));
return snapshot(request_id,std::move(m),O{{"kind","report-index"},{"leagues",std::move(leagues)}});
}
if(kind=="league-fixtures") {
const std::string id=text_field(request,"leagueId");int league=-1;
for(int l=0;l<kLeagueCount;++l)if(*std::get<O>(report_league(g,l,-1).value).at("id").string()==id){league=l;break;}
const auto* round=field(request,"round");
if(league<0||(round&&(!round->integer()||*round->integer()<1||*round->integer()>league_matchdays(league))))
return failure(request_id,"invalid_fixture_request","Liga oder Spieltag ist nicht verfügbar.",c.state_revision);
O query{{"kind","fixtures"},{"league",id}};
if(round)query["matchday"]=*round;
J data=query_projection(g,c.manager,query);
auto* values=std::get_if<O>(&data.value);
if(!values||!values->count("ok")||!std::holds_alternative<bool>(values->at("ok").value)||!std::get<bool>(values->at("ok").value))
return failure(request_id,"fixtures_unavailable","Die Paarungen sind derzeit nicht verfügbar.",c.state_revision);
values->erase("ok");(*values)["kind"]="league-fixtures";(*values)["leagueId"]=id;(*values)["round"]=values->at("matchday");(*values)["rounds"]=league_matchdays(league);
return snapshot(request_id,std::move(m),std::move(data));
}
if(kind=="league-report") {
const std::string id=text_field(request,"leagueId");int league=-1;
for(int l=0;l<kLeagueCount;++l)if(*std::get<O>(report_league(g,l,-1).value).at("id").string()==id){league=l;break;}