Modern UI contract: live table in the ticker

Each live frame carries the league tables of the ticker's matches: the
table before the matchday plus every match of that round at the frame's
minute, the final whistle using the recorded result. Frames carry only
changed tables; a single frame read gets the full standing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 13:59:02 +01:00
1 parent 74c1504e3a
commit eb5c5d6211
4 files changed
+109 -6

No files matched your search

+17 -1
View File
@@ -3,6 +3,7 @@
// envelope, identities, money, errors and that a read changes nothing. Needs game data
// (a Modern session on the Classic data).
#include <cstdio>
#include <map>
#include <string>
#include <variant>
@@ -510,6 +511,7 @@ int main(int argc, char** argv) {
// the live ticker: advance until a kickoff played a match of the human manager, then its recording
{
J fixture;
J live_final;
for (int k = 0; k < 12; ++k) {
fixture = session.read_live(O{{"kind", "fixture"}});
if (truth(at(fixture, "ok"))) break;
@@ -524,7 +526,8 @@ int main(int argc, char** argv) {
if (frames && frames->size() >= 4) {
const J& last = frames->back();
const J one = session.read_live(O{{"kind", "frame"}, {"sequence", int64_t(frames->size() - 1)}});
check(truth(at(one, "ok")) && cli::dump_json(at(one, "frame")) == cli::dump_json(last), "one frame by sequence");
check(truth(at(one, "ok")) && cli::dump_json(at(at(one, "frame"), "matches")) == cli::dump_json(at(last, "matches")), "one frame by sequence");
live_final = at(at(one, "frame"), "standings");
// the last frame's score is the recorded result of the match
const J m = at(at(last, "matches").array()->front(), "score");
std::printf("(live: %zu frames, %zu matches, conference %zu, final %s)\n", frames->size(), matches->size(),
@@ -538,6 +541,19 @@ int main(int argc, char** argv) {
check(s(at(post, "messageType")) == "snapshot" && steps && steps->size() == 5 && truth(at((*steps)[0], "available")) &&
at(pd, "matches").array() && !at(pd, "matches").array()->empty() && at(pd, "reportMatchIds").array() &&
!at(pd, "reportMatchIds").array()->empty(), "postmatch with results and report");
// the live table at the final whistle is the league table after the matchday
if (const auto* lt = live_final.array(); lt && !lt->empty() && at(pd, "tables").array()) {
std::map<std::string, int64_t> points;
for (const auto& t : *at(pd, "tables").array())
for (const auto& r : *at(t, "rows").array()) points[s(at(at(r, "club"), "id"))] = *at(r, "points").integer();
bool same = true;
for (const auto& r : *at(lt->front(), "rows").array()) {
const auto p = points.find(s(at(at(r, "team"), "id")));
same &= p != points.end() && p->second == *at(r, "points").integer();
}
std::printf("(live table: %zu leagues, %zu rows)\n", lt->size(), at(lt->front(), "rows").array()->size());
check(same, "live table at the final whistle equals the league table");
}
std::printf("(postmatch: %zu matches, %zu tables, %zu elevens)\n", at(pd, "matches").array()->size(),
at(pd, "tables").array() ? at(pd, "tables").array()->size() : 0,
at(pd, "teamOfTheDay").array() ? at(pd, "teamOfTheDay").array()->size() : 0);