Modern UI contract: environment read and environment.commit

The surroundings of Diamond 3.6: three youth teams, co-trainer, doctor and
physio with their monthly budget level and cost, the youth teams' strength,
place and league. environment.commit sets a level 0-6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 13:44:25 +01:00
1 parent abbba65a81
commit f2c895ffb0
4 files changed
+55

No files matched your search

+17
View File
@@ -398,6 +398,23 @@ int main(int argc, char** argv) {
check(s(at(session.ui_command(cmd("request:t11", "transfer.submit", O{{"action", "bid"}, {"listingId", "listing:999"}}), rev), "code")) ==
"unknown_listing", "unknown listing refused");
}
// the surroundings: six budgets 0-6
{
const J env = session.ui_read(O{{"kind", "environment"}}, rev);
const auto* items = at(at(env, "data"), "items").array();
check(items && items->size() == 6 && at(at(env, "data"), "youth").array(), "environment read");
if (items && items->size() == 6) {
const int64_t level = *at((*items)[4], "level").integer();
const int64_t wanted = level < 6 ? level + 1 : level - 1;
const uint64_t before = rev;
const J done = session.ui_command(cmd("request:u1", "environment.commit", O{{"itemId", "environment:doctor"}, {"level", wanted}}), rev);
const J after_env = session.ui_read(O{{"kind", "environment"}}, rev);
check(s(at(done, "messageType")) == "command_result" && rev == before + 1 &&
*at((*at(at(after_env, "data"), "items").array())[4], "level").integer() == wanted, "doctor budget changed");
check(s(at(session.ui_command(cmd("request:u2", "environment.commit", O{{"itemId", "environment:doctor"}, {"level", 9}}), rev), "code")) ==
"invalid_payload", "level above 6 refused");
}
}
// toto and the exclusive sponsor
{
const J toto = session.ui_read(O{{"kind", "toto"}}, rev);