Modern UI contract: calendar read

club_calendar projects the season calendar of a club: the competitions
of each day and the club's league matches on the day of their round, or
on the replay day when moved or postponed. The calendar read lists a
date range of it with fixtures, status and results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 14:12:57 +01:00
1 parent 6e400d708c
commit d3d526c2e4
5 files changed
+138

No files matched your search

+21
View File
@@ -4,6 +4,7 @@
// (a Modern session on the Classic data).
#include <cstdio>
#include <map>
#include <set>
#include <string>
#include <variant>
@@ -415,6 +416,26 @@ int main(int argc, char** argv) {
const J again = session.ui_read(O{{"kind", "scheduling"}}, rev);
check(s(at(moved, "messageType")) == "command_result" && rev == before + 1 && at(at(again, "data"), "moved").array() &&
!at(at(again, "data"), "moved").array()->empty(), "league match moved");
// the calendar of the season: every league match once (two per opponent), the
// moved one on its new date with the planned one as original date
const J cal = session.ui_read(O{{"kind", "calendar"}, {"from", "1900-01-01"}, {"until", "2999-12-31"}}, rev);
const auto* fixtures = at(at(cal, "data"), "fixtures").array();
std::set<std::string> ids, opponents;
std::string own = s(at(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "data"), "team"), "id"));
bool moved_seen = false;
if (fixtures)
for (const auto& f : *fixtures) {
ids.insert(s(at(f, "id")));
const std::string h = s(at(at(f, "home"), "id")), a = s(at(at(f, "away"), "id"));
opponents.insert(h == own ? a : h);
if (s(at(f, "status")) == "rescheduled" && s(at(f, "scheduledDate")) == target && s(at(f, "originalDate")) != target)
moved_seen = true;
}
std::printf("(calendar: %zu days, %zu league matches, %zu opponents)\n",
at(at(cal, "data"), "days").array() ? at(at(cal, "data"), "days").array()->size() : 0, ids.size(), opponents.size());
check(fixtures && ids.size() == fixtures->size() && !opponents.empty() && ids.size() == 2 * opponents.size(),
"calendar: every league match once, two per opponent");
check(moved_seen, "calendar: the moved match on its new date");
const J undone = session.ui_command(cmd("request:f2", "fixture.reschedule", O{{"action", "undo"}, {"date", target}}), rev);
check(s(at(undone, "messageType")) == "command_result", "move taken back");
std::printf("(moved %s to %s and back)\n", match.c_str(), target.c_str());