Modern UI: the live ticker replays the last kickoff's matches

ModernSession::read_live answers the ticker's fixture and frame queries with
the engine's recording of the last session.advance: the matches of human
managers with their owners, frames in minute order (kickoff, every event,
half time, the end) with score, chances, cards and players on the pitch, the
event lines, and the day's other matches as the conference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 09:37:37 +01:00
1 parent 1400848387
commit fda4b72967
6 files changed
+213

No files matched your search

+25
View File
@@ -424,6 +424,31 @@ int main(int argc, char** argv) {
std::printf("(date now %s)\n", s(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "meta"), "date")).c_str());
std::printf("(%d contract decisions answered)\n", decisions);
}
// the live ticker: advance until a kickoff played a match of the human manager, then its recording
{
J fixture;
for (int k = 0; k < 12; ++k) {
fixture = session.read_live(O{{"kind", "fixture"}});
if (truth(at(fixture, "ok"))) break;
check(s(at(fixture, "error")) == "live_no_human_match", "no human match: said so");
session.ui_command(cmd("request:lv" + std::to_string(k), "session.advance", O{}), rev);
}
const auto* frames = at(fixture, "frames").array();
const auto* matches = at(fixture, "matches").array();
check(truth(at(fixture, "ok")) && s(at(fixture, "source")) == "engine-recording" && frames && frames->size() >= 4 &&
matches && !matches->empty() && at(fixture, "owners").array() && !at(fixture, "owners").array()->empty(),
"live fixture of the last kickoff");
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");
// 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(),
at(fixture, "conference").array() ? at(fixture, "conference").array()->size() : 0, cli::dump_json(m).c_str());
}
check(s(at(session.read_live(O{{"kind", "frame"}, {"sequence", 99999}}), "error")) == "invalid_live_sequence", "bad sequence");
}
// almanac view after the kickoffs: index, calendar, day, match
{
const J index = session.read_almanac(O{{"kind", "index"}});