The report draws the match sheet's event pictures instead of pale outlines, the league pickers take the sheet's colours, and notices no longer talk about recordings. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
497 lines
25 KiB
C++
497 lines
25 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
||
namespace {
|
||
std::string postmatch_label(const std::string &tab) {
|
||
if (tab == "results")
|
||
return "Ergebnisse";
|
||
if (tab == "report")
|
||
return "Spielbericht";
|
||
if (tab == "eleven")
|
||
return "Elf des Tages";
|
||
if (tab == "overview")
|
||
return "Übersicht";
|
||
return "Tabelle";
|
||
}
|
||
std::string postmatch_count(const Json &v) {
|
||
return v.is_number_integer() ? number(v.get<int64_t>()) : "—";
|
||
}
|
||
std::string postmatch_kind(const std::string &kind) {
|
||
if (kind == "goal")
|
||
return "Tor";
|
||
if (kind == "yellow")
|
||
return "Gelbe Karte";
|
||
if (kind == "red")
|
||
return "Rote Karte";
|
||
if (kind == "injury")
|
||
return "Behandlung";
|
||
if (kind == "attack")
|
||
return "Angriff";
|
||
if (kind == "chance" || kind == "save")
|
||
return "Torchance";
|
||
if (kind == "kickoff")
|
||
return "Anpfiff";
|
||
if (kind == "interval")
|
||
return "Halbzeit";
|
||
if (kind == "restart")
|
||
return "Wiederanpfiff";
|
||
if (kind == "fulltime")
|
||
return "Abpfiff";
|
||
return "Ereignis";
|
||
}
|
||
} // namespace
|
||
std::string App::postmatch_icon(const std::string &kind, double size) {
|
||
// the report uses the pictures of the match sheet, so they read on every skin
|
||
const bool whistle = kind == "kickoff" || kind == "interval" || kind == "fulltime" || kind == "restart";
|
||
return live_icon(whistle ? "time" : kind, size);
|
||
}
|
||
// The pictures of the day's totals: drawn large and filled, in the sheet's colours.
|
||
std::string App::postmatch_art(const std::string &kind, double size) {
|
||
const bool dark = theme_ != "silver" && theme_ != "matchday";
|
||
const std::string ink = dark ? "#f0ece2" : "#2a211a", paper = dark ? "#2a2d34" : "#fffdf6";
|
||
const auto card = [&](const char *fill, const char *turn) {
|
||
return std::string("<g transform='rotate(") + turn + " 50 50)'><rect x='33' y='20' width='44' height='64' rx='6' fill='#000000' fill-opacity='.16'/><rect x='28' y='14' width='44' height='64' rx='6' fill='" + fill +
|
||
"' stroke='" + ink + "' stroke-width='3'/><path d='M37 25h18' stroke='#ffffff' stroke-opacity='.55' stroke-width='5' stroke-linecap='round'/></g>";
|
||
};
|
||
std::string g;
|
||
if (kind == "yellow") g = card("#e9c53a", "-12");
|
||
else if (kind == "red") g = card("#c8372d", "12");
|
||
else if (kind == "crowd") {
|
||
const auto person = [&](double x, double y, double k, const char *fill) {
|
||
return "<g transform='translate(" + scalar(x) + " " + scalar(y) + ") scale(" + scalar(k) + ")'><path d='M-24 40c0-18 10-28 24-28s24 10 24 28z' fill='" + std::string(fill) + "' stroke='" + paper +
|
||
"' stroke-width='3'/><circle cx='0' cy='-6' r='13' fill='" + fill + "' stroke='" + paper + "' stroke-width='3'/></g>";
|
||
};
|
||
g = person(26, 46, .8, "#7a8a5e") + person(74, 46, .8, "#7a8a5e") + person(50, 52, 1.05, "#c67139");
|
||
} else {
|
||
g = "<g stroke='" + ink + "' stroke-opacity='.3' stroke-width='1.6'><path d='M27 26v50M42 26v50M57 26v50M72 26v50M12 39h76M12 52h76M12 65h76'/></g><path d='M12 80V26h76v54' fill='none' stroke='" + ink +
|
||
"' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'/><circle cx='58' cy='63' r='16' fill='" + paper + "' stroke='" + ink + "' stroke-width='3'/><path d='M58 53.5l8.5 6.2-3.200 10h-10.600l-3.200-10z' fill='" + ink + "'/>";
|
||
}
|
||
return picture(renderer_.diagram("postmatch-art-" + kind + (dark ? "-d" : "-l"), "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>" + g + "</svg>", int(size * 2)), size, size);
|
||
}
|
||
std::string App::postmatch_team(const Json &team, bool home, double size) {
|
||
const auto name = live_text(team.value("name", "—"), "postmatch-team-name");
|
||
const auto badge = live_badge(team, size);
|
||
return "<span class=\"postmatch-team " + std::string(home ? "home" : "away") +
|
||
"\">" + (home ? name + badge : badge + name) + "</span>";
|
||
}
|
||
Json App::postmatch_groups() const {
|
||
Json groups = Json::array();
|
||
if (!postmatch_data_.value("ok", false))
|
||
return groups;
|
||
for (const auto &m : postmatch_data_.at("matches")) {
|
||
const auto *club = live_world_
|
||
? live_world_->find("clubs", m.at("home").at("id"))
|
||
: nullptr;
|
||
const std::string league = club ? club->value("competition", "") : "";
|
||
const auto *competition =
|
||
live_world_ ? live_world_->find("competitions", league) : nullptr;
|
||
const std::string country =
|
||
competition ? competition->value("nation", "") : "";
|
||
const auto *nation =
|
||
live_world_ ? live_world_->find("nations", country) : nullptr;
|
||
const std::string key = league.empty() ? "recording" : league;
|
||
auto group = std::find_if(groups.begin(), groups.end(),
|
||
[&](const auto &g) { return g.at("id") == key; });
|
||
if (group == groups.end()) {
|
||
groups.push_back(
|
||
{{"id", key},
|
||
{"name", competition ? live_world_->name(*competition)
|
||
: m.at("competition").get<std::string>()},
|
||
{"country", country.empty() ? "recording" : country},
|
||
{"country_name",
|
||
nation ? live_world_->name(*nation) : "Aufzeichnung"},
|
||
{"match_ids", Json::array()}});
|
||
group = groups.end() - 1;
|
||
}
|
||
(*group)["match_ids"].push_back(m.at("id"));
|
||
}
|
||
return groups;
|
||
}
|
||
Json App::postmatch_matches() const {
|
||
if (postmatch_data_.at("role") != "club" ||
|
||
postmatch_data_.at("surface") != "outdoor")
|
||
return postmatch_data_.at("matches");
|
||
const auto groups = postmatch_groups();
|
||
Json rows = Json::array();
|
||
for (const auto &group : groups)
|
||
if (group.at("id") == postmatch_league_)
|
||
for (const auto &m : postmatch_data_.at("matches"))
|
||
if (std::find(group.at("match_ids").begin(),
|
||
group.at("match_ids").end(),
|
||
m.at("id")) != group.at("match_ids").end())
|
||
rows.push_back(m);
|
||
return rows;
|
||
}
|
||
Json App::postmatch_report() const {
|
||
if (!live_.available() || !postmatch_data_.value("ok", false))
|
||
return Json();
|
||
return query_demo_post_match(
|
||
live_.fixture(),
|
||
{{"kind", "report"},
|
||
{"completed_sequence", postmatch_data_.at("completed_sequence")},
|
||
{"fixture_id", postmatch_data_.at("fixture_id")},
|
||
{"revision", postmatch_data_.at("source_revision")},
|
||
{"match_id", postmatch_match_},
|
||
{"minute", postmatch_minute_}});
|
||
}
|
||
std::string App::postmatch_events(const Json &report, const std::string &side) {
|
||
std::string out =
|
||
"<ol class=\"postmatch-event-column\" aria-label=\"Ereignisse " +
|
||
esc(report.at(side).at("name").get<std::string>()) + "\">";
|
||
size_t index = 0, shown = 0;
|
||
for (const auto &e : report.at("timeline")) {
|
||
const auto n = index++;
|
||
if (e.at("side") != side || e.at("sequence") > report.at("sequence"))
|
||
continue;
|
||
out += "<li>" +
|
||
btn("postmatch-event",
|
||
live_text(std::to_string(e.at("minute").get<int>()) + "′",
|
||
"postmatch-event-time") +
|
||
postmatch_icon(e.at("kind"), 42) +
|
||
"<span class=\"postmatch-event-copy\"><strong>" +
|
||
live_text(e.at("headline")) + "</strong><span>" +
|
||
esc(e.at("body").get<std::string>()) + "</span></span>",
|
||
"postmatch-event",
|
||
"id=\"postmatch-event-" + std::to_string(n) + "\" data-id=\"" +
|
||
esc(e.at("id").get<std::string>()) + "\"") +
|
||
"</li>";
|
||
++shown;
|
||
}
|
||
if (!shown)
|
||
out += "<li class=\"postmatch-no-events\">" +
|
||
live_text("Noch keine Ereignisse") + "</li>";
|
||
return out + "</ol>";
|
||
}
|
||
std::string App::postmatch_report_markup(const Json &report) {
|
||
const auto score = report.at("score");
|
||
std::string out = "<section class=\"postmatch-report\"><header "
|
||
"class=\"postmatch-report-teams\"><div>" +
|
||
live_badge(report.at("home"), 120) + "<strong>" +
|
||
live_text(report.at("home").at("name")) +
|
||
"</strong></div><div id=\"postmatch-score\" "
|
||
"class=\"postmatch-report-score\">" +
|
||
live_text(std::to_string(score[0].get<int>())) +
|
||
live_text(":", "separator") +
|
||
live_text(std::to_string(score[1].get<int>())) +
|
||
"</div><div>" + live_badge(report.at("away"), 120) +
|
||
"<strong>" + live_text(report.at("away").at("name")) +
|
||
"</strong></div></header>";
|
||
out += "<p class=\"postmatch-report-meta\">" +
|
||
live_text(live_match_info_text(report, postmatch_data_.at("surface") == "indoor")) +
|
||
"</p><div id=\"postmatch-events\" class=\"postmatch-event-columns\">" +
|
||
postmatch_events(report, "home") + postmatch_events(report, "away") +
|
||
"</div><section class=\"postmatch-timeline\"><div "
|
||
"class=\"postmatch-timeline-teams\">" +
|
||
live_text(report.at("home").at("name")) +
|
||
live_text(report.at("away").at("name")) +
|
||
"</div><div class=\"postmatch-timeline-tracks\">";
|
||
for (const auto *side : {"home", "away"}) {
|
||
out += "<div class=\"postmatch-track\" aria-label=\"Zeitleiste " +
|
||
esc(report.at(side).at("name").get<std::string>()) + "\">";
|
||
size_t index = 0;
|
||
for (const auto &e : report.at("timeline")) {
|
||
const auto n = index++;
|
||
if (e.at("side") != side)
|
||
continue;
|
||
const auto minute = e.at("minute").get<int>();
|
||
out +=
|
||
btn("postmatch-event", postmatch_icon(e.at("kind"), 34),
|
||
"postmatch-marker " +
|
||
std::string(e.at("sequence") <= report.at("sequence")
|
||
? "is-visible"
|
||
: ""),
|
||
"id=\"postmatch-marker-" + std::to_string(n) + "\" data-id=\"" +
|
||
esc(e.at("id").get<std::string>()) + "\" style=\"left:" +
|
||
scalar(100.0 * minute /
|
||
postmatch_data_.at("duration").get<int>()) +
|
||
"%;\" aria-label=\"" + std::to_string(minute) +
|
||
" Minute: " + esc(postmatch_kind(e.at("kind"))) + "\"");
|
||
}
|
||
out += "</div>";
|
||
}
|
||
out += "<div class=\"postmatch-ticks\">";
|
||
for (int i = 0; i < 7; ++i)
|
||
out +=
|
||
live_text(std::to_string(int(std::lround(
|
||
i * postmatch_data_.at("duration").get<int>() / 6.0))) +
|
||
"′");
|
||
out +=
|
||
"</div></div></section><div class=\"postmatch-seek\">" +
|
||
btn("postmatch-play",
|
||
postmatch_playing_ ? "Pause" : "Rückblick abspielen", {},
|
||
"id=\"postmatch-play\" aria-pressed=\"" +
|
||
std::string(postmatch_playing_ ? "true" : "false") + "\"") +
|
||
"<input id=\"postmatch-minute\" type=\"range\" min=\"0\" max=\"" +
|
||
std::to_string(postmatch_data_.at("duration").get<int>()) +
|
||
"\" step=\"1\" value=\"" + std::to_string(postmatch_minute_) +
|
||
"\" aria-label=\"Berichtsminute\"/><span id=\"postmatch-minute-label\">" +
|
||
std::to_string(postmatch_minute_) +
|
||
"′</span></div><p id=\"postmatch-recorded-note\" "
|
||
"class=\"postmatch-recorded-note\">" +
|
||
live_text("Stand nach " +
|
||
std::to_string(report.at("recorded_minute").get<int>()) +
|
||
"′") +
|
||
"</p>";
|
||
const auto matches = postmatch_matches();
|
||
size_t at = 0;
|
||
for (size_t i = 0; i < matches.size(); ++i)
|
||
if (matches[i].at("id") == postmatch_match_)
|
||
at = i;
|
||
out += "<nav class=\"postmatch-fixture-nav\">" +
|
||
btn("postmatch-fixture-prev", "‹ Voriges Spiel", {},
|
||
"id=\"postmatch-fixture-prev\" " +
|
||
std::string(at == 0 ? "disabled" : "")) +
|
||
live_text(report.at("home").at("name").get<std::string>() + " – " +
|
||
report.at("away").at("name").get<std::string>()) +
|
||
btn("postmatch-fixture-next", "Nächstes Spiel ›", {},
|
||
"id=\"postmatch-fixture-next\" " +
|
||
std::string(at + 1 == matches.size() ? "disabled" : "")) +
|
||
"</nav></section>";
|
||
return out;
|
||
}
|
||
std::string App::render_postmatch() {
|
||
if (!postmatch_data_.value("ok", false))
|
||
return "";
|
||
for (const auto *id : {"postmatch-results", "postmatch-events",
|
||
"postmatch-eleven-list", "postmatch-table"})
|
||
if (auto *node = element(id))
|
||
postmatch_scrolls_[postmatch_rendered_scope_ + "|" + id] =
|
||
node->GetScrollTop();
|
||
postmatch_restore_scroll_ = true;
|
||
const auto &tabs = postmatch_data_.at("tabs");
|
||
const auto matches = postmatch_matches();
|
||
postmatch_rendered_scope_ = postmatch_tab_ + "|" + postmatch_match_;
|
||
const auto selected = live_match_by_id(matches, postmatch_match_);
|
||
std::set<std::string> own;
|
||
for (const auto &owner : postmatch_data_.at("owners"))
|
||
own.insert(owner.at("team").at("id"));
|
||
size_t position = 0;
|
||
for (size_t i = 0; i < tabs.size(); ++i)
|
||
if (tabs[i].get<std::string>() == postmatch_tab_) position = i;
|
||
std::string steps;
|
||
for (size_t i = 0; i < tabs.size(); ++i) {
|
||
const auto tab = tabs[i].get<std::string>();
|
||
steps += btn("postmatch-tab", std::to_string(i + 1) + ". " + postmatch_label(tab),
|
||
tab == postmatch_tab_ ? "selected" : i < position ? "done" : "",
|
||
"id=\"postmatch-tab-" + tab + "\" data-id=\"" + tab + "\" role=\"tab\" aria-selected=\"" +
|
||
std::string(tab == postmatch_tab_ ? "true" : "false") + "\" tabindex=\"" + std::string(tab == postmatch_tab_ ? "0" : "-1") + "\"");
|
||
}
|
||
std::string pickers;
|
||
if (postmatch_data_.at("role") == "club" && postmatch_data_.at("surface") == "outdoor") {
|
||
std::vector<std::pair<std::string, std::string>> countries, leagues;
|
||
for (const auto &g : postmatch_groups()) {
|
||
const auto country = g.at("country").get<std::string>();
|
||
if (std::none_of(countries.begin(), countries.end(), [&](const auto &c) { return c.first == country; }))
|
||
countries.emplace_back(country, g.at("country_name"));
|
||
if (country == postmatch_country_) leagues.emplace_back(g.at("id"), g.at("name"));
|
||
}
|
||
pickers = "<nav class=\"postmatch-pickers\" aria-label=\"Aufgezeichnete Ligagruppe\">" + select("postmatch-country", countries, postmatch_country_) +
|
||
select("postmatch-league", leagues, postmatch_league_) + "</nav>";
|
||
}
|
||
std::string body = "<section id=\"postmatch-underlay\" class=\"postmatch\"><header class=\"postmatch-heading\"><div><span class=\"mv-k\">" +
|
||
esc(pg_upper("Auswertung · Schritt " + std::to_string(position + 1) + " von " + std::to_string(tabs.size()))) +
|
||
"</span><h2 id=\"postmatch-heading\" tabindex=\"-1\">" + live_text(postmatch_label(postmatch_tab_)) +
|
||
"</h2></div><nav class=\"postmatch-tabs\" role=\"tablist\">" + steps + "</nav></header><div class=\"pm-sub\"><span>" +
|
||
esc(selected.at("competition").get<std::string>() + " · " + ui_long_date(postmatch_data_.at("date").get<std::string>())) + "</span>" + pickers + "</div>";
|
||
body += "<div id=\"postmatch-panel\" class=\"postmatch-panel\" "
|
||
"role=\"tabpanel\" aria-labelledby=\"postmatch-tab-" +
|
||
postmatch_tab_ + "\">";
|
||
if (postmatch_tab_ == "results") {
|
||
// the fewer matches, the larger each is shown: one fills the note, a full match day is a list
|
||
const size_t shown = matches.size();
|
||
const std::string scale = shown <= 1 ? "one" : shown == 2 ? "two" : shown <= 4 ? "few" : "many";
|
||
const double badge = shown <= 1 ? 300 : shown == 2 ? 210 : shown <= 4 ? 130 : 68;
|
||
const bool hall = postmatch_data_.at("surface") == "indoor" || live_indoor();
|
||
body += std::string(scale == "many" ? "<div class=\"postmatch-results-head\">" + live_text("Heim", "home") + live_text("Ergebnis", "score") + live_text("Auswärts", "away") + "</div>" : std::string()) +
|
||
"<div id=\"postmatch-results\" class=\"postmatch-results " + scale + "\">";
|
||
for (size_t i = 0; i < matches.size(); ++i) {
|
||
const auto &m = matches[i];
|
||
const bool owned = own.contains(m.at("home").at("id")) ||
|
||
own.contains(m.at("away").at("id"));
|
||
body += btn(
|
||
"postmatch-fixture",
|
||
postmatch_team(m.at("home"), true, badge) +
|
||
"<strong class=\"postmatch-result-score\">" +
|
||
live_text(
|
||
std::to_string(m.at("final").at("score")[0].get<int>())) +
|
||
live_text(":", "separator") +
|
||
live_text(
|
||
std::to_string(m.at("final").at("score")[1].get<int>())) +
|
||
"</strong>" + postmatch_team(m.at("away"), false, badge),
|
||
"postmatch-result-row " + std::string(owned ? "postmatch-own" : ""),
|
||
"id=\"postmatch-result-" + std::to_string(i) + "\" data-id=\"" +
|
||
esc(m.at("id").get<std::string>()) + "\"");
|
||
if (shown <= 2) body += "<p class=\"postmatch-result-info\">" + esc(m.at("competition").get<std::string>() + " · " + live_match_info_text(m, hall)) + "</p>";
|
||
}
|
||
body += "</div><p class=\"postmatch-scope-note\">" +
|
||
live_text(postmatch_data_.at("source") == "engine-recording"
|
||
? "Partien mit eigener Beteiligung · alle Ergebnisse stehen unter Ligaspiele und Übrige Spiele"
|
||
: "Vorgegebene Aufzeichnung der menschlichen Partien · "
|
||
"kein vollständiger Ligaspieltag") +
|
||
"</p>";
|
||
} else if (postmatch_tab_ == "report")
|
||
body += postmatch_report_markup(postmatch_report());
|
||
else if (postmatch_tab_ == "eleven") {
|
||
const auto color = theme_ == "silver" ? "#42627d"
|
||
: theme_ == "matchday" ? "#d2b8be"
|
||
: "#abcbbf";
|
||
const auto pitch = picture(
|
||
renderer_.diagram("postmatch-pitch", postmatch_pitch_svg(color), 1110),
|
||
740, 1110);
|
||
body += postmatch_eleven_markup(
|
||
postmatch_data_.at("eleven"),
|
||
[&](const Json &team, double size) { return live_badge(team, size); },
|
||
pitch);
|
||
} else if (postmatch_tab_ == "overview") {
|
||
auto total = postmatch_data_.at("overview");
|
||
total["games"] = matches.size();
|
||
total["attendance"] = int64_t(0);
|
||
for (const auto &m : matches) {
|
||
if (m.at("attendance").is_null()) { total["attendance"] = nullptr; break; }
|
||
total["attendance"] = total.at("attendance").get<int64_t>() + m.at("attendance").get<int64_t>();
|
||
}
|
||
for (const auto *key : {"goals", "yellow", "red"})
|
||
total[key] = 0;
|
||
for (const auto &m : matches)
|
||
for (const auto *key : {"goals", "yellow", "red"}) {
|
||
const auto &pair =
|
||
m.at("final").at(std::string(key) == "goals" ? "score" : key);
|
||
total[key] =
|
||
total.at(key).get<int>() + pair[0].get<int>() + pair[1].get<int>();
|
||
}
|
||
body += "<section class=\"postmatch-overview\"><div "
|
||
"class=\"postmatch-total-grid\">";
|
||
for (const auto &[key, icon, label] :
|
||
std::array<std::tuple<const char *, const char *, const char *>, 4>{
|
||
{{"yellow", "yellow", "Gelbe Karten"},
|
||
{"red", "red", "Platzverweise"},
|
||
{"attendance", "crowd", "Zuschauer"},
|
||
{"goals", "goal", "Tore"}}})
|
||
body += "<article class=\"postmatch-total\">" + postmatch_art(icon, 310) + "<div class=\"pm-total-copy\"><strong>" + live_text(postmatch_count(total.at(key))) +
|
||
"</strong>" + live_text(label) + "</div></article>";
|
||
const int games = total.at("games");
|
||
body +=
|
||
"</div><p>" +
|
||
live_text(std::to_string(games) + (games == 1 ? " Partie · " : " Partien · ") +
|
||
(games ? scalar(double(total.at("goals").get<int>()) / games)
|
||
: "—") +
|
||
" Tore pro Partie") +
|
||
"</p><p class=\"postmatch-scope-note\">" +
|
||
live_text(total.at("attendance").is_null()
|
||
? "Zuschauerzahl unbekannt · nur Partien mit eigener Beteiligung"
|
||
: "Nur Partien mit eigener Beteiligung") +
|
||
"</p></section>";
|
||
} else {
|
||
const Json *table = nullptr;
|
||
for (const auto &t : postmatch_data_.at("tables"))
|
||
if (std::find(t.at("match_ids").begin(), t.at("match_ids").end(),
|
||
Json(postmatch_match_)) != t.at("match_ids").end()) {
|
||
table = &t;
|
||
break;
|
||
}
|
||
body +=
|
||
"<p class=\"postmatch-table-note\">" +
|
||
live_text(postmatch_data_.at("source") == "engine-recording"
|
||
? "Tabellenstand nach diesem Spieltag"
|
||
: "Vorgegebener POC-Tabellenstand · Siege, Unentschieden und "
|
||
"Niederlagen nicht aufgezeichnet") +
|
||
"</p><div id=\"postmatch-table\" class=\"postmatch-table-scroll\"><div "
|
||
"class=\"postmatch-table-row heading\">";
|
||
for (const auto *label :
|
||
{"Pl.", "Verein", "Sp.", "S", "U", "N", "Tore", "Diff.", "Pkt."})
|
||
body += live_text(label);
|
||
body += "</div>";
|
||
if (table)
|
||
for (const auto &r : table->at("rows")) {
|
||
const int diff = r.at("gf").get<int>() - r.at("ga").get<int>();
|
||
body +=
|
||
"<div class=\"postmatch-table-row " +
|
||
std::string(own.contains(r.at("team").at("id")) ? "postmatch-own"
|
||
: "") +
|
||
"\">" + live_text(postmatch_count(r.at("position"))) +
|
||
postmatch_team(r.at("team"), false, 43) +
|
||
live_text(postmatch_count(r.at("played"))) +
|
||
live_text(postmatch_count(r.value("won", Json()))) +
|
||
live_text(postmatch_count(r.value("drawn", Json()))) +
|
||
live_text(postmatch_count(r.value("lost", Json()))) +
|
||
live_text(postmatch_count(r.at("gf")) + ":" +
|
||
postmatch_count(r.at("ga"))) +
|
||
live_text((diff > 0 ? "+" : "") + std::to_string(diff)) +
|
||
live_text(postmatch_count(r.at("points"))) + "</div>";
|
||
}
|
||
if (!table)
|
||
body +=
|
||
"<p>" +
|
||
live_text("Zu dieser Partie gehört keine Tabelle.") +
|
||
"</p>";
|
||
body += "</div>";
|
||
}
|
||
body += "</div><footer class=\"postmatch-actions\">" +
|
||
btn("postmatch-prev", "Zurück", "mv-btn", "id=\"postmatch-prev\" " + std::string(position == 0 ? "disabled" : "")) +
|
||
btn("postmatch-ticker", "<span id=\"live-review-back\">Zum Ticker</span>", "mv-btn", "id=\"postmatch-ticker\"") +
|
||
live_text(engine_mode_ ? std::string() : std::string("UI-Aufzeichnung"), "postmatch-status") +
|
||
btn("postmatch-next", position + 1 == tabs.size() ? (engine_mode_ ? "Zum Schreibtisch" : "Zum Desktop") : "Weiter", "mv-btn primary", "id=\"postmatch-next\"") +
|
||
"</footer></section>";
|
||
std::string dialog;
|
||
if (!postmatch_dialog_.empty()) {
|
||
Json team;
|
||
const Json *nominee = nullptr, *match = nullptr;
|
||
for (const auto &row : postmatch_data_.at("eleven").at("rows")) {
|
||
if (row.at("team").at("id") == postmatch_detail_team_)
|
||
team = row.at("team");
|
||
if (row.at("player").at("id") == postmatch_detail_player_)
|
||
nominee = &row;
|
||
}
|
||
for (const auto &m : postmatch_data_.at("matches"))
|
||
if (m.at("home").at("id") == postmatch_detail_team_ ||
|
||
m.at("away").at("id") == postmatch_detail_team_)
|
||
match = &m;
|
||
std::string detail;
|
||
if (nominee)
|
||
detail =
|
||
postmatch_nominee_detail(*nominee, [&](const Json &t, double size) {
|
||
return live_badge(t, size);
|
||
});
|
||
else if (team.is_object())
|
||
detail = "<header class=\"postmatch-player-summary\">" +
|
||
live_badge(team, 150) + "</header>";
|
||
if (match) {
|
||
const bool home = match->at("home").at("id") == postmatch_detail_team_;
|
||
const auto &final = match->at("final");
|
||
const size_t side = home ? 0 : 1;
|
||
detail += "<h3>" + live_text("Teamwerte der Partie") + "</h3><p class=\"postmatch-detail-result\">" +
|
||
live_text(match->at("home").at("name").get<std::string>() +
|
||
" · " + live_score_text(final.at("score")) + " · " +
|
||
match->at("away").at("name").get<std::string>()) +
|
||
"</p><dl class=\"postmatch-player-facts\">";
|
||
for (const auto &[key, label] :
|
||
std::array<std::pair<const char *, const char *>, 3>{
|
||
{{"yellow", "Gelbe Karten"},
|
||
{"red", "Platzverweise"},
|
||
{"score", "Tore"}}})
|
||
detail += "<div><dt>" + live_text(label) + "</dt><dd>" +
|
||
live_text(postmatch_count(final.at(key)[side])) +
|
||
"</dd></div>";
|
||
detail += "<div><dt>Zuschauer</dt><dd>" + live_text(postmatch_count(match->at("attendance"))) + "</dd></div></dl>";
|
||
} else
|
||
detail += "<p>" +
|
||
live_text("Dieser Verein spielte in keiner deiner Partien, deshalb gibt es keinen Spielbericht.") +
|
||
"</p>";
|
||
dialog =
|
||
"<div id=\"postmatch-dialog-layer\" "
|
||
"class=\"mv-veil\"><section class=\"mv-note "
|
||
"postmatch-dialog\" role=\"dialog\" aria-modal=\"true\"><div class=\"mv-tape\"></div><h2>" +
|
||
live_text(nominee ? nominee->at("player").at("name").get<std::string>()
|
||
: team.value("name", "Spieltagsinfo")) +
|
||
"</h2>" + detail + "<footer>" +
|
||
btn("postmatch-detail-close", "Schließen", "mv-btn",
|
||
"id=\"postmatch-detail-close\"") +
|
||
btn("postmatch-detail-report", "Spielbericht", "mv-btn primary",
|
||
"id=\"postmatch-detail-report\" " +
|
||
std::string(match ? "" : "disabled")) +
|
||
"</footer></section></div>";
|
||
}
|
||
// the evaluation is a note laid on the match sheet; the sheet beneath is not operated meanwhile
|
||
const std::string note = "<div class=\"mv-veil\"><div class=\"mv-note pm-note postmatch-window\" role=\"dialog\" aria-label=\"Auswertung\"><div class=\"mv-tape\"></div>" + body + "</div></div>" + dialog;
|
||
const std::string sheet = live_sheet(note);
|
||
return sheet.empty() ? "<section id=\"live-stage\" class=\"mv-stage\">" + note + "</section>" : sheet;
|
||
}
|