Modern UI contract: the end of the game

Resigning as the only or last human ends the game as the end of the set
duration does: the highscore hook updates and shows the table. The end's
reason and date are saved; the session read follows the contract's
Session schema (archived managers, termination reason, ownership, mode),
managers become archived (resigned or retired) and their employments end
with the career. The resign answer carries the ownership change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 18:39:32 +01:00
1 parent 6570384642
commit d6d31f939d
10 files changed
+99 -20

No files matched your search

+14 -1
View File
@@ -827,7 +827,20 @@ int main(int argc, char** argv) {
check(s(at(resign("request:r1", O{}), "code")) == "confirmation_required", "resigning needs the confirmation");
const J done = resign("request:r2", O{{"confirmed", true}});
check(s(at(done, "outcome")) == "career_ended", "the last human manager ends the career");
check(s(at(at(session.ui_read(O{{"kind", "session"}}, rev), "data"), "sessionState")) == "ended", "session ended");
const J ended = at(session.ui_read(O{{"kind", "session"}}, rev), "data");
check(s(at(ended, "sessionState")) == "ended", "session ended");
check(s(at(ended, "terminationReason")) == "last_human_resigned" && !truth(at(ended, "canAdvance")) &&
std::holds_alternative<std::nullptr_t>(at(ended, "activeManagerId").value) &&
at(ended, "archivedManagerIds").array() && at(ended, "archivedManagerIds").array()->size() == 1,
"the ended session: reason, archived manager, no advance");
const J& identity = at(at(done, "ownershipChange"), "archivedIdentity");
const auto* jobs = at(identity, "employments").array();
std::printf("(archived: %s)\n", cli::dump_json(identity).substr(0, 400).c_str());
check(s(at(identity, "control")) == "archived" && s(at(identity, "status")) == "resigned", "the archived identity");
bool resigned_job = false;
if (jobs) for (const auto& j : *jobs) resigned_job |= s(at(j, "endReason")) == "resigned" && at(j, "until").string();
check(resigned_job, "the employment ends with the resignation");
check(!std::as_const(session).state().career_end_reason.empty(), "the end is kept in the state (saved)");
check(s(at(resign("request:r3", O{{"confirmed", true}}), "code")) == "career_ended", "no command after the end");
}
} catch (const std::exception& ex) {