Modern UI: the almanac screen reads the recorded matches

ModernSession::read_almanac answers the almanac screen's request kinds
(index, calendar, day, match) from the engine's almanac in the demo's match
form: competition, sides with human managers, result split into regulation,
extra time (by the goal minutes) and shoot-out, referee, attendance, weather,
line-ups and events. Unknown line-ups stay null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 08:47:41 +01:00
1 parent ae817c6d6d
commit e82ce1649f
5 files changed
+170

No files matched your search

+22
View File
@@ -248,6 +248,28 @@ int main(int argc, char** argv) {
const std::string date_after = s(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "meta"), "date"));
check(date_after > date_before, "the date moved on");
}
// almanac view after the kickoffs: index, calendar, day, match
{
const J index = session.read_almanac(O{{"kind", "index"}});
const auto* years = at(index, "years").array();
check(truth(at(index, "ok")) && years && !years->empty() && *at(index, "match_count").integer() > 0, "almanac index");
const J cal = years && !years->empty() ? session.read_almanac(O{{"kind", "calendar"}, {"year", (*years)[0]}}) : J{};
const auto* days = at(cal, "days").array();
check(days && !days->empty(), "almanac calendar");
const J day = days && !days->empty() ? session.read_almanac(O{{"kind", "day"}, {"date", at((*days)[0], "date")}}) : J{};
const auto* matches = at(day, "matches").array();
check(matches && !matches->empty(), "almanac day");
if (matches && !matches->empty()) {
const J& m = (*matches)[0];
const auto* final_score = at(at(m, "result"), "final").array();
check(final_score && final_score->size() == 2 && at(at(m, "home"), "id").string() &&
at(m, "events").array(), "almanac match form");
const J one = session.read_almanac(O{{"kind", "match"}, {"id", at(m, "id")}});
check(truth(at(one, "ok")) && s(at(at(one, "match"), "id")) == s(at(m, "id")), "almanac match by id");
}
check(s(at(session.read_almanac(O{{"kind", "match"}, {"id", "match:0-0"}}), "error")) == "almanac_match_not_found",
"unknown match");
}
} catch (const std::exception& ex) {
std::fprintf(stderr, "FAIL: %s\n", ex.what());
return 1;