Modern UI contract: national friendlies
At the national coach's desk the friendly read quotes a match against another nation on a copy of the Watcom generator (price, payer, ratings, free dates); friendly.book draws the same ratings and books it. The opponent bound of the national quote follows the world layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d3d526c2e4
commit
d943494ef4
4 files changed
+107
-7
No files matched your search
@@ -656,10 +656,34 @@ 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
|
||||
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; continue; }
|
||||
if (s(at(done, "messageType")) == "command_result") {
|
||||
++advances;
|
||||
// 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) {
|
||||
const J nf = session.ui_read(O{{"kind", "friendly"}, {"opponentId", "team:384"}}, rev);
|
||||
if (!truth(at(at(nf, "data"), "national"))) continue;
|
||||
const J again = session.ui_read(O{{"kind", "friendly"}, {"opponentId", "team:384"}}, rev);
|
||||
const auto* dates = at(at(nf, "data"), "dates").array();
|
||||
check(cli::dump_json(at(nf, "data")) == cli::dump_json(at(again, "data")) && dates, "national friendly read is pure");
|
||||
std::printf("(national friendly: %s)\n", cli::dump_json(at(nf, "data")).substr(0, 300).c_str());
|
||||
national_friendly = 0;
|
||||
if (dates && !dates->empty()) {
|
||||
const J day = at(dates->back(), "date");
|
||||
const uint64_t was = rev;
|
||||
const J booked = session.ui_command(cmd("request:nf" + std::to_string(k), "friendly.book",
|
||||
O{{"opponentId", "team:384"}, {"date", day}, {"acceptCost", true}}), rev);
|
||||
std::printf("(national friendly booked: %s)\n", cli::dump_json(booked).substr(0, 200).c_str());
|
||||
check(s(at(booked, "messageType")) == "command_result" && rev == was + 1, "national friendly booked");
|
||||
national_friendly = 1;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const std::string code = s(at(done, "code"));
|
||||
const std::string player = s(at(at(at(done, "message"), "args"), "playerId"));
|
||||
check(code == "decision_pending" && !player.empty() && rev == before, "a pending contract names the player, nothing changed");
|
||||
|
||||
Reference in new issue
Block a user