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:
1 parent
abbba65a81
commit
f2c895ffb0
4 files changed
+55
No files matched your search
@@ -10094,6 +10094,24 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"transfer", "squad", "desktop"}, feedback);
|
||||
if (bid_pending) std::get<cli::Json::Object>(answer.value)["outcome"] = "offer_pending";
|
||||
}
|
||||
} else if (kind == "environment.commit") {
|
||||
// payload {itemId: "environment:<item>", level 0-6}: a monthly budget of the surroundings
|
||||
// (no immediate booking, no random draw); the original's notice comes back as feedback
|
||||
static constexpr const char* kItems[6] = {"youth_youngest", "youth_academy", "youth_oldest", "co_trainer", "doctor", "physio"};
|
||||
const std::string id = ui_text(*payload, "itemId");
|
||||
int item = -1;
|
||||
for (int i = 0; i < 6; ++i) if (id == std::string("environment:") + kItems[i]) item = i;
|
||||
const cli::Json* level = ui_field(*payload, "level");
|
||||
if (item < 0 || !level || !level->integer() || *level->integer() < 0 || *level->integer() > 6)
|
||||
return refuse("invalid_payload", "itemId und level (0 bis 6) nötig.");
|
||||
const int team = g_.manager_teams[size_t(manager)];
|
||||
if (team < 0 || team >= league_clubs()) return refuse("no_club", "Am Schreibtisch des Bundestrainers gibt es kein Umfeld.");
|
||||
std::string message;
|
||||
const EnvironmentResult result = modern::set_environment(g_, manager, item, int(*level->integer()), &message);
|
||||
if (result == EnvironmentResult::invalid) { restore(); return refuse("environment_refused", message.empty() ? "Nicht möglich." : ui::original_to_utf8(message)); }
|
||||
if (result == EnvironmentResult::changed) revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"environment", "desktop"},
|
||||
message.empty() ? "Umfeld geändert." : ui::original_to_utf8(message));
|
||||
} else if (kind == "manager.resign.commit") {
|
||||
// payload {confirmed: true}. A Modern feature (the original has no resigning): when the last
|
||||
// human manager resigns the career ends (outcome career_ended, sessionState "ended"). With
|
||||
|
||||
Reference in new issue
Block a user