Modern UI contract: camps read and the first command, camp.book

ModernSession::ui_command checks careerId, expectedRevision and owner, runs
the engine action and answers command_result or error. A refused command
restores the state and both generators; a repeated requestId gets the stored
answer, a different command under the same id duplicate_request. The camps
read lists maps and camps with a binding, draw-free quote per camp, focus and
the season's stays. Tests cover stale revision, foreign owner, unknown camp,
booking, repeat, conflict and a refused second booking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 08:25:54 +01:00
1 parent fec4c6c7e7
commit 99a48a463d
7 files changed
+252 -2

No files matched your search

+9
View File
@@ -848,6 +848,11 @@ public:
context.next_away = desk.next_match_away;
return modern::ui_read(g_, context, request);
}
// A command of the interface contract: checks career, expectedRevision and owner, runs the
// engine action and answers command_result or error. A refused command leaves the state and
// both generators untouched; a repeated requestId with the same command gets the stored
// answer, with another command duplicate_request. Kinds so far: camp.book.
cli::Json ui_command(const cli::Json& request, uint64_t& revision);
ModernState& state() { return g_; }
const TurnResultSnapshot& last_turn_results() const { return turn_driver_.last_results; }
// Owned presentation for the event completed by the last accepted kickoff.
@@ -996,6 +1001,10 @@ private:
uint64_t original_rand_calls = 0, original_game_calls = 0, context_revision = 0;
};
std::optional<ManagerJoinDraft> manager_join_;
// ui_command: answers by requestId (the command as JSON, the answer) for repeated commands,
// the last 64 in this process; after a restart expectedRevision prevents a second booking.
std::map<std::string, std::pair<std::string, cli::Json>> ui_answers_;
std::vector<std::string> ui_answer_order_;
std::filesystem::path data_directory_;
LeImage exe_;