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

+18
View File
@@ -14,6 +14,7 @@
#include "modern/content/world_package.hpp"
#include "modern/game/almanac.hpp"
#include "modern/game/desk_actions.hpp"
#include "modern/game/environment.hpp"
namespace bmh::modern {
@@ -368,6 +369,23 @@ 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 == "environment") {
// the club's surroundings (Diamond 3.6): three youth teams, co-trainer, doctor, physio, each
// with a monthly budget level 0-6 and its cost; the youth teams' strength, place and league
static constexpr const char* kItems[6] = {"youth_youngest", "youth_academy", "youth_oldest", "co_trainer", "doctor", "physio"};
if (team_of(g, c.manager) < 0 || team_of(g, c.manager) >= league_clubs())
return failure(request_id, "no_club", "Am Schreibtisch des Bundestrainers gibt es kein Umfeld.", c.state_revision);
const EnvironmentState e = environment_state(g, c.manager);
A items, youth;
for (int i = 0; i < 6; ++i)
items.push_back(O{{"id", std::string("environment:") + kItems[i]}, {"level", e.level[size_t(i)]}, {"maxLevel", 6},
{"monthly", ui_money(e.monthly[size_t(i)])}, {"stepCost", ui_money(kEnvironmentStep[size_t(i)])}});
for (size_t t = 0; t < 3; ++t)
youth.push_back(O{{"id", std::string("youth:") + kItems[t]}, {"strength", int(e.youth_strength[t])},
{"place", int(e.youth_position[t])}, {"league", int(e.youth_league[t])}});
return snapshot(request_id, std::move(m), O{{"kind", "environment"}, {"items", std::move(items)}, {"youth", std::move(youth)},
{"academyActive", environment_academy_active(g, c.manager)}});
}
if (kind == "toto" || kind == "sponsor") {
// the existing projections (ui-abfragen.md), amounts as Money
J p = query_projection(g, c.manager, O{{"kind", kind}});