Modern UI contract: stand block expansion

quote.request {kind: block, blockId, places, seats?, roof?} builds the stand
block editor's draft (target places, then seats and roof one at a time) and
stadium.commit confirms it with or without the tip, or cancels it. The
stadium read shows the quote with its breakdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 13:42:26 +01:00
1 parent dc3ecc3a8a
commit abbba65a81
3 files changed
+95 -5

No files matched your search

+23
View File
@@ -334,6 +334,29 @@ int main(int argc, char** argv) {
} else {
std::printf("(facility quote: %s)\n", s(at(q, "code")).c_str());
}
// a stand block: 1000 more places
std::string block;
int64_t places = 0;
if (const auto* blocks = at(at(after, "data"), "blocks").array())
for (const auto& b : *blocks)
if (block.empty() && *at(b, "constructionWeeks").integer() == 0 &&
*at(b, "places").integer() + 1000 <= *at(b, "maxPlaces").integer())
block = s(at(b, "id")), places = *at(b, "places").integer() + 1000;
if (!block.empty()) {
const uint64_t b1 = rev;
const J bq = session.ui_command(cmd("request:eb1", "quote.request", O{{"kind", "block"}, {"blockId", block}, {"places", places}}), rev);
const J quote = quote_of();
if (s(at(bq, "messageType")) != "command_result") std::fprintf(stderr, "block quote: %s\n", cli::dump_json(bq).c_str());
check(s(at(quote, "kind")) == "block" && *at(quote, "places").integer() == places, "block quoted");
const J built = session.ui_command(cmd("request:eb2", "stadium.commit", O{{"quoteId", at(quote, "id")}, {"accept", true}, {"tip", false}}), rev);
if (s(at(built, "messageType")) != "command_result") std::fprintf(stderr, "block build: %s\n", cli::dump_json(built).c_str());
const J st = session.ui_read(O{{"kind", "stadium"}}, rev);
int weeks = -1;
for (const auto& b : *at(at(st, "data"), "blocks").array())
if (s(at(b, "id")) == block) weeks = int(*at(b, "constructionWeeks").integer());
check(s(at(built, "messageType")) == "command_result" && rev == b1 + 2 && weeks > 0, "block expansion under way");
std::printf("(block %s to %lld places: %d weeks)\n", block.c_str(), (long long)places, weeks);
}
const J q2 = session.ui_command(cmd("request:e7", "quote.request", O{{"kind", "facility"}, {"facilityId", "facility:comfort"}, {"increment", 1}}), rev);
if (s(at(q2, "messageType")) == "command_result") {
const J declined = session.ui_command(cmd("request:e8", "stadium.commit", O{{"quoteId", at(quote_of(), "id")}, {"accept", false}}), rev);