Modern UI contract: indoor surface and substitution pairs in the line-up read
The lineup read now passes on the prepared match context: surface (indoor during the indoor tournament, rebuilt from the cup groups when a save is loaded), durationMinutes and starterCount (always eleven). The first eleven's pairs come from the board's partner byte (+0x3f) as stored: pairs lists rows that name each other, every position carries its partnerId. Nothing is cut or relabelled; lineup.commit keeps owner, order and pairs (checked at the winter indoor tournament). Refs #27. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
50541207eb
commit
179843700a
5 files changed
+64
-7
No files matched your search
@@ -673,11 +673,42 @@ int main(int argc, char** argv) {
|
||||
O expiry;
|
||||
int decisions = 0, advances = 0;
|
||||
int national_friendly = -1; // -1 no national desk yet, 0 read, 1 booked
|
||||
bool indoor_seen = false;
|
||||
for (int k = 0; k < 200 && advances < 120; ++k) {
|
||||
const uint64_t before = rev;
|
||||
const J done = session.ui_command(cmd("request:s" + std::to_string(k), "session.advance", O{{"contractExpiry", expiry}}), rev);
|
||||
if (s(at(done, "messageType")) == "command_result") {
|
||||
++advances;
|
||||
// the winter indoor tournament (#27): the line-up read says so and gives the
|
||||
// first eleven's pairs; committing the same order keeps owner, order and pairs
|
||||
if (!indoor_seen) {
|
||||
const J lineup = session.ui_read(O{{"kind", "lineup"}}, rev);
|
||||
const J& data = at(lineup, "data");
|
||||
if (s(at(data, "surface")) == "indoor") {
|
||||
indoor_seen = true;
|
||||
const auto* order = at(data, "order").array();
|
||||
const auto* pairs = at(data, "pairs").array();
|
||||
const auto* positions = at(data, "positions").array();
|
||||
std::printf("(indoor line-up: %s)\n", cli::dump_json(at(data, "pairs")).substr(0, 300).c_str());
|
||||
bool linked = pairs && positions && positions->size() == 11 && order && order->size() >= 11;
|
||||
for (size_t i = 0; linked && i < pairs->size(); ++i) {
|
||||
const auto* ids = at((*pairs)[i], "playerIds").array();
|
||||
linked = ids && ids->size() == 2;
|
||||
for (const auto& p : *positions)
|
||||
if (linked && s(at(p, "playerId")) == s((*ids)[0])) linked = s(at(p, "partnerId")) == s((*ids)[1]);
|
||||
}
|
||||
check(linked && *at(data, "durationMinutes").integer() == 40 && *at(data, "starterCount").integer() == 11,
|
||||
"indoor line-up read: eleven starters with their pairs");
|
||||
const uint64_t was = rev;
|
||||
const J kept = session.ui_command(cmd("request:il" + std::to_string(k), "lineup.commit", O{{"order", J(*order)}}), rev);
|
||||
const J again = at(session.ui_read(O{{"kind", "lineup"}}, rev), "data");
|
||||
check(s(at(kept, "messageType")) == "command_result" && rev == was + 1 &&
|
||||
cli::dump_json(at(again, "order")) == cli::dump_json(at(data, "order")) &&
|
||||
cli::dump_json(at(again, "pairs")) == cli::dump_json(at(data, "pairs")) &&
|
||||
s(at(again, "surface")) == "indoor",
|
||||
"indoor line-up commit keeps order and pairs");
|
||||
}
|
||||
}
|
||||
// at the national coach's desk: a friendly against another nation (the quote
|
||||
// draws ratings; the read previews them without moving the generator)
|
||||
if (national_friendly < 0) {
|
||||
|
||||
Reference in new issue
Block a user