Show the season opening when a running Modern career reaches a new season

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 08:39:51 +01:00
1 parent fee03624be
commit 749c5ec512
2 files changed
+30 -3

No files matched your search

+13 -1
View File
@@ -48,7 +48,9 @@ void App::engine_kickoff() {
return EngineReply{link, desk, response, nullptr};
}
response["liveRecording"] = state;
return EngineReply{link, link->snapshot(), response, nullptr};
auto after = link->snapshot();
engine_attach_opening(*link, engine_season_id(desk), after, response);
return EngineReply{link, std::move(after), response, nullptr};
}, true);
}
// A contract runs out on the way to the next desk: the manager extends at the player's
@@ -129,6 +131,16 @@ void App::engine_accept(EngineReply result) {
if (engine_response_.value("code", "") == "decision_pending" && args.is_object() && args.value("decision", "") == "contract_expiry")
engine_expiry_ask(args);
}
if (engine_response_.contains("seasonOpening")) {
// a new season began: its draw is shown once the ticker is closed
const Json opening = engine_response_.at("seasonOpening");
engine_response_.erase("seasonOpening");
try {
auto state = engine_opening_projection(engine_data_, opening);
engine_opening_read_ = opening; engine_opening_state_ = std::move(state);
opening_due_ = 0; opening_io_blocked_ = false;
} catch (const std::exception &) {} // without a showable draw the desk simply continues
}
if (engine_response_.contains("liveState")) {
const Json state = engine_response_.at("liveState");
engine_response_.erase("liveState");
+17 -2
View File
@@ -1,4 +1,16 @@
// SPDX-License-Identifier: GPL-3.0-only
namespace {
// A kickoff that reached a new season carries that season's draw for the opening view.
void engine_attach_opening(EngineBridge &link, const std::string &season_before, const Json &after, Json &response) {
try {
const std::string season_after = after.at("desktop").at("meta").at("season").at("id");
if (!season_before.empty() && season_after != season_before) response["seasonOpening"] = link.read({{"kind", "opening"}});
} catch (const std::exception &) {}
}
std::string engine_season_id(const Json &bundle) {
try { return bundle.at("desktop").at("meta").at("season").at("id"); } catch (const std::exception &) { return {}; }
}
} // namespace
bool App::live_open() {
if (!source_) { message("Für diese Ansicht steht keine Live-Datenquelle bereit."); return false; }
const auto snapshot = snap();
@@ -153,9 +165,12 @@ void App::engine_live_poll() {
auto link = engine_link_;
if (accepted) {
engine_live_at_end_ = true;
engine_start("Abpfiff …", [link, state] {
const std::string season = engine_season_id(engine_data_);
engine_start("Abpfiff …", [link, state, season] {
Json finished = {{"messageType", "live_finished"}, {"liveRecording", state}};
return EngineReply{link, link->snapshot(), finished, nullptr};
auto after = link->snapshot();
engine_attach_opening(*link, season, after, finished);
return EngineReply{link, std::move(after), finished, nullptr};
}, true);
} else {
// the engine took the kickoff back (a question it could not ask in time): back to the desk