From 749c5ec512428f29f8bdbd6aae4dca922c9bf2f5 Mon Sep 17 00:00:00 2001 From: Weyoune Date: Sat, 14 Nov 2026 08:39:51 +0100 Subject: [PATCH] Show the season opening when a running Modern career reaches a new season Co-Authored-By: Claude Fable 5.2 --- src/modern/ui/engine_controls.inc | 14 +++++++++++++- src/modern/ui/live_controls.inc | 19 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/modern/ui/engine_controls.inc b/src/modern/ui/engine_controls.inc index 3e8626a..583a624 100644 --- a/src/modern/ui/engine_controls.inc +++ b/src/modern/ui/engine_controls.inc @@ -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"); diff --git a/src/modern/ui/live_controls.inc b/src/modern/ui/live_controls.inc index a04fc88..f0e1870 100644 --- a/src/modern/ui/live_controls.inc +++ b/src/modern/ui/live_controls.inc @@ -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