Modern UI contract: live matchdays with interventions

session.advance {live: true} runs the kickoff on its own thread and stops at
the minutes of a live match of a human manager (not at a voided one).
live.step plays on, live.substitute and live.tactics act as the original's
pitch and tactics screens during a match (open, change, close) on the
kickoff thread, live.finish plays the day to its end. Other commands answer
live_running meanwhile, read_live reports the minute and the live scores.
A missing contract decision rolls the whole live day back. Also: the
recording takes matches up to the day the kickoff ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 13:21:43 +01:00
1 parent 10a8f0b881
commit 822331f045
6 files changed
+386 -4

No files matched your search

+47
View File
@@ -403,6 +403,53 @@ 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");
}
// a live kickoff: stops in a match of the human manager, steps, intervenes, finishes
{
bool stopped = false;
for (int k = 0; k < 12 && !stopped; ++k) {
const J started = session.ui_command(cmd("request:lr" + std::to_string(k), "session.advance", O{{"live", true}}), rev);
const J state = session.read_live(O{{"kind", "fixture"}});
stopped = truth(at(state, "live"));
if (!stopped)
check(s(at(started, "messageType")) == "command_result", "a live kickoff without a human match runs through");
}
check(stopped, "a live kickoff stood still in a match");
if (stopped) {
check(s(at(session.ui_command(cmd("request:lx", "bank.commit", O{{"action", "deposit"}}), rev), "code")) == "live_running",
"other commands wait for the live kickoff");
const J stepped = session.ui_command(cmd("request:ls", "live.step", O{{"minutes", 30}}), rev);
const J state = session.read_live(O{{"kind", "fixture"}});
check(s(at(stepped, "messageType")) == "command_result" && at(state, "minute").integer() &&
*at(state, "minute").integer() >= 30, "thirty minutes on");
std::printf("(live state: %s)\n", cli::dump_json(state).substr(0, 400).c_str());
// a substitution: the last field row for the first bench row
const J lineup = session.ui_read(O{{"kind", "lineup"}}, rev);
const auto* order = at(at(lineup, "data"), "order").array();
if (order && order->size() > 11) {
const J sub = session.ui_command(cmd("request:lsub", "live.substitute",
O{{"outPlayerId", (*order)[10]}, {"inPlayerId", (*order)[11]}}), rev);
std::printf("(live substitution: %s)\n", cli::dump_json(sub).substr(0, 200).c_str());
check(s(at(sub, "messageType")) == "command_result" || s(at(sub, "code")) == "substitution_refused",
"live substitution answered");
}
const J tactics = session.ui_read(O{{"kind", "tactics"}}, rev);
if (const auto* controls = at(at(tactics, "data"), "controls").array(); controls && controls->size() == 8) {
J::Array values;
for (const auto& c : *controls) values.push_back(at(c, "value"));
values[7] = J(*values[7].integer() == 0 ? 1 : 0);
const J changed = session.ui_command(cmd("request:ltac", "live.tactics", O{{"values", values}}), rev);
std::printf("(live tactics: %s)\n", cli::dump_json(changed).substr(0, 800).c_str());
check(s(at(changed, "messageType")) == "command_result", "live tactics changed");
}
const J done = session.ui_command(cmd("request:lf", "live.finish", O{}), rev);
check(s(at(done, "messageType")) == "command_result", "live kickoff finished");
const J fixture = session.read_live(O{{"kind", "fixture"}});
if (!truth(at(fixture, "ok"))) std::printf("(fixture: %s)\n", cli::dump_json(fixture).substr(0, 200).c_str());
check(truth(at(fixture, "ok")) && at(fixture, "frames").array() && at(fixture, "frames").array()->size() >= 4,
"the live kickoff's recording");
}
check(s(at(session.ui_command(cmd("request:lz", "live.step", O{}), rev), "code")) == "live_not_running", "no live kickoff");
}
// a season of kickoffs: running-out contracts stop the run with decision_pending and the
// player; the advance is sent again with the answer (here: release)
{