Modern UI contract: running-out contracts during session.advance
The original asks for a running-out contract in the middle of the calendar. session.advance takes the answers in contractExpiry (renew with years and salary, or release); a contract without an answer rolls the run back and decision_pending names the player, the interface asks and sends the advance again. The test plays two seasons of kickoffs answering every request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ca6b21a94
commit
f71f072774
3 files changed
+74
-1
No files matched your search
@@ -273,6 +273,27 @@ 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 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)
|
||||
{
|
||||
O expiry;
|
||||
int decisions = 0, advances = 0;
|
||||
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; }
|
||||
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");
|
||||
if (code != "decision_pending" || player.empty() || expiry.count(player)) break;
|
||||
expiry[player] = O{{"action", "release"}};
|
||||
++decisions;
|
||||
}
|
||||
check(advances == 120, "two seasons of kickoffs with answered contract decisions");
|
||||
check(decisions > 0, "running-out contracts were asked for");
|
||||
std::printf("(date now %s)\n", s(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "meta"), "date")).c_str());
|
||||
std::printf("(%d contract decisions answered)\n", decisions);
|
||||
}
|
||||
// almanac view after the kickoffs: index, calendar, day, match
|
||||
{
|
||||
const J index = session.read_almanac(O{{"kind", "index"}});
|
||||
|
||||
Reference in new issue
Block a user