Modern UI contract: toto and exclusive sponsor reads and commands

toto and sponsor reads in the envelope (amounts as Money), toto.submit with
up to six columns and sponsor.answer for a camp's exclusive sponsor offer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 09:29:25 +01:00
1 parent e6bc72d3a0
commit 43317985e4
4 files changed
+73

No files matched your search

+20
View File
@@ -10,6 +10,7 @@
#include "formats/executable_layout.hpp"
#include "game/state.hpp"
#include "game/table.hpp"
#include "modern/content/projections.hpp"
#include "modern/content/world_package.hpp"
#include "modern/game/almanac.hpp"
#include "modern/game/desk_actions.hpp"
@@ -367,6 +368,25 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
if (kind == "session") return snapshot(request_id, std::move(m), session_data(g, c));
if (kind == "desktop") return snapshot(request_id, std::move(m), desktop_data(g, c, today));
if (kind == "camps") return snapshot(request_id, std::move(m), camps_data(g, c, std::to_string(c.state_revision)));
if (kind == "toto" || kind == "sponsor") {
// the existing projections (ui-abfragen.md), amounts as Money
J p = query_projection(g, c.manager, O{{"kind", kind}});
auto* o = std::get_if<O>(&p.value);
if (!o || !(*o)["ok"].value.index() || !std::get<bool>((*o)["ok"].value))
return failure(request_id, "unavailable", "Nicht verfügbar.", c.state_revision);
o->erase("ok");
const auto money = [](J& v) { if (v.integer()) v = ui_money(*v.integer()); };
if (kind == "toto") {
money((*o)["stake"]), money((*o)["cost"]);
auto& last = std::get<O>((*o)["last"].value);
money(last["paid"]), money(last["won"]);
} else {
for (const char* key : {"offer", "queued"})
if (auto* row = std::get_if<O>(&(*o)[key].value)) money((*row)["monthly"]);
}
(*o)["kind"] = kind;
return snapshot(request_id, std::move(m), std::move(p));
}
if (kind == "squad") {
const int team = requested_team(g, c, request);
if (team < 0 || !fields_players(g, team))