Bind the kickoff of the Modern desk to the engine and show its recording in the ticker
The kickoff button sends session.advance; the engine's recording of the played matchday is shaped for the live ticker (phases, per-match tables, the desk manager's squad). A contract running out on the way asks the manager to extend at the player's demand or to release him. The UI script driver accepts optional clicks, and modern_live_dump writes the engine's recording for inspection. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e92d07b03
commit
7c0e66affe
15 files changed
+447
-30
No files matched your search
@@ -9923,6 +9923,7 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
answers[id] = x;
|
||||
}
|
||||
std::string pending_player;
|
||||
std::array<uint32_t, 4> pending_demands{};
|
||||
auto previous_hook = g_.contract_screen;
|
||||
const bool previous_installed = contract_expiry_presenter_installed_;
|
||||
set_contract_expiry_presenter([&](modern::ModernState& state, WatcomRandom& random, int m, int row) -> int {
|
||||
@@ -9931,7 +9932,11 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
const int p = size_t(row) < range.count ? state.squad_slots[range.first + size_t(row)] & 0x0fff : 0x0fff;
|
||||
const std::string id = p == 0x0fff ? std::string{} : modern::ui_player_id(state, p);
|
||||
const auto it = answers.find(id);
|
||||
if (it == answers.end()) { pending_player = id; return -2; } // ask the interface
|
||||
if (it == answers.end()) { // ask the interface; the run is rolled back, so this draw is repeated later
|
||||
pending_player = id;
|
||||
try { pending_demands = modern::contract_demands(state, m, row, false, random); } catch (const std::exception&) { pending_demands = {}; }
|
||||
return -2;
|
||||
}
|
||||
if (!it->second.renew) return 0; // released
|
||||
try {
|
||||
const auto demands = modern::contract_demands(state, m, row, false, random);
|
||||
@@ -9973,7 +9978,9 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
if (!pending_player.empty()) {
|
||||
cli::Json pending = refuse("decision_pending", "Ein Vertrag läuft aus: Verlängern oder freigeben?");
|
||||
auto& message = std::get<cli::Json::Object>(std::get<cli::Json::Object>(pending.value)["message"].value);
|
||||
message["args"] = cli::Json::Object{{"decision", "contract_expiry"}, {"playerId", pending_player}};
|
||||
cli::Json::Array demands;
|
||||
for (const uint32_t d : pending_demands) demands.push_back(d == 0 || d == UINT32_MAX ? cli::Json(nullptr) : modern::ui_money(int64_t(d)));
|
||||
message["args"] = cli::Json::Object{{"decision", "contract_expiry"}, {"playerId", pending_player}, {"demands", std::move(demands)}};
|
||||
return pending;
|
||||
}
|
||||
const std::string reason = r.reason.empty() ? error : r.reason;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp crest_contrast.cpp engine_dto.cpp engine_statistics.cpp engine_toto.cpp engine_stadium.cpp engine_transfer.cpp engine_achievements.cpp engine_news.cpp engine_balance.cpp engine_widgets.cpp engine_indoor.cpp engine_settings.cpp engine_managers.cpp model.cpp demo_career.cpp demo_national_ui.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_live.cpp demo_post_match.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp news_catalog.cpp news_journal.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp career_files.cpp demo_opening.cpp)
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp crest_contrast.cpp engine_dto.cpp engine_live.cpp engine_statistics.cpp engine_toto.cpp engine_stadium.cpp engine_transfer.cpp engine_achievements.cpp engine_news.cpp engine_balance.cpp engine_widgets.cpp engine_indoor.cpp engine_settings.cpp engine_managers.cpp model.cpp demo_career.cpp demo_national_ui.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_live.cpp demo_post_match.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp news_catalog.cpp news_journal.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp career_files.cpp demo_opening.cpp)
|
||||
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
|
||||
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
|
||||
add_library(bmh_modern_ui_mods STATIC mod_library.cpp)
|
||||
@@ -161,9 +161,12 @@ target_link_libraries(modern_engine_dto_tests PRIVATE bmh_modern_ui_core)
|
||||
add_test(NAME modern_engine_dto_tests COMMAND modern_engine_dto_tests)
|
||||
add_executable(modern_engine_bridge_probe ../../../tests/modern_engine_bridge_probe.cpp)
|
||||
target_link_libraries(modern_engine_bridge_probe PRIVATE bmh_modern_ui_engine bmh_modern_session)
|
||||
add_executable(modern_live_dump ../../../tests/modern_live_dump.cpp)
|
||||
target_link_libraries(modern_live_dump PRIVATE bmh_modern_ui_engine bmh_modern_session)
|
||||
if(MSVC)
|
||||
target_compile_options(modern_engine_dto_tests PRIVATE /utf-8)
|
||||
target_compile_options(modern_engine_bridge_probe PRIVATE /utf-8 /bigobj)
|
||||
target_compile_options(modern_live_dump PRIVATE /utf-8 /bigobj)
|
||||
endif()
|
||||
|
||||
add_executable(modern_managers_projection_tests "${CMAKE_SOURCE_DIR}/tests/modern_managers_projection_tests.cpp")
|
||||
|
||||
@@ -914,6 +914,12 @@ void App::script() {
|
||||
const auto end=SDL_GetTicks64()+command.value("timeout_ms",uint64_t(300000));
|
||||
while(front_busy_&&SDL_GetTicks64()<end){front_poll();if(needs_render_||dirty_)frame();SDL_Delay(10);}
|
||||
if(front_busy_)throw editor::Error("Modvorgang hat das QA-Zeitlimit überschritten.");
|
||||
} else if (type == "click" && command.value("optional", false) && command.contains("selector") && [&] {
|
||||
context_->Update();
|
||||
auto *node = doc_->QuerySelector(command.at("selector").get<std::string>());
|
||||
return !node || !node->IsVisible(true) || node->HasAttribute("disabled");
|
||||
}()) {
|
||||
// An optional step whose element is absent, hidden or disabled is skipped.
|
||||
} else if (type == "click" || type == "right") {
|
||||
const auto point = locate(command);
|
||||
const int button = type == "right" ? 1 : 0;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_sports.hpp"
|
||||
#include "modern/ui/engine_live.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <map>
|
||||
@@ -215,6 +216,8 @@ Json make_demo_live(const Catalog &world, const Json &state, uint64_t revision)
|
||||
|
||||
bool valid_live_fixture(const Json &v) {
|
||||
try {
|
||||
// A recording of the engine has its own, engine-shaped rules.
|
||||
if (v.is_object() && v.value("source", "") == "engine-recording") return valid_engine_live_fixture(v);
|
||||
if (!v.is_object() || !v.value("ok", false) || v.at("schema") != "openbmh-live-fixture@1" ||
|
||||
v.at("source") != "ui-demo-fixture" || !v.at("fixture_id").is_string() ||
|
||||
!uint_value(v.at("source_revision"), UINT64_MAX) || !v.at("owners").is_array() ||
|
||||
@@ -383,7 +386,7 @@ bool LivePlayback::cycle_owner(int direction) {
|
||||
}
|
||||
Json LivePlayback::frame() const { return available() ? live_fixture_frame(fixture_, sequence_) : failure("live_unavailable"); }
|
||||
Json LivePlayback::status() const {
|
||||
return {{"source", available() ? Json("ui-demo-fixture") : Json()}, {"available", available()},
|
||||
return {{"source", available() ? fixture_.at("source") : Json()}, {"available", available()},
|
||||
{"fixture_id", available() ? fixture_.at("fixture_id") : Json()},
|
||||
{"source_revision", available() ? fixture_.at("source_revision") : Json()},
|
||||
{"sequence", sequence_}, {"speed", speed_}, {"owner", owner_}, {"finished", finished()}};
|
||||
|
||||
@@ -83,6 +83,9 @@ Json EngineBridge::command(const Json &request) {
|
||||
Json EngineBridge::read(const Json &request) const {
|
||||
return from_engine(impl_->session->ui_read(cli::parse_json(request.dump()), impl_->revision));
|
||||
}
|
||||
Json EngineBridge::read_live(const Json &request) const {
|
||||
return from_engine(impl_->session->read_live(cli::parse_json(request.dump())));
|
||||
}
|
||||
CareerFiles make_career_files(const fs::path &directory,const fs::path &world) {
|
||||
const auto model=modern::open_world_package(world).world;
|
||||
return CareerFiles(directory,[model](const fs::path &file){
|
||||
|
||||
@@ -104,6 +104,8 @@ public:
|
||||
~EngineBridge();
|
||||
Json snapshot() const;
|
||||
Json read(const Json &request) const;
|
||||
// The recording of the last kickoff (or the paused live state); never starts a match.
|
||||
Json read_live(const Json &request) const;
|
||||
Json command(const Json &request);
|
||||
Json save_copy(const fs::path &path);
|
||||
Json file_metadata() const;
|
||||
|
||||
@@ -6,6 +6,50 @@ void App::engine_start(std::string label, std::function<EngineReply()> job, bool
|
||||
engine_operation_ = std::move(label); engine_busy_ = true;
|
||||
engine_job_ = std::async(std::launch::async, std::move(job)); refresh();
|
||||
}
|
||||
// Plays the next kickoff with the line-up and tactics of the desk; the ticker then shows
|
||||
// the engine's recording of it. Answers to questions of the run travel in the payload.
|
||||
void App::engine_kickoff() {
|
||||
if (engine_busy_ || !engine_link_) return;
|
||||
const auto command = engine_advance_command(engine_data_, editor::new_id("request:ui-"), engine_advance_payload_);
|
||||
auto link = engine_link_;
|
||||
engine_start("Der Spieltag läuft …", [link, command] {
|
||||
auto response = link->command(command);
|
||||
if (response.value("messageType", "") == "command_result") response["liveRecording"] = link->read_live({{"kind", "fixture"}});
|
||||
else response["advanceRefused"] = true;
|
||||
return EngineReply{link, link->snapshot(), response, nullptr};
|
||||
}, true);
|
||||
}
|
||||
// A contract runs out on the way to the next desk: the manager extends at the player's
|
||||
// demand, lets him go, or returns to the desk to deal with it there.
|
||||
void App::engine_expiry_ask(const Json &args) {
|
||||
const std::string id = args.value("playerId", std::string());
|
||||
if (id.empty()) return;
|
||||
std::string name = id;
|
||||
try {
|
||||
for (const auto &p : engine_data_.at("squad").at("data").at("players"))
|
||||
if (p.at("player").at("id") == id) name = p.at("player").at("name").get<std::string>();
|
||||
} catch (const std::exception &) {}
|
||||
int years = 0; Json salary;
|
||||
const auto demands = args.value("demands", Json::array());
|
||||
for (int option : {1, 0, 2, 3})
|
||||
if (!years && demands.is_array() && size_t(option) < demands.size() && demands[size_t(option)].is_object()) { years = option + 1; salary = demands[size_t(option)]; }
|
||||
engine_expiry_player_ = id;
|
||||
if (years) {
|
||||
confirmation("Der Vertrag von " + name + " läuft aus. Er fordert " + engine_price(salary) + " monatlich für " +
|
||||
std::to_string(years) + (years == 1 ? " Jahr." : " Jahre.") + " Verlängern oder freigeben?",
|
||||
[this, id, years, salary] {
|
||||
engine_advance_payload_["contractExpiry"][id] = {{"action", "renew"}, {"years", years}, {"monthlySalary", salary}};
|
||||
engine_kickoff();
|
||||
});
|
||||
popup_accept_ = "Verlängern";
|
||||
} else {
|
||||
confirmation("Der Vertrag von " + name + " läuft aus und der Spieler verlängert nicht. Freigeben und weiter?",
|
||||
[this, id] { engine_advance_payload_["contractExpiry"][id] = {{"action", "release"}}; engine_kickoff(); });
|
||||
popup_accept_ = "Freigeben";
|
||||
return;
|
||||
}
|
||||
popup_extra_ = btn("engine-expiry-release", "Freigeben");
|
||||
}
|
||||
void App::engine_accept(EngineReply result) {
|
||||
engine_fresh_ = true;
|
||||
if (result.catalog) { world_ = std::move(result.catalog); bind_world(world_); }
|
||||
@@ -45,6 +89,20 @@ void App::engine_accept(EngineReply result) {
|
||||
engine_focus_ = {{"condition", f.at("condition")}, {"technique", f.at("technique")}, {"play", f.at("play")}};
|
||||
if (engine_camp_.empty() && !engine_data_.at("camps").at("data").at("camps").empty())
|
||||
engine_camp_ = engine_data_.at("camps").at("data").at("camps").front().at("id");
|
||||
if (engine_response_.value("advanceRefused", false)) {
|
||||
engine_response_.erase("advanceRefused");
|
||||
Json args;
|
||||
try { args = engine_response_.at("message").at("args"); } catch (const std::exception &) {}
|
||||
if (engine_response_.value("code", "") == "decision_pending" && args.is_object() && args.value("decision", "") == "contract_expiry")
|
||||
engine_expiry_ask(args);
|
||||
}
|
||||
if (engine_response_.contains("liveRecording")) {
|
||||
const Json recording = engine_response_.at("liveRecording");
|
||||
engine_response_.erase("liveRecording");
|
||||
engine_advance_payload_ = Json::object();
|
||||
if (recording.value("ok", false)) engine_live_open(recording);
|
||||
else engine_notice_ = "Weiter zum nächsten Termin · an diesem Tag gab es kein eigenes Spiel.";
|
||||
}
|
||||
}
|
||||
void App::engine_poll() {
|
||||
if (!engine_busy_ || engine_job_.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready) return;
|
||||
@@ -91,6 +149,10 @@ void App::engine_frame() {
|
||||
engine_sports_update();
|
||||
if (ticket_) ticket_->update();
|
||||
render_popup(); context_->Update();
|
||||
if (scene_ == "live" && live_.available()) {
|
||||
if (rendered) { live_after_render(); context_->Update(); }
|
||||
live_update_parts();
|
||||
}
|
||||
if(center_fixture_columns())context_->Update();
|
||||
if (menu_ == "settings") { settings_after_render(); context_->Update(); }
|
||||
if (rendered && menu_ == "friendlies") if (auto *list = element("friendly-opponents")) list->SetScrollTop(engine_friendly_scroll_);
|
||||
@@ -160,6 +222,16 @@ void App::engine_event(Rml::Event &event) {
|
||||
const auto type = event.GetType(); auto *target = event.GetTargetElement();
|
||||
if (type == "keydown") keyboard_navigation_ = true;
|
||||
if (type == "mousedown") keyboard_navigation_ = false;
|
||||
if (scene_ == "live" && live_.available()) {
|
||||
// The ticker of a played kickoff: only its own controls, nothing of the desk beneath.
|
||||
if (live_event(event)) return;
|
||||
if (type == "click")
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (n->HasAttribute("data-action") && !n->HasAttribute("disabled")) {
|
||||
live_action(n->GetAttribute<Rml::String>("data-action", ""), n); break;
|
||||
}
|
||||
event.StopImmediatePropagation(); return;
|
||||
}
|
||||
for (auto *node = target; node && node != doc_; node = node->GetParentNode())
|
||||
if (node->GetId() == "native-ticket-layer") return; // owned by the compact control
|
||||
if (ticket_ && ticket_->is_open()) return;
|
||||
@@ -285,6 +357,12 @@ void App::engine_event(Rml::Event &event) {
|
||||
const auto action = node->GetAttribute<Rml::String>("data-action", ""), id = node->GetAttribute<Rml::String>("data-id", "");
|
||||
if (!popup_.empty()) {
|
||||
if(action=="balance-discard"){engine_balance_action(action,node);return;}
|
||||
if (action == "engine-expiry-release") {
|
||||
const auto player = engine_expiry_player_;
|
||||
popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true;
|
||||
if (!player.empty()) { engine_advance_payload_["contractExpiry"][player] = {{"action", "release"}}; engine_kickoff(); }
|
||||
return;
|
||||
}
|
||||
if (action == "popup-close") { popup_.clear(); reset_popup(); engine_files_pending_load_.reset(); engine_exit_after_save_=false; dirty_ = true; }
|
||||
if(action=="files-save-before-load"){const auto pending=engine_files_pending_load_;reset_popup();popup_.clear();engine_files_begin("save");engine_files_pending_load_=pending;return;}
|
||||
if(action=="engine-save-exit"){reset_popup();popup_.clear();engine_exit_after_save_=true;try{engine_save();}catch(const std::exception &e){engine_exit_after_save_=false;message(e.what());}return;}
|
||||
@@ -359,6 +437,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
else if (action == "engine-open" && id == "save") engine_save();
|
||||
else if (action == "engine-open" && (id == "training" || id == "tactics")) { engine_sports_reset(); menu_ = id; refresh(); }
|
||||
else if (action == "engine-open" && id == "lineup") { menu_ = "lineup"; lineup_selected_.clear(); lineup_reset_scroll_ = true; refresh(); }
|
||||
else if (action == "engine-open" && id == "kickoff" && engine_fresh_) engine_kickoff();
|
||||
else if (action == "engine-open" && id == "camp") { menu_ = "camp"; refresh(); }
|
||||
else if (action == "camp-region") { selections_["camp-region"] = id; refresh(); }
|
||||
else if (action == "camp-select") { engine_camp_ = id; refresh(); }
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// The engine's kickoff recording, shaped for the live ticker. Nothing here simulates or
|
||||
// estimates: the recording is copied, its phases and tables are renamed to the ticker's
|
||||
// vocabulary and the desk manager's squad is attached for the team tab.
|
||||
#include "modern/ui/engine_live.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
namespace {
|
||||
Json failure(const std::string &error) { return {{"ok", false}, {"error", error}}; }
|
||||
bool text(const Json &v, size_t max = 400) { return v.is_string() && v.get_ref<const std::string &>().size() <= max; }
|
||||
bool count(const Json &v, uint64_t max = 1000000) { return v.is_number_integer() && v.get<int64_t>() >= 0 && uint64_t(v.get<int64_t>()) <= max; }
|
||||
bool team_ok(const Json &v) { return v.is_object() && text(v.at("id")) && !v.at("id").get_ref<const std::string &>().empty() && text(v.at("name")); }
|
||||
Json metric(const Json &player, const char *key) {
|
||||
try {
|
||||
const auto &value = player.at("metrics").at(key).at("value");
|
||||
return value.is_number_integer() ? value : Json();
|
||||
} catch (const std::exception &) { return Json(); }
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Json engine_advance_command(const Json &bundle, const std::string &request_id, const Json &payload) {
|
||||
validate_engine_desk(bundle);
|
||||
if (request_id.empty()) throw editor::Error("Anfrage-ID fehlt.");
|
||||
const auto &meta = bundle.at("desktop").at("meta");
|
||||
const auto commands = meta.at("scope").value("allowedCommands", Json::array());
|
||||
if (!commands.is_array() || std::find(commands.begin(), commands.end(), Json("session.advance")) == commands.end())
|
||||
throw editor::Error("Der Anstoß ist in diesem Kontext gesperrt.");
|
||||
return {{"messageType", "command"}, {"contractVersion", meta.at("contractVersion")}, {"requestId", request_id},
|
||||
{"careerId", meta.at("careerId")}, {"expectedRevision", meta.at("stateRevision")},
|
||||
{"owner", {{"managerId", meta.at("scope").at("managerId")}}},
|
||||
{"kind", "session.advance"}, {"payload", payload.is_object() ? payload : Json::object()}};
|
||||
}
|
||||
|
||||
bool valid_engine_live_fixture(const Json &v) {
|
||||
try {
|
||||
if (!v.is_object() || !v.value("ok", false) || v.at("schema") != "openbmh-live-fixture@1" ||
|
||||
v.at("source") != "engine-recording" || !text(v.at("fixture_id")) || !count(v.at("source_revision"), UINT64_MAX >> 1) ||
|
||||
!v.at("owners").is_array() || v.at("owners").empty() || v.at("owners").size() > 4 ||
|
||||
!v.at("matches").is_array() || v.at("matches").empty() || v.at("matches").size() > 16 ||
|
||||
!v.at("frames").is_array() || v.at("frames").size() < 2 || v.at("frames").size() > 2000 ||
|
||||
!count(v.at("duration"), 200) || !count(v.at("field_count"), 11) ||
|
||||
(v.at("role") != "club" && v.at("role") != "national") ||
|
||||
(v.at("surface") != "outdoor" && v.at("surface") != "indoor")) return false;
|
||||
std::set<std::string> match_ids, owner_ids;
|
||||
for (const auto &match : v.at("matches")) {
|
||||
if (!text(match.at("id")) || !match_ids.insert(match.at("id")).second || !team_ok(match.at("home")) ||
|
||||
!team_ok(match.at("away")) || !match.at("owners").is_array()) return false;
|
||||
for (const auto &id : match.at("owners")) if (!id.is_string()) return false;
|
||||
}
|
||||
for (const auto &owner : v.at("owners")) {
|
||||
if (!text(owner.at("id")) || !owner_ids.insert(owner.at("id")).second || !text(owner.at("name")) ||
|
||||
!count(owner.at("portrait"), 11) || !team_ok(owner.at("team")) || !match_ids.contains(owner.at("match_id")) ||
|
||||
!owner.at("view").is_object() || owner.at("view").at("engine") != true || !owner.at("view").at("rows").is_array() ||
|
||||
owner.at("view").at("rows").size() > 64) return false;
|
||||
for (const auto &row : owner.at("view").at("rows"))
|
||||
if (!text(row.at("id")) || !text(row.at("name")) || !row.contains("strength") || !row.contains("condition")) return false;
|
||||
}
|
||||
const int64_t duration = v.at("duration");
|
||||
int64_t minute = -1; size_t sequence = 0;
|
||||
for (const auto &frame : v.at("frames")) {
|
||||
if (frame.at("sequence") != sequence++ || !count(frame.at("minute"), uint64_t(duration)) || frame.at("minute").get<int64_t>() < minute ||
|
||||
!frame.at("events").is_array() || frame.at("events").size() > 8000 || !frame.at("matches").is_array() ||
|
||||
frame.at("matches").size() != match_ids.size()) return false;
|
||||
minute = frame.at("minute");
|
||||
const auto phase = frame.value("phase", "");
|
||||
if (phase != "first_half" && phase != "interval" && phase != "second_half" && phase != "extra_time" &&
|
||||
phase != "shootout" && phase != "finished") return false;
|
||||
if ((phase == "finished") != (sequence == v.at("frames").size())) return false;
|
||||
std::set<std::string> scored;
|
||||
for (const auto &m : frame.at("matches")) {
|
||||
if (!match_ids.contains(m.at("match_id")) || !scored.insert(m.at("match_id")).second) return false;
|
||||
for (auto key : {"score", "chances", "yellow", "red", "players"})
|
||||
if (!m.at(key).is_array() || m.at(key).size() != 2 || !count(m.at(key)[0], 1000) || !count(m.at(key)[1], 1000)) return false;
|
||||
if (!m.at("standings").is_array() || m.at("standings").size() > 128) return false;
|
||||
for (const auto &row : m.at("standings")) {
|
||||
if (!team_ok(row.at("team"))) return false;
|
||||
for (auto key : {"position", "played", "gf", "ga", "points"}) if (!count(row.at(key))) return false;
|
||||
}
|
||||
}
|
||||
for (const auto &event : frame.at("events"))
|
||||
if (!text(event.at("id")) || !match_ids.contains(event.at("match_id")) || !count(event.at("minute"), 200) ||
|
||||
!text(event.at("headline")) || !text(event.at("body"), 2200) || !text(event.at("kind"), 40) ||
|
||||
(event.at("side") != "home" && event.at("side") != "away") || !event.at("score").is_array() ||
|
||||
event.at("score").size() != 2 || !count(event.at("score")[0], 1000) || !count(event.at("score")[1], 1000)) return false;
|
||||
}
|
||||
return true;
|
||||
} catch (const std::exception &) { return false; }
|
||||
}
|
||||
|
||||
Json engine_live_fixture(const Json &recording, const Json &bundle) {
|
||||
try {
|
||||
if (!recording.is_object()) return failure("live_unavailable");
|
||||
if (!recording.value("ok", false)) return failure(recording.value("error", "live_unavailable"));
|
||||
Json out = recording;
|
||||
out["source"] = "engine-recording";
|
||||
const std::string role = out.value("role", "club") == "national" ? "national" : "club";
|
||||
out["role"] = role;
|
||||
if (!out.contains("surface")) out["surface"] = "outdoor";
|
||||
|
||||
// The desk manager's squad in line-up order (the squad after the kickoff).
|
||||
std::string desk_team;
|
||||
Json rows = Json::array();
|
||||
try {
|
||||
desk_team = bundle.at("desktop").at("meta").at("scope").at("teamId").get<std::string>();
|
||||
const auto &players = bundle.at("squad").at("data").at("players");
|
||||
std::map<std::string, const Json *> by_id;
|
||||
std::vector<std::string> listed;
|
||||
for (const auto &p : players) {
|
||||
const std::string id = p.at("player").at("id");
|
||||
by_id[id] = &p; listed.push_back(id);
|
||||
}
|
||||
std::vector<std::string> order;
|
||||
try {
|
||||
for (const auto &id : bundle.at("lineup").at("data").at("order")) if (id.is_string()) order.push_back(id);
|
||||
} catch (const std::exception &) {}
|
||||
std::set<std::string> seen;
|
||||
const auto add = [&](const std::string &id) {
|
||||
const auto at = by_id.find(id);
|
||||
if (at == by_id.end() || !seen.insert(id).second) return;
|
||||
const auto &p = *at->second;
|
||||
rows.push_back({{"id", id}, {"name", p.at("player").at("name")}, {"slot", rows.size()},
|
||||
{"strength", metric(p, "strength")}, {"condition", metric(p, "condition")},
|
||||
{"caps", nullptr}, {"international_goals", nullptr}});
|
||||
};
|
||||
for (const auto &id : order) add(id);
|
||||
for (const auto &id : listed) add(id);
|
||||
} catch (const std::exception &) { rows = Json::array(); }
|
||||
|
||||
if (!out.at("owners").is_array() || out.at("owners").empty()) return failure("live_no_human_match");
|
||||
std::set<int> portraits;
|
||||
for (auto &owner : out.at("owners")) {
|
||||
int portrait = owner.value("portrait", 0);
|
||||
portrait = std::clamp(portrait, 0, 11);
|
||||
for (int tries = 0; tries < 12 && portraits.contains(portrait); ++tries) portrait = (portrait + 1) % 12;
|
||||
portraits.insert(portrait);
|
||||
owner["portrait"] = portrait;
|
||||
if (!owner.at("team").contains("role")) owner["team"]["role"] = role;
|
||||
const bool own = owner.at("team").at("id") == desk_team;
|
||||
owner["view"] = {{"ok", true}, {"engine", true}, {"rows", own ? rows : Json::array()},
|
||||
{"field_count", out.value("field_count", 11)}};
|
||||
}
|
||||
for (auto &match : out.at("matches")) {
|
||||
for (auto side : {"home", "away"}) if (!match.at(side).contains("role")) match[side]["role"] = role;
|
||||
if (!match.contains("owners") || !match.at("owners").is_array()) match["owners"] = Json::array();
|
||||
}
|
||||
|
||||
// Tables arrive on the frame when they change; the ticker wants each match's table.
|
||||
std::map<std::string, Json> tables; // competition id -> ticker rows
|
||||
const int64_t duration = out.value("duration", 90);
|
||||
auto &frames = out.at("frames");
|
||||
for (size_t i = 0; i < frames.size(); ++i) {
|
||||
auto &frame = frames[i];
|
||||
const std::string phase = frame.value("phase", "");
|
||||
const bool last = i + 1 == frames.size();
|
||||
frame["phase"] = last ? "finished"
|
||||
: phase == "kickoff" ? "first_half"
|
||||
: phase == "restart" ? "second_half"
|
||||
: phase == "fulltime" || phase == "shootout_end" || phase == "finished" ? "second_half"
|
||||
: phase;
|
||||
if (frame.at("minute").is_number_integer()) frame["minute"] = std::clamp<int64_t>(frame.at("minute").get<int64_t>(), 0, duration);
|
||||
if (frame.contains("standings") && frame.at("standings").is_array())
|
||||
for (const auto &table : frame.at("standings")) {
|
||||
if (!table.is_object() || !table.contains("rows")) continue;
|
||||
Json converted = Json::array();
|
||||
for (const auto &row : table.at("rows")) {
|
||||
Json team = row.at("team");
|
||||
team["role"] = "club";
|
||||
converted.push_back({{"team", team}, {"position", row.at("rank")}, {"played", row.at("played")},
|
||||
{"gf", row.at("goalsFor")}, {"ga", row.at("goalsAgainst")}, {"points", row.at("points")}});
|
||||
}
|
||||
tables[table.value("competitionId", std::string("table"))] = std::move(converted);
|
||||
}
|
||||
for (auto &score : frame.at("matches")) {
|
||||
score["standings"] = Json::array();
|
||||
for (auto key : {"score", "chances", "yellow", "red", "players"})
|
||||
for (auto &value : score.at(key)) if (value.is_number_integer() && value.get<int64_t>() < 0) value = 0;
|
||||
const Json *home = nullptr;
|
||||
for (const auto &match : out.at("matches")) if (match.at("id") == score.at("match_id")) home = &match.at("home").at("id");
|
||||
if (!home || role == "national") continue;
|
||||
for (const auto &[id, table] : tables) {
|
||||
(void)id;
|
||||
const bool has = std::any_of(table.begin(), table.end(), [&](const Json &row) { return row.at("team").at("id") == *home; });
|
||||
if (has) { score["standings"] = table; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!valid_engine_live_fixture(out)) return failure("invalid_live_fixture");
|
||||
return out;
|
||||
} catch (const std::exception &) { return failure("invalid_live_fixture"); }
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/engine_bridge.hpp"
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// The command that plays the next kickoff (or moves to the next desk day). `payload` carries
|
||||
// answers the engine asked for, such as contract decisions.
|
||||
Json engine_advance_command(const Json &bundle, const std::string &request_id, const Json &payload);
|
||||
// Shapes the engine's recording of the last kickoff for the live ticker. `bundle` is the
|
||||
// desk snapshot read after the kickoff; it supplies the desk manager's squad.
|
||||
// Returns {ok:false,error} when there is nothing to show.
|
||||
Json engine_live_fixture(const Json &recording, const Json &bundle);
|
||||
bool valid_engine_live_fixture(const Json &);
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -54,6 +54,8 @@ void App::engine_render() {
|
||||
if (engine_data_.empty()) {
|
||||
out = "<div class=\"fill center\"><div class=\"panel\" style=\"padding:70dp;\"><h1>OpenBMH</h1><p>" +
|
||||
esc(engine_busy_ ? "Spielstand wird geladen …" : engine_notice_) + "</p></div></div>";
|
||||
} else if (scene_ == "live" && live_.available()) {
|
||||
out = render_live();
|
||||
} else if(engine_opening_active()&&menu_.empty()) {
|
||||
out=main_menu()+"<div class=\"fill\" style=\"z-index:100;\">"+render_opening()+"</div>";
|
||||
} else {
|
||||
@@ -132,7 +134,7 @@ void App::engine_render() {
|
||||
const auto route = id.substr(4);
|
||||
const bool camp_allowed = desk.at("menuAvailability").at("camps").value("status", "") == "available";
|
||||
const auto commands = meta.at("scope").value("allowedCommands", Json::array());
|
||||
const bool supported = (route=="newplayer"&&engine_fresh_&&engine_manager_value_.is_object()) || (route=="settings"&&engine_fresh_&&engine_settings_value_.is_object()) || (route=="indoor"&&engine_fresh_&&engine_indoor_value_.is_object()) || ((route=="tables"||route=="strengths"||route=="league"||route=="other"||route=="scorers"||route=="fairplay")&&engine_fresh_&&meta.at("scope").at("role")=="club") || (route == "almanac" && engine_fresh_) || (route == "friendlies" && friendlies_available && engine_fresh_) || (route == "calendar" && calendar_available && engine_fresh_) || (route == "postpone" && scheduling_available && engine_fresh_) || (route == "contracts" && contracts_available && engine_fresh_) || (route == "environment" && environment_available && engine_fresh_) || (route == "advertising" && advertising_available && engine_fresh_) || (route == "bank" && bank_available && engine_fresh_) || (route == "training" && training_available && engine_fresh_) || (route == "tactics" && tactics_available && engine_fresh_) || (route == "lineup" && lineup_available && engine_fresh_) || (route=="balance"&&engine_fresh_&&engine_data_.at("balance").value("messageType","")=="snapshot") || (route=="news"&&engine_fresh_&&engine_news_value_.is_object()) || (route=="achievements"&&engine_fresh_&&engine_data_.at("achievements").value("messageType","")=="snapshot"&&engine_data_.at("achievements").at("data").at("available")==true) || (route=="transfer"&&engine_fresh_&&engine_transfer_value_.is_object()) || (route=="stadium"&&engine_fresh_&&engine_stadium_value_.is_object()) || (route=="toto"&&engine_fresh_&&engine_toto_value_.is_object()) || (route=="statistics"&&engine_fresh_) || route == "save" || route == "load" || (route == "camp" && engine_fresh_ && camp_allowed && std::find(commands.begin(), commands.end(), Json("camp.book")) != commands.end());
|
||||
const bool supported = (route=="newplayer"&&engine_fresh_&&engine_manager_value_.is_object()) || (route=="settings"&&engine_fresh_&&engine_settings_value_.is_object()) || (route=="indoor"&&engine_fresh_&&engine_indoor_value_.is_object()) || ((route=="tables"||route=="strengths"||route=="league"||route=="other"||route=="scorers"||route=="fairplay")&&engine_fresh_&&meta.at("scope").at("role")=="club") || (route == "almanac" && engine_fresh_) || (route == "friendlies" && friendlies_available && engine_fresh_) || (route == "calendar" && calendar_available && engine_fresh_) || (route == "postpone" && scheduling_available && engine_fresh_) || (route == "contracts" && contracts_available && engine_fresh_) || (route == "environment" && environment_available && engine_fresh_) || (route == "advertising" && advertising_available && engine_fresh_) || (route == "bank" && bank_available && engine_fresh_) || (route == "training" && training_available && engine_fresh_) || (route == "tactics" && tactics_available && engine_fresh_) || (route == "lineup" && lineup_available && engine_fresh_) || (route=="balance"&&engine_fresh_&&engine_data_.at("balance").value("messageType","")=="snapshot") || (route=="news"&&engine_fresh_&&engine_news_value_.is_object()) || (route=="achievements"&&engine_fresh_&&engine_data_.at("achievements").value("messageType","")=="snapshot"&&engine_data_.at("achievements").at("data").at("available")==true) || (route=="transfer"&&engine_fresh_&&engine_transfer_value_.is_object()) || (route=="stadium"&&engine_fresh_&&engine_stadium_value_.is_object()) || (route=="toto"&&engine_fresh_&&engine_toto_value_.is_object()) || (route=="statistics"&&engine_fresh_) || route == "save" || route == "load" || (route == "kickoff" && engine_fresh_ && std::find(commands.begin(), commands.end(), Json("session.advance")) != commands.end()) || (route == "camp" && engine_fresh_ && camp_allowed && std::find(commands.begin(), commands.end(), Json("camp.book")) != commands.end());
|
||||
out += desktop_button(id, o, "engine-open", supported && !engine_busy_ && (!engine_manager_value_.is_object() || engine_manager_value_.at("ended")!=true || route=="save" || route=="load" || route=="newplayer"));
|
||||
}
|
||||
}
|
||||
@@ -167,10 +169,11 @@ void App::engine_render() {
|
||||
if (menu_ == "camp") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Trainingslager", render_camp()) + "</div>";
|
||||
}
|
||||
if ((menu_ == "stadium" || menu_ == "bank" || menu_ == "environment" || menu_ == "advertising" || menu_ == "contracts" || menu_ == "calendar" || menu_ == "postpone" || menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league" || menu_=="other" || menu_=="scorers" || menu_=="fairplay") && !amount_ && contracts_dialog_.empty() && planning_dialog_.empty()) out += "<div class=\"panel\" style=\"position:absolute;bottom:12dp;left:700dp;right:700dp;padding:9dp;font-size:25dp;z-index:110;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
|
||||
if (menu_.empty() || engine_data_.empty()) out += "<div class=\"panel\" style=\"position:absolute;left:850dp;bottom:24dp;right:100dp;padding:18dp;font-size:27dp;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
|
||||
if ((menu_.empty() || engine_data_.empty()) && !(scene_ == "live" && live_.available())) out += "<div class=\"panel\" style=\"position:absolute;left:850dp;bottom:24dp;right:100dp;padding:18dp;font-size:27dp;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
|
||||
if(menu_=="statistics")out+=render_statistics_trophy();
|
||||
element("canvas")->SetProperty("overflow",statistics_trophy_.contains("asset")?"visible":"hidden");
|
||||
element("canvas")->SetInnerRML(out); ++document_generation_;
|
||||
live_detail_pending_ = live_ticker_pending_ = false;
|
||||
scale_chalk_shadow();
|
||||
if (!engine_player_.empty()) {
|
||||
Rml::ElementList underlay; doc_->QuerySelectorAll(underlay, "#lineup-underlay button,#window-close");
|
||||
|
||||
@@ -24,11 +24,37 @@ bool App::live_open() {
|
||||
focus_after_render_ = "live-next";
|
||||
refresh(); return true;
|
||||
}
|
||||
bool App::engine_live_open(const Json &recording) {
|
||||
const auto fixture = engine_live_fixture(recording, engine_data_);
|
||||
if (!fixture.value("ok", false) || !live_.open(fixture, "")) {
|
||||
engine_notice_ = "Spieltag gespielt · Der Ticker kann diese Aufzeichnung nicht zeigen (" +
|
||||
fixture.value("error", std::string("invalid_live_fixture")) + ").";
|
||||
return false;
|
||||
}
|
||||
try { live_.owner(engine_data_.at("desktop").at("meta").at("scope").at("managerId").get<std::string>()); }
|
||||
catch (const std::exception &) {}
|
||||
live_source_ = nullptr; live_world_ = world_;
|
||||
postmatch_data_=Json::object();postmatch_scrolls_=Json::object();postmatch_playing_=false;
|
||||
live_drafts_ = Json::object(); live_dialog_.clear(); live_dialog_draft_ = Json();
|
||||
live_coverage_ = "all"; live_filter_ = "all"; live_tab_ = "team";
|
||||
live_selected_match_ = fixture.at("matches").front().at("id");
|
||||
for (const auto &owner : fixture.at("owners")) if (owner.at("id") == live_.owner()) live_selected_match_ = owner.at("match_id");
|
||||
live_ticker_scroll_ = live_detail_scroll_ = 0;
|
||||
live_reset_ticker_ = live_reset_detail_ = true;
|
||||
live_feedback_.clear(); live_resume_speed_ = 0;
|
||||
live_review_ = false; live_speed_dragging_ = false;
|
||||
if (scene_ != "live") live_return_scene_ = scene_;
|
||||
scene_ = "live"; menu_.clear();
|
||||
live_.speed(2); live_last_tick_ = SDL_GetTicks64();
|
||||
focus_after_render_ = "live-pause";
|
||||
return true;
|
||||
}
|
||||
void App::live_close() {
|
||||
live_review_=false;postmatch_playing_=false;
|
||||
live_.speed(0); live_dialog_.clear(); live_dialog_draft_ = Json();
|
||||
live_resume_speed_ = 0; live_speed_dragging_ = false;
|
||||
scene_ = "desktop"; menu_.clear(); focus_after_render_ = "object-app-kickoff"; refresh();
|
||||
if (engine_mode_) { scene_ = live_return_scene_; live_.close(); } else scene_ = "desktop";
|
||||
menu_.clear(); focus_after_render_ = "object-app-kickoff"; refresh();
|
||||
}
|
||||
void App::live_set_speed(int value) {
|
||||
if (!live_.speed(value)) return;
|
||||
@@ -43,9 +69,10 @@ void App::live_set_speed(int value) {
|
||||
if (auto *node = element("live-speed-value")) node->SetInnerRML(esc(value ? std::to_string(value) + "×" : "Pause"));
|
||||
if (auto *node = element("live-pause")) node->SetInnerRML(live_text(value ? "Pause" : "Abspielen", "control-label"));
|
||||
const auto &frame = live_.fixture().at("frames")[live_.sequence()];
|
||||
const std::string phase = live_.finished() ? "Beendet" : frame.at("phase") == "interval" ? "Halbzeit" : value ? "Aufzeichnung läuft" : "Gemeinsam pausiert";
|
||||
const bool recorded = live_.fixture().at("source") == "engine-recording";
|
||||
const std::string phase = live_.finished() ? "Beendet" : frame.at("phase") == "interval" ? "Halbzeit" : value ? (recorded ? "Spiel läuft" : "Aufzeichnung läuft") : (recorded ? "Pausiert" : "Gemeinsam pausiert");
|
||||
if (auto *node = element("live-phase-status")) node->SetInnerRML(esc(phase));
|
||||
if (auto *node = element("live-playback-status")) node->SetInnerRML(esc(phase + " · " + std::to_string(frame.at("minute").get<int>()) + "′ · keine Spielwertänderung"));
|
||||
if (auto *node = element("live-playback-status")) node->SetInnerRML(esc(phase + " · " + std::to_string(frame.at("minute").get<int>()) + (recorded ? "′" : "′ · keine Spielwertänderung")));
|
||||
dirty_ = true;
|
||||
}
|
||||
void App::live_tick() {
|
||||
@@ -53,9 +80,9 @@ void App::live_tick() {
|
||||
const auto now = SDL_GetTicks64(), elapsed = now - live_last_tick_; live_last_tick_ = now;
|
||||
if(live_review_){postmatch_tick(now);return;}
|
||||
if (!popup_.empty() || !live_dialog_.empty() || live_speed_dragging_ || live_review_) return;
|
||||
const auto current = source_ ? source_->snapshot() : Snapshot();
|
||||
if (!source_ || source_.get() != live_source_ || current.world != live_world_ ||
|
||||
current.revision != live_.fixture().at("source_revision").get<uint64_t>()) {
|
||||
const auto current = source_ && !engine_mode_ ? source_->snapshot() : Snapshot();
|
||||
if (!engine_mode_ && (!source_ || source_.get() != live_source_ || current.world != live_world_ ||
|
||||
current.revision != live_.fixture().at("source_revision").get<uint64_t>())) {
|
||||
live_.speed(0);
|
||||
if (live_feedback_ != "Die Quelle hat sich geändert. Diese Aufzeichnung bleibt pausiert; öffne Anstoß erneut.") { live_feedback_ = "Die Quelle hat sich geändert. Diese Aufzeichnung bleibt pausiert; öffne Anstoß erneut."; needs_render_ = true; }
|
||||
return;
|
||||
@@ -120,11 +147,12 @@ bool App::live_action(const std::string &action, Rml::Element *target) {
|
||||
} else if (action == "live-pause") {
|
||||
live_set_speed(live_.speed() ? 0 : 1); return true;
|
||||
} else if (action == "live-review" && live_.finished()) {
|
||||
postmatch_open();return true;
|
||||
if (live_.fixture().at("source") == "engine-recording") live_close(); else postmatch_open();
|
||||
return true;
|
||||
} else if (action == "live-review-back") {
|
||||
postmatch_action("postmatch-ticker",target);return true;
|
||||
} else if (action == "live-intervene-lineup" || action == "live-intervene-tactics") {
|
||||
if (live_.finished()) return true;
|
||||
if (live_.finished() || live_.fixture().at("source") == "engine-recording") return true;
|
||||
const auto owner = live_owner(); live_dialog_draft_ = live_owner_state(owner);
|
||||
live_dialog_ = action == "live-intervene-lineup" ? "lineup" : "tactics";
|
||||
live_resume_speed_ = live_.speed(); live_.speed(0); live_last_tick_ = SDL_GetTicks64();
|
||||
|
||||
@@ -21,10 +21,12 @@ Json App::live_owner() const {
|
||||
return Json();
|
||||
}
|
||||
Json App::live_owner_state(const Json &owner) const {
|
||||
if (owner.at("view").value("engine", false)) return Json::object();
|
||||
const auto id = owner.at("id").get<std::string>();
|
||||
return live_drafts_.contains(id) ? live_drafts_.at(id) : owner.at("view").at("edit_state");
|
||||
}
|
||||
Json App::live_owner_rows(const Json &owner) const {
|
||||
if (owner.at("view").value("engine", false)) return owner.at("view").at("rows");
|
||||
if (!live_world_) return Json::array();
|
||||
const auto view = live_owner_state(owner);
|
||||
const auto projection = demo_lineup_rows(view, *live_world_, owner.at("view").at("club_basis"));
|
||||
@@ -58,9 +60,10 @@ std::string App::live_roster(const Json &owner) {
|
||||
live_text("Nr.", "live-roster-number") + live_text(owner.at("team").at("name"), "live-roster-name") +
|
||||
live_text(national ? "Caps" : "Stä.", "live-roster-stat") + live_text(national ? "Tore" : "Ko.", "live-roster-stat") + "</div>";
|
||||
const auto rows = live_owner_rows(owner);
|
||||
if (national) out += "<p class=\"live-roster-note\">" + live_text("Demokader auf Vereinsbasis · keine Nationalkaderberufung") + "</p>";
|
||||
const bool recorded = live_.fixture().at("source") == "engine-recording";
|
||||
if (national && !recorded) out += "<p class=\"live-roster-note\">" + live_text("Demokader auf Vereinsbasis · keine Nationalkaderberufung") + "</p>";
|
||||
for (size_t i = 0; i < rows.size(); ++i) {
|
||||
if (int(i) == field_count) out += "<p class=\"live-roster-note\">" + live_text(field_count == 6 ? "Rotationspartner · erster 11er-Plan" : "Reserven · Demovorschau") + "</p>";
|
||||
if (int(i) == field_count) out += "<p class=\"live-roster-note\">" + live_text(field_count == 6 ? "Rotationspartner · erster 11er-Plan" : recorded ? "Ersatzbank und Reserve" : "Reserven · Demovorschau") + "</p>";
|
||||
if (field_count == 6 && i == 11) out += "<p class=\"live-roster-note\">" + live_text("Weitere Kaderreserven") + "</p>";
|
||||
const auto &row = rows[i];
|
||||
out += "<div class=\"live-roster-row\" data-live-player=\"" + esc(row.at("id").get<std::string>()) + "\">" +
|
||||
@@ -68,7 +71,7 @@ std::string App::live_roster(const Json &owner) {
|
||||
live_text(lineup_value(row.at(national ? "caps" : "strength")), "live-roster-stat") +
|
||||
live_text(lineup_value(row.at(national ? "international_goals" : "condition")), "live-roster-stat") + "</div>";
|
||||
}
|
||||
if (rows.empty()) out += "<p class=\"live-note\">" + live_text("Für diese Demomannschaft sind keine Kaderspieler verfügbar.") + "</p>";
|
||||
if (rows.empty()) out += "<p class=\"live-note\">" + live_text(recorded ? "Für diese Mannschaft liegt keine Kaderansicht vor." : "Für diese Demomannschaft sind keine Kaderspieler verfügbar.") + "</p>";
|
||||
return out + "</div>";
|
||||
}
|
||||
std::string App::live_detail(const Json &owner, const Json &frame) {
|
||||
@@ -76,9 +79,11 @@ std::string App::live_detail(const Json &owner, const Json &frame) {
|
||||
const auto &match = live_match_by_id(fixture.at("matches"), owner.at("match_id"));
|
||||
const auto &score = live_score_by_id(frame, match.at("id"));
|
||||
if (live_tab_ == "team") return live_roster(owner);
|
||||
const bool recorded = fixture.at("source") == "engine-recording";
|
||||
if (live_tab_ == "table") {
|
||||
if (recorded && score.at("standings").empty()) return "<p class=\"live-note\">" + live_text("Diese Partie gehört zu keiner Ligatabelle.") + "</p>";
|
||||
if (fixture.at("role") == "national") return "<p class=\"live-note\">" + live_text("Dieses Demo-Länderspiel gehört zu keiner Liga. Der Spielstand steht links; eine Vereins-Live-Tabelle wird nicht eingeblendet.") + "</p>";
|
||||
std::string out = "<p class=\"live-note\">" + live_text("Vorgegebene Demo-Tabelle · keine echte Saisonwertung") + "</p><div class=\"live-table\" role=\"table\" aria-label=\"Demo-Live-Tabelle\"><div class=\"live-table-row heading\">" +
|
||||
std::string out = "<p class=\"live-note\">" + live_text(recorded ? "Tabelle zum Stand dieser Spielminute" : "Vorgegebene Demo-Tabelle · keine echte Saisonwertung") + "</p><div class=\"live-table\" role=\"table\" aria-label=\"Live-Tabelle\"><div class=\"live-table-row heading\">" +
|
||||
live_text("Pl.", "live-table-pos") + "<div class=\"live-table-team\">" + live_text("Verein") + "</div>" + live_text("Sp.", "live-table-number") +
|
||||
live_text("Tore", "live-table-number live-table-goals") + live_text("Diff.", "live-table-number") + live_text("Pkt.", "live-table-number") + "</div>";
|
||||
for (const auto &row : score.at("standings")) {
|
||||
@@ -94,6 +99,8 @@ std::string App::live_detail(const Json &owner, const Json &frame) {
|
||||
}
|
||||
return out + "</div>";
|
||||
}
|
||||
if (live_tab_ == "tactics" && recorded)
|
||||
return "<div class=\"live-context\"><h3>" + live_text("Taktik") + "</h3><p>" + live_text("Dieser Spieltag wurde mit der Aufstellung und Taktik vom Schreibtisch gespielt. Eingriffe während des Spiels folgen mit dem Live-Modus.") + "</p></div>";
|
||||
if (live_tab_ == "tactics") {
|
||||
const auto state = live_owner_state(owner), board = demo_lineup_visible(state);
|
||||
Json points = Json::array(); const int count = fixture.at("field_count");
|
||||
@@ -106,7 +113,7 @@ std::string App::live_detail(const Json &owner, const Json &frame) {
|
||||
std::string out;
|
||||
if (live_tab_ == "opponent") {
|
||||
const auto &opponent = match.at(owner.at("team").at("id") == match.at("home").at("id") ? "away" : "home");
|
||||
out = "<div class=\"live-context\"><h3>" + live_text(opponent.at("name")) + "</h3><p>" + live_text("Gegner dieser vorgegebenen Demopartie. Es werden keine unbekannten Gegneranweisungen behauptet.") + "</p></div>";
|
||||
out = "<div class=\"live-context\"><h3>" + live_text(opponent.at("name")) + "</h3><p>" + live_text(recorded ? "Gegner dieser Partie." : "Gegner dieser vorgegebenen Demopartie. Es werden keine unbekannten Gegneranweisungen behauptet.") + "</p></div>";
|
||||
}
|
||||
const std::array<std::pair<const char *, const char *>, 5> fields{{{"Tore", "score"}, {"Chancen", "chances"}, {"Gelbe Karten", "yellow"}, {"Rote Karten", "red"}, {"Spieler auf dem Feld", "players"}}};
|
||||
for (const auto &[label, key] : fields) {
|
||||
@@ -115,7 +122,7 @@ std::string App::live_detail(const Json &owner, const Json &frame) {
|
||||
out += "<div class=\"live-stat\"><div class=\"live-stat-label\">" + live_text(std::to_string(a)) + live_text(label, "stat-title") + live_text(std::to_string(b)) +
|
||||
"</div><div class=\"live-stat-bar\"><div class=\"home\" style=\"width:" + scalar(percent) + "%;\"></div><div class=\"away\"></div></div></div>";
|
||||
}
|
||||
return out + "<p class=\"live-note\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>() + " · vorgegebene Demowerte") + "</p>";
|
||||
return out + "<p class=\"live-note\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>() + (recorded ? "" : " · vorgegebene Demowerte")) + "</p>";
|
||||
}
|
||||
std::string App::live_dialog_markup(const Json &owner) {
|
||||
if (live_dialog_.empty()) return "";
|
||||
@@ -151,7 +158,7 @@ std::string App::live_ticker_events(const Json &frame, size_t &shown) {
|
||||
"<div class=\"live-event-copy\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>(), "live-event-owners") + "<h3>" + live_text(event.at("headline")) + "</h3><p>" + live_text(event.at("body")) + "</p></div>" + live_text(live_score_text(event.at("score")), "live-event-score") + "</article>";
|
||||
++shown;
|
||||
}
|
||||
if (!shown) out += "<p class=\"live-note\">" + live_text("Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
|
||||
if (!shown) out += "<p class=\"live-note\">" + live_text(fixture.at("source") == "engine-recording" ? "Für diesen Filter liegt noch keine Meldung vor." : "Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
|
||||
return out;
|
||||
}
|
||||
std::string App::render_live() {
|
||||
@@ -163,10 +170,11 @@ std::string App::render_live() {
|
||||
live_restore_scroll_ = true;
|
||||
const auto &fixture = live_.fixture(); const auto frame = live_.frame(); const auto owner = live_owner();
|
||||
const int minute = frame.at("minute"); const auto phase = frame.at("phase").get<std::string>();
|
||||
const auto phase_text = live_.finished() ? "Beendet" : phase == "interval" ? "Halbzeit" : live_.speed() ? "Aufzeichnung läuft" : "Gemeinsam pausiert";
|
||||
const bool recorded = fixture.at("source") == "engine-recording";
|
||||
const auto phase_text = live_.finished() ? "Beendet" : phase == "interval" ? "Halbzeit" : live_.speed() ? (recorded ? (phase == "extra_time" ? "Verlängerung" : phase == "shootout" ? "Elfmeterschießen" : "Spiel läuft") : "Aufzeichnung läuft") : (recorded ? "Pausiert" : "Gemeinsam pausiert");
|
||||
const auto arrow = [&](bool right) { const auto color = theme_ == "silver" ? "#376b84" : theme_ == "matchday" ? "#efb2aa" : "#b5dbd2"; return picture(renderer_.diagram(right ? "live-arrow-right" : "live-arrow-left", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path d=\"" + std::string(right ? "M7 4l6 6-6 6" : "M13 4l-6 6 6 6") + "\" fill=\"none\" stroke=\"" + color + "\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>", 72), 36, 36); };
|
||||
std::string out = "<section id=\"live-stage\" class=\"live-stage\" data-source=\"ui-demo-fixture\" data-fixture-id=\"" + esc(fixture.at("fixture_id").get<std::string>()) + "\"><header class=\"live-header\"><div>" + live_text("SPIELTAG · LIVE-TICKER", "live-eyebrow") +
|
||||
"<h1>" + live_text(live_review_ ? "Ergebnisse & Bericht" : fixture.at("role") == "national" ? "Deutschland · Demo-Länderspiel" : fixture.at("surface") == "indoor" ? "Hallenpartien · 40 Minuten" : "Gemeinsamer Spieltag") + "</h1></div>" + live_text("UI-Demo · vorgegebene Ergebnisse", "live-demo-tag") + "</header>";
|
||||
std::string out = "<section id=\"live-stage\" class=\"live-stage\" data-source=\"" + std::string(recorded ? "engine-recording" : "ui-demo-fixture") + "\" data-fixture-id=\"" + esc(fixture.at("fixture_id").get<std::string>()) + "\"><header class=\"live-header\"><div>" + live_text("SPIELTAG · LIVE-TICKER", "live-eyebrow") +
|
||||
"<h1>" + live_text(live_review_ ? "Ergebnisse & Bericht" : fixture.at("role") == "national" ? "Deutschland · Demo-Länderspiel" : fixture.at("surface") == "indoor" ? "Hallenpartien · 40 Minuten" : recorded ? fixture.at("matches").front().value("competition", std::string("Spieltag")) : std::string("Gemeinsamer Spieltag")) + "</h1></div>" + live_text(recorded ? fixture.value("date", std::string()) : std::string("UI-Demo · vorgegebene Ergebnisse"), "live-demo-tag") + "</header>";
|
||||
const auto scoreline = [&](const Json &match) {
|
||||
const auto &value = live_score_by_id(frame, match.at("id"));
|
||||
return "<div class=\"live-scoreline\">" + live_text(match.at("home").at("name"), "live-team-name home") + live_badge(match.at("home"), 58) + live_text(live_score_text(value.at("score")), "live-score") + live_badge(match.at("away"), 58) + live_text(match.at("away").at("name"), "live-team-name away") + "</div>";
|
||||
@@ -180,20 +188,20 @@ std::string App::render_live() {
|
||||
if (live_coverage_ == "single" && match.at("id") != live_selected_match_) continue;
|
||||
std::string names;
|
||||
for (const auto &id : match.at("owners")) for (const auto &person : fixture.at("owners")) if (person.at("id") == id) { if (!names.empty()) names += " · "; names += person.at("name").get<std::string>(); }
|
||||
out += "<button data-action=\"live-match\" class=\"live-game " + std::string(match.at("id") == live_selected_match_ ? "active" : "") + "\" data-live-match=\"" + esc(match.at("id").get<std::string>()) + "\" data-id=\"" + esc(match.at("id").get<std::string>()) + "\">" + live_text(names, "live-owners") + scoreline(match) + live_text(std::to_string(minute) + "′ · " + (match.at("owners").size() > 1 ? "Zwei menschliche Manager" : "Eine menschliche Mannschaft"), "live-card-caption") + live_text(live_match_info_text(match, fixture.at("surface") == "indoor"), "live-match-info") + "</button>";
|
||||
out += "<button data-action=\"live-match\" class=\"live-game " + std::string(match.at("id") == live_selected_match_ ? "active" : "") + "\" data-live-match=\"" + esc(match.at("id").get<std::string>()) + "\" data-id=\"" + esc(match.at("id").get<std::string>()) + "\">" + live_text(names, "live-owners") + scoreline(match) + live_text(std::to_string(minute) + "′ · " + (match.at("owners").size() > 1 ? std::string("Zwei menschliche Manager") : recorded ? match.value("competition", std::string("Eine menschliche Mannschaft")) : std::string("Eine menschliche Mannschaft")), "live-card-caption") + live_text(live_match_info_text(match, fixture.at("surface") == "indoor"), "live-match-info") + "</button>";
|
||||
}
|
||||
out += "</div></section><section class=\"live-panel live-ticker\"><header class=\"live-panel-heading\"><h2>" + live_text("Gemeinsamer Live-Ticker") + "</h2>" + live_text(live_coverage_ == "single" ? "Gewählte Partie" : "Alle Manager", "live-small") + "</header><nav class=\"live-filters\">";
|
||||
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 4>{{{"all", "Alles"}, {"highlights", "Highlights"}, {"goal", "Tore"}, {"yellow", "Karten"}}}) out += btn("live-filter", label, live_filter_ == id ? "selected" : "", "id=\"live-filter-" + std::string(id) + "\" data-id=\"" + id + "\"");
|
||||
out += "</nav><div id=\"live-ticker\" class=\"live-event-list\" tabindex=\"0\" aria-label=\"Gemeinsamer Ereignisverlauf\">";
|
||||
size_t shown = 0;
|
||||
out += live_ticker_events(frame, shown);
|
||||
out += "</div><footer class=\"live-ticker-footer\">" "<span id=\"live-event-count\" class=\"live-small\">" + esc(std::to_string(shown) + " Meldungen · feste Aufzeichnung") + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + "<span id=\"live-owner-team\">" + esc(owner.at("team").at("name").get<std::string>()) + "</span></h2><p><span id=\"live-owner-name\">" + esc(owner.at("name").get<std::string>()) + "</span>" + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
|
||||
out += "</div><footer class=\"live-ticker-footer\">" "<span id=\"live-event-count\" class=\"live-small\">" + esc(std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? " Meldungen" : " Meldungen · feste Aufzeichnung")) + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + "<span id=\"live-owner-team\">" + esc(owner.at("team").at("name").get<std::string>()) + "</span></h2><p><span id=\"live-owner-name\">" + esc(owner.at("name").get<std::string>()) + "</span>" + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
|
||||
btn("live-owner-prev", arrow(false), "", "id=\"live-owner-prev\" aria-label=\"Vorheriger Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + btn("live-owner-next", arrow(true), "", "id=\"live-owner-next\" aria-label=\"Nächster Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + "</nav></header><nav class=\"live-tabs\">";
|
||||
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 5>{{{"team", "Team"}, {"tactics", "Taktik"}, {"opponent", "Gegner"}, {"table", "Live-Tabelle"}, {"stats", "Statistik"}}}) out += btn("live-tab", label, live_tab_ == id ? "selected" : "", "id=\"live-tab-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (live_tab_ == id ? "true" : "false") + "\"");
|
||||
out += "</nav><div id=\"live-detail-body\" class=\"live-detail-body\" tabindex=\"0\">" + live_detail(owner, frame) + "</div><footer class=\"live-detail-footer\">" + btn("live-intervene-lineup", "Aufstellung & Wechsel", "", "id=\"live-lineup-edit\" " + std::string(live_.finished() ? "disabled" : "")) + "</footer></aside></div>";
|
||||
out += "</nav><div id=\"live-detail-body\" class=\"live-detail-body\" tabindex=\"0\">" + live_detail(owner, frame) + "</div><footer class=\"live-detail-footer\">" + btn("live-intervene-lineup", "Aufstellung & Wechsel", "", "id=\"live-lineup-edit\" " + std::string(live_.finished() || recorded ? "disabled" : "")) + "</footer></aside></div>";
|
||||
out += "<div class=\"live-speed\">" + live_text("+") + "<input id=\"live-speed\" type=\"range\" orientation=\"vertical\" min=\"0\" max=\"4\" step=\"1\" value=\"" + std::to_string(4 - live_.speed()) + "\" aria-label=\"Wiedergabegeschwindigkeit; unten Pause\" aria-valuenow=\"" + std::to_string(live_.speed()) + "\" " + (live_.finished() ? "disabled" : "") + "/><span id=\"live-speed-value\" class=\"live-speed-value\">" + esc(live_.finished() ? "Ende" : live_.speed() ? std::to_string(live_.speed()) + "×" : "Pause") + "</span></div>";
|
||||
out += "<footer class=\"live-bottom\"><div class=\"live-bottom-actions\">" + btn("live-back", "Zum Desktop", "", "id=\"live-back\"") + btn("live-pause", live_.speed() ? "Pause" : "Abspielen", "", "id=\"live-pause\" " + std::string(live_.finished() ? "disabled" : "")) + "</div><span id=\"live-playback-status\" class=\"live-bottom-note\">" + esc(live_feedback_.empty() ? std::string(phase_text) + " · " + std::to_string(minute) + "′ · keine Spielwertänderung" : live_feedback_) + "</span>" +
|
||||
btn(live_.finished() ? "live-review" : "live-next", live_.finished() ? "Zur Auswertung" : "Nächste Meldung", "", "id=\"" + std::string(live_.finished() ? "live-review" : "live-next") + "\"") + "</footer>";
|
||||
out += "<footer class=\"live-bottom\"><div class=\"live-bottom-actions\">" + btn("live-back", recorded ? "Zum Schreibtisch" : "Zum Desktop", "", "id=\"live-back\"") + btn("live-pause", live_.speed() ? "Pause" : "Abspielen", "", "id=\"live-pause\" " + std::string(live_.finished() ? "disabled" : "")) + "</div><span id=\"live-playback-status\" class=\"live-bottom-note\">" + esc(live_feedback_.empty() ? std::string(phase_text) + " · " + std::to_string(minute) + (recorded ? "′" : "′ · keine Spielwertänderung") : live_feedback_) + "</span>" +
|
||||
btn(live_.finished() ? "live-review" : "live-next", live_.finished() ? (recorded ? "Zum Schreibtisch" : "Zur Auswertung") : "Nächste Meldung", "", "id=\"" + std::string(live_.finished() ? "live-review" : "live-next") + "\"") + "</footer>";
|
||||
return out + live_dialog_markup(owner) + "</section>";
|
||||
}
|
||||
void App::live_after_render() {
|
||||
@@ -239,7 +247,7 @@ void App::live_update_parts() {
|
||||
auto *list = element("live-ticker"); auto *count = element("live-event-count");
|
||||
if (!list || !count) { refresh(); return; }
|
||||
size_t shown = 0; list->SetInnerRML(live_ticker_events(frame, shown));
|
||||
count->SetInnerRML(esc(std::to_string(shown) + " Meldungen · feste Aufzeichnung"));
|
||||
count->SetInnerRML(esc(std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? " Meldungen" : " Meldungen · feste Aufzeichnung")));
|
||||
list->SetScrollTop(0); live_ticker_scroll_ = 0; live_reset_ticker_ = false;
|
||||
Rml::ElementList filters; doc_->QuerySelectorAll(filters, ".live-filters button");
|
||||
for (auto *filter : filters)
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
Json live_owner_rows(const Json &) const;
|
||||
Json live_owner_state(const Json &) const;
|
||||
bool live_open();
|
||||
// Engine career: shows the recording of the kickoff that was just played.
|
||||
bool engine_live_open(const Json &recording);
|
||||
std::string live_return_scene_;
|
||||
Json engine_advance_payload_ = Json::object();
|
||||
std::string engine_expiry_player_;
|
||||
void engine_kickoff();
|
||||
void engine_expiry_ask(const Json &args);
|
||||
void live_close();
|
||||
bool live_action(const std::string &, Rml::Element *);
|
||||
bool live_event(Rml::Event &);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "modern/ui/controls.hpp"
|
||||
#include "modern/ui/crest_contrast.hpp"
|
||||
#include "modern/ui/engine_bridge.hpp"
|
||||
#include "modern/ui/engine_live.hpp"
|
||||
#include "modern/ui/news_catalog.hpp"
|
||||
#include "modern/ui/career_files.hpp"
|
||||
#include "modern/ui/live_match_info.hpp"
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Developer probe: advances a Modern career through the UI command path and writes the
|
||||
// engine's kickoff recording, post-match read and line-up read as JSON files.
|
||||
// usage: modern_live_dump <world.obw> <career.obs> <output dir> [kickoffs]
|
||||
#include "modern/ui/engine_bridge.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
using bmh::modern_ui::EngineBridge;
|
||||
using bmh::modern_ui::Json;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 4) { std::cerr << "usage: modern_live_dump <world.obw> <career.obs> <output dir> [kickoffs]\n"; return 2; }
|
||||
try {
|
||||
const fs::path out = argv[3];
|
||||
fs::create_directories(out);
|
||||
const int wanted = argc > 4 ? std::atoi(argv[4]) : 1;
|
||||
auto link = EngineBridge::open(argv[1], argv[2]);
|
||||
const auto write = [&](const std::string &name, const Json &value) {
|
||||
std::ofstream(out / name, std::ios::binary) << value.dump(1);
|
||||
};
|
||||
int found = 0;
|
||||
Json expiry = Json::object();
|
||||
for (int step = 0; step < 400 && found < wanted; ++step) {
|
||||
const auto bundle = link->snapshot();
|
||||
const auto &meta = bundle.at("desktop").at("meta");
|
||||
if (step == 0) write("bundle.json", bundle);
|
||||
const Json command = {{"messageType", "command"}, {"contractVersion", meta.at("contractVersion")},
|
||||
{"requestId", "request:dump-" + std::to_string(step)}, {"careerId", meta.at("careerId")},
|
||||
{"expectedRevision", meta.at("stateRevision")},
|
||||
{"owner", {{"managerId", meta.at("scope").at("managerId")}}},
|
||||
{"kind", "session.advance"}, {"payload", {{"contractExpiry", expiry}}}};
|
||||
const auto reply = link->command(command);
|
||||
write("advance-" + std::to_string(step) + ".json", reply);
|
||||
if (reply.value("messageType", "") != "command_result") {
|
||||
if (reply.value("code", "") == "decision_pending") {
|
||||
expiry[reply.at("message").at("args").at("playerId").get<std::string>()] = {{"action", "release"}};
|
||||
continue;
|
||||
}
|
||||
std::cerr << "advance refused: " << reply.dump() << "\n";
|
||||
return 1;
|
||||
}
|
||||
const auto fixture = link->read_live({{"kind", "fixture"}});
|
||||
std::cout << "step " << step << ": " << (fixture.value("ok", false) ? "fixture" : fixture.value("error", "?")) << "\n";
|
||||
if (!fixture.value("ok", false)) continue;
|
||||
const std::string tag = std::to_string(found++);
|
||||
write("fixture-" + tag + ".json", fixture);
|
||||
write("postmatch-" + tag + ".json", link->read({{"kind", "postmatch"}}));
|
||||
write("lineup-" + tag + ".json", link->read({{"kind", "lineup"}}));
|
||||
write("tactics-" + tag + ".json", link->read({{"kind", "tactics"}}));
|
||||
}
|
||||
std::cout << found << " recordings written\n";
|
||||
return found ? 0 : 1;
|
||||
} catch (const std::exception &e) { std::cerr << e.what() << "\n"; return 1; }
|
||||
}
|
||||
Reference in new issue
Block a user