- Match engine (Modern turn driver only, MatchEngine::tactic_effects): wing play, through balls, goal kicks, flat or high balls, offside trap and pressing of a human side shift how often it and its opponent come to a chance (play_shift, at most two steps of the chance roll). Each setting pays in one situation and costs in another; pressing also raises the foul roll. No random numbers are drawn; computer sides and the Classic core are unchanged. Documented in docs/DIFFERENCES.md. - The tactics read names the settings; desk and live dialog show every value in words with one sentence on its effect. The live dialog offers all eight settings again. - The tactics board is a slate with a wooden frame, drawn in wobbling chalk strokes. - modern_season_sim: SIM_TACTICS keeps a tactic set for measuring; new modern_play_shift_tests pin the direction of every setting. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
320 lines
31 KiB
C++
320 lines
31 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
||
namespace {
|
||
std::string live_text(const std::string &value, const std::string &css = {}) {
|
||
return "<span" + (css.empty() ? std::string() : " class=\"" + css + "\"") + ">" + esc(value) + "</span>";
|
||
}
|
||
std::string live_score_text(const Json &score) {
|
||
return std::to_string(score[0].get<int>()) + " : " + std::to_string(score[1].get<int>());
|
||
}
|
||
// A value of the engine's tactics board in words: the attitude (item 0, lowest = most
|
||
// defensive), the commitment (item 7) and the numbered variants of the play patterns.
|
||
std::string live_tactic_value(size_t index, int value, int maximum) { return tactic_value_text(index, value, maximum); }
|
||
const Json &live_match_by_id(const Json &rows, const Json &id) {
|
||
|
||
for (const auto &row : rows) if (row.at("id") == id) return row;
|
||
throw editor::Error("live_match_unavailable");
|
||
}
|
||
const Json &live_score_by_id(const Json &frame, const Json &id) {
|
||
for (const auto &row : frame.at("matches")) if (row.at("match_id") == id) return row;
|
||
throw editor::Error("live_score_unavailable");
|
||
}
|
||
} // namespace
|
||
|
||
Json App::live_owner() const {
|
||
for (const auto &owner : live_.fixture().at("owners")) if (owner.at("id") == live_.owner()) return owner;
|
||
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"));
|
||
if (!projection.value("ok", false)) return Json::array();
|
||
auto rows = projection.at("rows");
|
||
for (auto &row : rows) {
|
||
row["caps"] = nullptr; row["international_goals"] = nullptr;
|
||
for (const auto &base : owner.at("view").at("rows")) if (base.at("id") == row.at("id")) {
|
||
row["caps"] = base.at("caps"); row["international_goals"] = base.at("international_goals");
|
||
}
|
||
}
|
||
return rows;
|
||
}
|
||
std::string App::live_badge(const Json &team, double size) {
|
||
std::string art;
|
||
if (team.value("role", "club") == "national") {
|
||
auto nation = team.value("nation", team.value("id", "") == "national-de" ? "nation:de" : "");
|
||
if (nation.starts_with("nation:")) nation = nation.substr(7);
|
||
const auto flag = ui_nation_flag_svg(nation);
|
||
if (!flag.empty()) art = picture(renderer_.diagram("live-flag-" + nation, flag, int(size * 2)), size, size * .7);
|
||
} else if (live_world_) {
|
||
if (const auto *club = live_world_->find("clubs", team.value("id", "")); club && !club->value("crest", "").empty()) art = crest(club, size);
|
||
}
|
||
if (art.empty()) art = glyph(team.value("role", "club") == "national" ? "world" : "shirt", size);
|
||
return "<div class=\"live-badge\" style=\"width:" + scalar(size) + "dp;height:" + scalar(size) + "dp;\">" + art + "</div>";
|
||
}
|
||
std::string App::live_roster(const Json &owner) {
|
||
const bool national = live_.fixture().at("role") == "national";
|
||
const int field_count = live_.fixture().at("field_count");
|
||
std::string out = "<div class=\"live-roster\"><div class=\"live-roster-row heading\">" +
|
||
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);
|
||
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" : 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>()) + "\">" +
|
||
live_text(std::to_string(i + 1), "live-roster-number") + live_text(row.at("name"), "live-roster-name") +
|
||
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(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) {
|
||
const auto &fixture = live_.fixture();
|
||
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(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")) {
|
||
const bool own = row.at("team").at("id") == owner.at("team").at("id");
|
||
const int difference = row.at("gf").get<int>() - row.at("ga").get<int>();
|
||
out += "<div class=\"live-table-row " + std::string(own ? "own" : "") + "\" data-live-table-team=\"" + esc(row.at("team").at("id").get<std::string>()) + "\"" + (own ? " aria-current=\"true\"" : "") + ">" +
|
||
live_text(std::to_string(row.at("position").get<int>()), "live-table-pos") +
|
||
"<div class=\"live-table-team\">" + live_badge(row.at("team"), 48) + live_text(row.at("team").at("name")) + "</div>" +
|
||
live_text(std::to_string(row.at("played").get<int>()), "live-table-number") +
|
||
live_text(std::to_string(row.at("gf").get<int>()) + ":" + std::to_string(row.at("ga").get<int>()), "live-table-number live-table-goals") +
|
||
live_text((difference > 0 ? "+" : "") + std::to_string(difference), "live-table-number") +
|
||
live_text(std::to_string(row.at("points").get<int>()), "live-table-number") + "</div>";
|
||
}
|
||
return out + "</div>";
|
||
}
|
||
if (live_tab_ == "tactics" && live_.running() && engine_live_tactics_.size() == 8) {
|
||
std::string out = "<div class=\"live-context\"><h3>" + live_text("Taktik in diesem Spiel") + "</h3>";
|
||
for (size_t i = 0; i < engine_live_tactics_.size(); ++i)
|
||
out += "<div class=\"live-tactic-row\">" + live_text(engine_live_tactics_[i].at("label").get<std::string>()) +
|
||
live_text(i == 0 && engine_live_assistant_ ? std::string("Assistent passt an") : live_tactic_value(i, engine_live_tactics_[i].at("value").get<int>(), engine_live_tactics_[i].at("max").get<int>())) + "</div>";
|
||
return out + btn("live-intervene-tactics", "Taktik ändern", "", "id=\"live-tactics-edit\"") + "</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");
|
||
for (int i = 0; i < count; ++i) points.push_back(board.at("points")[size_t(i)]);
|
||
return "<div class=\"live-context\"><h3>" + live_text("Aktuelle Demoaufstellung") + "</h3><p>" + live_text(std::to_string(count) + " Spieler auf dem Feld · unabhängige Manageransicht") + "</p><div class=\"live-pitch\">" +
|
||
picture(renderer_.diagram("live-formation", lineup_mini(points, theme_), 1200), 1140, 684) + "</div>" +
|
||
btn("live-intervene-tactics", "Taktik als Demo bearbeiten", "", "id=\"live-tactics-edit\" " + std::string(live_.finished() ? "disabled" : "")) +
|
||
"<p>" + live_text("Die Vorschau verändert weder diese feste Ereignisfolge noch Spiel- oder Saisonwerte.") + "</p></div>";
|
||
}
|
||
if (live_tab_ == "opponent" && recorded) {
|
||
// the other matches of the day, own competition first; known once the day is played
|
||
if (!live_.finished() || !fixture.contains("conference") || !fixture.at("conference").is_array() || fixture.at("conference").empty())
|
||
return "<p class=\"live-note\">" + live_text(live_.finished() ? "An diesem Tag gab es keine weiteren Spiele." : "Die Ergebnisse der anderen Spiele stehen nach dem Abpfiff hier.") + "</p>";
|
||
const std::string own = match.value("competition", std::string());
|
||
std::vector<std::string> order;
|
||
std::map<std::string, std::string> groups;
|
||
for (const auto &other : fixture.at("conference")) {
|
||
const std::string name = other.at("competition").value("name", std::string("Weitere Spiele"));
|
||
if (!groups.contains(name)) order.push_back(name);
|
||
const auto &result = other.at("result").at("final");
|
||
groups[name] += "<div class=\"live-roster-row\">" +
|
||
live_text(other.at("home").value("name", std::string()) + " – " + other.at("away").value("name", std::string()), "live-roster-name") +
|
||
live_text(std::to_string(result[0].get<int>()) + ":" + std::to_string(result[1].get<int>()), "live-roster-stat") + "</div>";
|
||
}
|
||
std::stable_sort(order.begin(), order.end(), [&](const std::string &a, const std::string &b) { return (a == own) > (b == own); });
|
||
std::string list = "<div class=\"live-roster\">";
|
||
for (const auto &name : order)
|
||
list += "<div class=\"live-roster-row heading\">" + live_text(name, "live-roster-name") + live_text("", "live-roster-stat") + "</div>" + groups.at(name);
|
||
return list + "</div>";
|
||
}
|
||
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(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) {
|
||
const auto &pair = score.at(key); const int a = pair[0], b = pair[1];
|
||
const double percent = a + b ? 100.0 * a / (a + b) : 50;
|
||
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>() + (recorded ? "" : " · vorgegebene Demowerte")) + "</p>";
|
||
}
|
||
std::string App::live_dialog_markup(const Json &owner) {
|
||
if (live_dialog_.empty()) return "";
|
||
const auto rows = live_owner_rows(owner);
|
||
std::string body = "<h2 id=\"live-dialog-heading\">" + live_text(live_.running() ? (live_dialog_ == "lineup" ? "Aufstellung & Wechsel" : "Taktik") : live_dialog_ == "lineup" ? "Aufstellung & Wechsel · Demo" : "Taktik · Demo") + "</h2><p>" + live_text(live_.running() ? owner.at("team").at("name").get<std::string>() + " · Das Spiel steht, bis du entschieden hast." : "Nur lokale Vorschau für " + owner.at("name").get<std::string>() + " · " + owner.at("team").at("name").get<std::string>() + ". Keine Änderung an der Partie; der feste Spielverlauf bleibt unverändert.") + "</p>";
|
||
if (live_dialog_ == "lineup") {
|
||
std::vector<std::pair<std::string, std::string>> active, bench;
|
||
for (size_t i = 0; i < rows.size(); ++i) (i < size_t(live_.fixture().at("field_count").get<int>()) ? active : bench).emplace_back(rows[i].at("id"), rows[i].at("name"));
|
||
body += "<label for=\"live-player-out\">" + live_text("Vom Feld") + select("live-player-out", active, live_out_) + "</label><label for=\"live-player-in\">" + live_text("Von der Ersatzbank") + select("live-player-in", bench, live_in_) + "</label>";
|
||
if (active.empty() || bench.empty()) body += "<p>" + live_text(live_.running() ? "Kein Wechselpaar verfügbar." : "Für diese Demokaderbasis ist kein Wechselpaar verfügbar.") + "</p>";
|
||
} else {
|
||
const std::array<const char *, 8> names{"Defensiv / offensiv", "Pass-/Schussbild unten", "Pass-/Schussbild Mitte", "Pass-/Schussbild links", "Flache / hohe Bälle", "Flügelbild links", "Flügelbild rechts", "Einsatz"};
|
||
const bool engine_board = live_.running() && engine_live_tactics_.size() == 8;
|
||
const auto &values = engine_board ? live_dialog_draft_.at("values") : live_dialog_draft_.at("tactics").at("values");
|
||
for (size_t i = 0; i < names.size(); ++i)
|
||
body += "<div class=\"live-tactic-row\">" + live_text(engine_board ? engine_live_tactics_[i].at("label").get<std::string>() : std::string(names[i])) + btn("live-tactic-cycle", engine_board ? live_tactic_value(i, values[i].get<int>(), engine_live_tactics_[i].at("max").get<int>()) : "Wert " + std::to_string(values[i].get<int>()), "", "id=\"live-tactic-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\"") + "</div>";
|
||
}
|
||
if (live_dialog_ == "tactics" && live_.running() && engine_live_tactics_.size() == 8)
|
||
body += "<p id=\"live-tactic-effect\">" + live_text(tactic_effect_text(size_t(std::clamp(last_tactic_, 0, 7)))) + "</p>";
|
||
body += "<div class=\"live-dialog-actions\">" + btn("live-dialog-cancel", "Abbrechen", "", "id=\"live-dialog-cancel\"") +
|
||
btn("live-dialog-apply", live_.running() ? (live_dialog_ == "lineup" ? "Wechsel ausführen" : "Taktik übernehmen") : "Demovorschau anzeigen", "", "id=\"live-dialog-apply\" " + std::string(live_dialog_ == "lineup" && (live_out_.empty() || live_in_.empty()) ? "disabled" : "")) + "</div>";
|
||
return "<div class=\"live-dialog-layer\"><div id=\"live-dialog\" class=\"live-dialog\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"live-dialog-heading\">" + body + "</div></div>";
|
||
}
|
||
std::string App::live_ticker_events(const Json &frame, size_t &shown) {
|
||
const auto &fixture = live_.fixture();
|
||
shown = 0;
|
||
std::string out;
|
||
for (auto i = frame.at("events").rbegin(); i != frame.at("events").rend(); ++i) {
|
||
const auto &event = *i; const auto kind = event.value("kind", "");
|
||
if (live_coverage_ == "single" && event.at("match_id") != live_selected_match_) continue;
|
||
if (live_filter_ == "goal" && kind != "goal") continue;
|
||
if (live_filter_ == "yellow" && kind != "yellow" && kind != "red" && kind != "second_yellow") continue;
|
||
if (live_filter_ == "highlights" && kind != "goal" && kind != "chance" && kind != "miss" && kind != "red" && kind != "second_yellow") continue;
|
||
const auto &match = live_match_by_id(fixture.at("matches"), event.at("match_id"));
|
||
out += "<article class=\"live-event " + std::string(kind == "goal" ? "is-goal" : "") + "\" data-live-event=\"" + esc(event.at("id").get<std::string>()) + "\">" + live_text(std::to_string(event.at("minute").get<int>()) + "′", "live-event-time") + (kind == "kickoff" || kind == "interval" || kind == "fulltime" ? "<div class=\"live-badge\" style=\"width:54dp;height:54dp;\"></div>" : live_badge(match.at(event.at("side").get<std::string>()), 54)) +
|
||
"<div class=\"live-event-copy\">" + (fixture.at("source") == "engine-recording" && fixture.at("matches").size() == 1 ? std::string() : 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 && fixture.at("source") == "engine-recording" && live_filter_ == "all" && frame.at("events").empty()) {
|
||
// before the first report: who starts
|
||
for (const auto &match : fixture.at("matches")) {
|
||
if (live_coverage_ == "single" && match.at("id") != live_selected_match_) continue;
|
||
if (!match.contains("lineups") || !match.at("lineups").is_object()) continue;
|
||
std::string columns;
|
||
for (const auto *side : {"home", "away"}) {
|
||
const auto names = match.at("lineups").value(side, Json());
|
||
columns += "<div class=\"live-lineup-side\"><h3>" + live_text(match.at(side).at("name")) + "</h3>";
|
||
if (names.is_array() && !names.empty()) {
|
||
size_t number = 0;
|
||
for (const auto &name : names) columns += "<div class=\"live-lineup-row\">" + live_text(std::to_string(++number), "live-roster-number") + live_text(name.get<std::string>(), "live-roster-name") + "</div>";
|
||
} else columns += "<p>" + live_text("Aufstellung nicht bekannt.") + "</p>";
|
||
columns += "</div>";
|
||
}
|
||
out += "<div class=\"live-lineups\">" + columns + "</div>";
|
||
}
|
||
if (!out.empty()) return out;
|
||
}
|
||
if (!shown) out += "<p class=\"live-note\">" + live_text(fixture.at("source") == "engine-recording" ? "Noch keine Meldungen." : "Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
|
||
return out;
|
||
}
|
||
std::string App::render_live() {
|
||
if(live_review_) return render_postmatch();
|
||
if (!live_.available()) return "";
|
||
if (auto *node = element("live-ticker")) live_ticker_scroll_ = live_reset_ticker_ ? 0 : node->GetScrollTop();
|
||
if (auto *node = element("live-detail-body")) live_detail_scroll_ = live_reset_detail_ ? 0 : node->GetScrollTop();
|
||
live_reset_detail_ = live_reset_ticker_ = false;
|
||
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 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=\"" + std::string(recorded ? "engine-recording" : "ui-demo-fixture") + "\" data-fixture-id=\"" + esc(fixture.at("fixture_id").get<std::string>()) + "\"><header class=\"live-header\"><div>" + (recorded ? std::string() : 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 ? ui_long_date(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>";
|
||
};
|
||
out += "<div id=\"live-underlay\" class=\"live-body\"><div class=\"live-left\"><section class=\"live-panel live-overview\"><nav class=\"live-coverage" + std::string(recorded && fixture.at("matches").size() == 1 ? " solo" : "") + "\">";
|
||
if (!(recorded && fixture.at("matches").size() == 1))
|
||
for (const auto &[id, text] : std::array<std::pair<const char *, const char *>, 3>{{{"all", "Alle Spiele"}, {"single", "Einzelspiel"}, {"conference", "Konferenz"}}})
|
||
out += btn("live-coverage", text, live_coverage_ == id ? "selected" : "", "id=\"live-coverage-" + std::string(id) + "\" data-id=\"" + id + "\"");
|
||
if (live_coverage_ == "single" && fixture.at("matches").size() > 1) out += btn("live-match-prev", arrow(false), "live-match-arrow", "id=\"live-match-prev\" aria-label=\"Vorherige Tickerpartie\"") + btn("live-match-next", arrow(true), "live-match-arrow", "id=\"live-match-next\" aria-label=\"Nächste Tickerpartie\"");
|
||
if (!(recorded && fixture.at("matches").size() == 1)) out += live_text(std::to_string(minute) + ":00", "live-clock");
|
||
out += "</nav><div class=\"live-cards " + std::string(fixture.at("matches").size() == 1 || live_coverage_ == "single" ? "single" : "") + "\">";
|
||
for (const auto &match : fixture.at("matches")) {
|
||
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>()) + "\">" + (recorded && fixture.at("owners").size() == 1 ? std::string() : live_text(names, "live-owners")) + scoreline(match) + live_text(recorded && fixture.at("matches").size() == 1 ? std::string(phase_text) + (live_.finished() || minute < 1 ? "" : " · " + std::to_string(minute) + ". Minute") : 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(recorded ? "Ticker" : "Gemeinsamer Live-Ticker") + "</h2>" + (recorded && fixture.at("owners").size() == 1 ? std::string() : 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(recorded && !shown ? std::string() : std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? (shown == 1 ? " Meldung" : " Meldungen") : " Meldungen · feste Aufzeichnung")) + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(recorded ? std::string() : std::string(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", recorded ? "Ergebnisse" : "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() || (recorded && !live_.running()) ? "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", live_.running() ? "Zu Ende spielen" : 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() ? (recorded ? std::string() : 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" : live_.running() ? "Nächste Minute" : "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() {
|
||
if(live_review_){postmatch_after_render();return;}
|
||
if (scene_ != "live" || !live_restore_scroll_) return;
|
||
live_restore_scroll_ = false;
|
||
if (auto *node = element("live-ticker")) node->SetScrollTop(live_ticker_scroll_);
|
||
if (auto *node = element("live-detail-body")) node->SetScrollTop(live_detail_scroll_);
|
||
if (!live_dialog_.empty()) {
|
||
Rml::ElementList controls; doc_->QuerySelectorAll(controls, "#live-underlay button,#live-speed,.live-bottom button");
|
||
for (auto *node : controls) { node->SetProperty("pointer-events", "none"); node->SetAttribute("tabindex", "-1"); }
|
||
}
|
||
}
|
||
|
||
// Apply local navigation only after event dispatch. The untouched match cards,
|
||
// ticker and speed input retain their DOM identity, focus and pointer capture.
|
||
void App::live_update_parts() {
|
||
if (!live_detail_pending_ && !live_ticker_pending_ && focus_after_render_.empty()) return;
|
||
if (scene_ != "live" || live_review_ || !live_.available() ||
|
||
!live_dialog_.empty() || !popup_.empty()) {
|
||
live_detail_pending_ = live_ticker_pending_ = false;
|
||
return;
|
||
}
|
||
const auto frame = live_.frame();
|
||
if (live_detail_pending_) {
|
||
const auto owner = live_owner();
|
||
auto *body = element("live-detail-body");
|
||
auto *team = element("live-owner-team");
|
||
auto *name = element("live-owner-name");
|
||
if (!body || !team || !name) { refresh(); return; }
|
||
team->SetInnerRML(esc(owner.at("team").at("name").get<std::string>()));
|
||
name->SetInnerRML(esc(owner.at("name").get<std::string>()));
|
||
body->SetInnerRML(live_detail(owner, frame));
|
||
body->SetScrollTop(0); live_detail_scroll_ = 0; live_reset_detail_ = false;
|
||
Rml::ElementList tabs; doc_->QuerySelectorAll(tabs, "#live-detail .live-tabs button");
|
||
for (auto *tab : tabs) {
|
||
const bool selected = tab->GetAttribute<Rml::String>("data-id", "") == live_tab_;
|
||
tab->SetClass("selected", selected); tab->SetAttribute("aria-pressed", selected ? "true" : "false");
|
||
}
|
||
++live_detail_updates_;
|
||
}
|
||
if (live_ticker_pending_) {
|
||
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) + (live_.fixture().at("source") == "engine-recording" ? (shown == 1 ? " Meldung" : " 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)
|
||
filter->SetClass("selected", filter->GetAttribute<Rml::String>("data-id", "") == live_filter_);
|
||
++live_ticker_updates_;
|
||
}
|
||
live_detail_pending_ = live_ticker_pending_ = false;
|
||
if (!focus_after_render_.empty()) {
|
||
if (auto *node = element(focus_after_render_)) node->Focus(keyboard_navigation_);
|
||
focus_after_render_.clear();
|
||
}
|
||
dirty_ = true;
|
||
}
|