A club analysis in the statistics: the season as charts; larger trophies

The engine counts the manager's club's running season from the almanac (read
"analysis"): matches, the points course beside the league's pace, records by venue,
what the first goal decided, goals by quarter of an hour, scorers and goal kinds. The
statistics open with it; the archive tables keep their place with larger type and
trophies.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 23:10:50 +01:00
1 parent 9006b7a05d
commit 8f607a9d89
13 files changed
+444 -9

No files matched your search

+92
View File
@@ -107,3 +107,95 @@ body.silver .statistics-minutes .statistics-row:not(.statistics-head) .statistic
body.silver .statistics-trophy-close {background-color:transparent;decorator:linear-gradient(180deg,#ffffffd8,#e9e1cf99);}
body.silver .statistics-trophy-close:hover {decorator:none;background-color:var(--hover);}
/* --- The club's season as charts. --- */
body {--an-gold:#d9bd7c;--an-panel:#ffffff0a;}
body.silver {--an-gold:#9a7a3a;--an-panel:#ffffff8c;}
.an-screen {color:var(--text);}
.an-head {position:absolute;left:0;top:0;width:2612dp;height:150dp;display:flex;align-items:center;padding:0 30dp;border-bottom:4dp var(--an-gold);}
.an-head .bank-brand strong {color:var(--an-gold);}
.an-tabs {margin-left:auto;}
.an-tabs .bank-tab.selected {background-color:var(--an-gold);border-color:var(--an-gold);}
.an-sub {position:absolute;left:30dp;top:166dp;width:2552dp;height:44dp;margin:0;line-height:44dp;font-size:32dp;color:var(--muted);}
.an-empty {position:absolute;left:30dp;top:400dp;width:2552dp;text-align:center;font-size:40dp;color:var(--muted);}
.an-tile {position:absolute;border:2dp var(--rule);border-radius:10dp;background-color:var(--an-panel);display:flex;flex-direction:column;align-items:center;justify-content:center;}
.an-tile strong {display:block;font-family:Display;font-size:96dp;line-height:108dp;font-weight:bold;white-space:nowrap;}
.an-tile span {display:block;font-size:34dp;line-height:44dp;}
.an-tile small {display:block;font-size:28dp;line-height:36dp;color:var(--muted);}
.an-card {position:absolute;border:2dp var(--rule);border-radius:10dp;background-color:var(--an-panel);padding:22dp 30dp;}
.an-card h3 {display:block;margin:0 0 12dp 0;font-family:Display;font-size:44dp;line-height:54dp;font-weight:bold;}
.an-card h4 {display:block;margin:18dp 0 8dp 0;font-size:28dp;line-height:36dp;font-weight:normal;letter-spacing:2dp;color:var(--an-gold);}
.an-none {margin:20dp 0;font-size:32dp;color:var(--muted);}
.an-course {width:1440dp;height:320dp;}
.an-axis {display:flex;align-items:center;justify-content:space-between;height:44dp;font-size:28dp;color:var(--muted);}
.an-axis span {display:block;flex-shrink:0;}
.an-legend {display:flex;align-items:center;}
.an-legend .key {width:40dp;height:10dp;border-radius:5dp;margin:0 12dp 0 30dp;}
.an-legend .key.own {background-color:#9ac7d8;}
body.silver .an-legend .key.own {background-color:#25617a;}
.an-legend .key.pace {background-color:var(--an-gold);}
.an-legend .key.won {background-color:var(--win);margin-left:0;}
.an-legend .key.lost {background-color:var(--loss);}
.an-strip {display:flex;height:190dp;}
.an-strip-column {flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;}
.an-strip-column .rise {height:90dp;width:100%;display:flex;align-items:flex-end;justify-content:center;}
.an-strip-column .fall {height:90dp;width:100%;display:flex;align-items:flex-start;justify-content:center;}
.an-strip-column .mid {width:100%;height:4dp;background-color:var(--rule);}
.an-strip-column .mid.drawn {height:10dp;margin:-3dp 0;width:60%;border-radius:5dp;background-color:var(--draw);}
.an-strip-column .bar {width:70%;max-width:34dp;border-radius:4dp;}
.bar.won {background-color:var(--win);}
.bar.lost {background-color:var(--loss);}
.an-record {margin-bottom:22dp;}
.an-record-head {display:flex;align-items:baseline;justify-content:space-between;height:48dp;font-size:34dp;}
.an-record-head span,.an-record-head strong {display:block;}
.an-record-head strong {font-size:28dp;font-weight:normal;color:var(--muted);}
.an-stack {display:flex;height:58dp;border-radius:8dp;overflow:hidden;}
.an-stack>div {display:flex;align-items:center;justify-content:center;min-width:0;overflow:hidden;}
.an-stack span {display:block;font-size:30dp;white-space:nowrap;color:#ffffff;}
.an-stack .won {background-color:#3f8a63;}
.an-stack .drawn {background-color:#7c858d;}
.an-stack .lost {background-color:#b24a4f;}
.an-stack .none {background-color:var(--rule);}
.an-stack .none span {color:var(--muted);}
.an-minutes {display:flex;height:420dp;}
.an-minute {flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;}
.an-minute .rise {height:230dp;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;}
.an-minute .fall {height:150dp;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;}
.an-minute .bar {width:86dp;border-radius:6dp;}
.an-minute .fall .bar {max-height:112dp;}
.an-minute span {display:block;font-size:30dp;line-height:36dp;font-weight:bold;}
.an-minute strong {display:block;width:100%;height:40dp;line-height:40dp;text-align:center;font-size:26dp;font-weight:normal;color:var(--muted);border-top:2dp var(--rule);border-bottom:2dp var(--rule);}
.an-scorer {display:flex;align-items:center;height:62dp;border-bottom:2dp var(--rule);font-size:30dp;}
.an-scorer span {display:block;flex-shrink:0;}
.an-scorer .name {width:330dp;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.an-scorer-bar {flex:1;display:flex;height:22dp;margin:0 16dp;}
.an-scorer-bar .goals {height:22dp;background-color:var(--an-gold);border-radius:4dp 0 0 4dp;}
.an-scorer-bar .assists {height:22dp;background-color:var(--an-gold);opacity:.45;border-radius:0 4dp 4dp 0;}
.an-scorer .sum {width:170dp;text-align:right;color:var(--muted);font-size:28dp;}
.an-kind {display:flex;align-items:center;height:50dp;font-size:30dp;}
.an-kind span {display:block;flex-shrink:0;}
.an-kind .name {width:290dp;}
.an-kind .bank-part-track {flex:1;}
.an-kind .bank-part-track>div {background-color:var(--an-gold);}
.an-kind .sum {width:70dp;text-align:right;font-family:Display;font-weight:bold;font-size:34dp;}
.an-reading {margin-top:14dp;border-top:2dp var(--rule);}
.an-reading p {margin:0;font-size:28dp;line-height:38dp;}
/* the archive: larger type and trophies */
.statistics-back {position:absolute;left:24dp;top:22dp;height:64dp;padding:0 26dp;border:2dp var(--rule);border-radius:32dp;background-color:transparent;font-size:30dp;z-index:2;}
.statistics-row {font-size:35dp;}
.statistics-club,.statistics-player-link {font-size:35dp;}
.statistics-heading {font-family:Display;font-size:52dp;height:60dp;line-height:60dp;}
.statistics-list.statistics-winners {top:170dp;height:1524dp;}
.statistics-winner-note {top:100dp;}
.statistics-trophy-heading {height:380dp;}
.statistics-trophy-icon {width:290dp;height:290dp;}
.statistics-trophy-label {height:48dp;line-height:48dp;font-family:Display;font-size:40dp;}
.statistics-world-trophy {height:100dp;font-size:35dp;}
.statistics-world-trophy-art {width:92dp;height:92dp;}
.statistics-winners .statistics-head,.statistics-winners .statistics-col-0 {font-size:34dp;}
.an-record {margin-bottom:30dp;}
.an-stack {height:66dp;}
.an-scorer {height:68dp;}
.an-minutes {height:460dp;}
.an-minute .rise {height:250dp;}
.an-minute .fall {height:170dp;}
+2
View File
@@ -131,3 +131,5 @@ Nach der Übergabe (MVP_FOR_CLAUDE.md): A Schreibtisch (dieser Stand) → B Vorb
`manager.resign.commit` bleibt der bestehende bestätigte Ein-Mensch-Endpfad. Mehrspieler-KI-Übergabe bleibt ausdrücklich nicht unterstützt. Moderne Beitritte behalten den aktuellen Erstligaplatz statt der ursprünglichen Neuplatzierung (#29); Classic und Neuanlage unverändert, in `DIFFERENCES.md` markiert.
- `league-report`: jede Tabellenzeile trägt `zone` (`europe`, `promotion`, `relegation` oder leer). Grundlage sind die Plätze der Saisonprognose (`kLeagueEurope`, in der ersten Liga vier) und die Abstiegsplätze (`kLeagueRelegation`); die Zone folgt dem Rang der gewählten Tabellenansicht.
- `analysis`: die laufende Saison des eigenen Vereins, aus dem Almanach gezählt (`modern::club_analysis`): alle Spiele, Punkteverlauf der Ligaspiele, Heim- und Auswärtsbilanz, Tore je Viertelstunde, Torarten, Chancen, Karten, das erste Tor und sein Ausgang, Torschützen, Liga-Vergleichswerte und die Endplätze abgeschlossener Saisons. Reines Lesen ohne Zufallszahlen.
+6 -1
View File
@@ -9046,7 +9046,7 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
return answer;
}
if (manager < 0 || size_t(manager) >= g_.manager_teams.size() ||
(kind != "balance" && kind != "achievements" && kind != "statistics" && kind != "opening" && kind != "lineup" && kind != "tactics" && kind != "training" && kind != "bank" && kind != "contracts" &&
(kind != "balance" && kind != "achievements" && kind != "statistics" && kind != "analysis" && kind != "opening" && kind != "lineup" && kind != "tactics" && kind != "training" && kind != "bank" && kind != "contracts" &&
kind != "advertising" && kind != "stadium" && kind != "transfer" && kind != "postmatch" && kind != "credit" &&
!(kind == "friendly" && g_.manager_teams[size_t(manager)] == no_team())))
return modern::ui_read(g_, context, request);
@@ -9083,6 +9083,11 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
} catch(const std::exception &e){return modern::ui_error(request_id,"achievements_unavailable",e.what(),revision,false);}
return modern::ui_snapshot(g_,context,request_id,O{{"kind","achievements"},{"available",!rows.empty()},{"originalMenuAvailable",original_available},{"managerId",modern::ui_manager_id(g_,manager)},{"teamId",modern::ui_team_id(g_,team)},{"currentSeasonYear",g_.display_start_year+g_.season},{"records",std::move(rows)}});
}
if (kind == "analysis") {
// the manager's club in the running season, counted from the almanac
return modern::ui_snapshot(g_,context,request_id,O{{"kind","analysis"},{"teamId",modern::ui_team_id(g_,g_.manager_teams[size_t(manager)])},
{"analysis",modern::club_analysis(g_,modern::ui_team_id(g_,g_.manager_teams[size_t(manager)]))}});
}
if (kind == "statistics") {
const cli::Json* query=ui_field(request,"query");
if(!query||!query->object())return modern::ui_error(request_id,"invalid_statistics_request","Eine Statistikabfrage wird benötigt.",revision,false);
+101
View File
@@ -1165,6 +1165,107 @@ cli::Json recent_results(const ModernState& g, const std::string& club_id, size_
return rows;
}
cli::Json club_analysis(const ModernState& g, const std::string& club_id) {
const auto seasons = seasons_of(g);
A history;
for (const auto& s : seasons)
for (const auto& table : s.tables)
for (const auto& row : table.rows)
if (row.club < s.clubs.size() && s.clubs[row.club].id == club_id) {
std::string league = "Liga";
for (const auto& l : s.leagues) if (l.index == int(table.league)) league = l.name;
history.push_back(O{{"year", s.start_year}, {"rank", int(row.rank)}, {"points", int(row.points)},
{"goalsFor", int(row.goals_for)}, {"goalsAgainst", int(row.goals_against)}, {"league", league}});
}
if (seasons.empty() || seasons.back().season != g.almanac.current.season || g.almanac.current.season < 0)
return O{{"available", false}, {"history", std::move(history)}};
const auto& s = seasons.back();
struct Record { int played = 0, won = 0, drawn = 0, lost = 0, goals_for = 0, goals_against = 0; };
const auto record = [](const Record& r) {
return O{{"played", r.played}, {"won", r.won}, {"drawn", r.drawn}, {"lost", r.lost}, {"goalsFor", r.goals_for},
{"goalsAgainst", r.goals_against}, {"points", r.won * 3 + r.drawn}};
};
Record home_record, away_record, first_for, first_against;
int buckets[6][2] = {}, kinds[4][2] = {}, chances[2] = {}, goals[2] = {}, yellow[2] = {}, red[2] = {}, league = -1;
std::map<uint16_t, std::pair<int, int>> scorers; // goals, assists
A matches, points;
int total = 0;
for (const auto& m : s.matches) {
if (m.home >= s.clubs.size() || m.away >= s.clubs.size()) continue;
const bool home = s.clubs[m.home].id == club_id;
if (!home && s.clubs[m.away].id != club_id) continue;
const int own_side = home ? 0 : 1;
const int own = home ? m.home_goals : m.away_goals, other = home ? m.away_goals : m.home_goals;
auto& side_record = home ? home_record : away_record;
++side_record.played; side_record.goals_for += own; side_record.goals_against += other;
(own > other ? side_record.won : own < other ? side_record.lost : side_record.drawn)++;
int first = -1; // who scored the first goal: 0 own, 1 opponent
for (const auto& e : m.events) {
const int mine = e.side == own_side ? 0 : 1;
if (e.kind == AlmanacEventKind::Goal || e.kind == AlmanacEventKind::Miss) ++chances[mine];
if (e.kind == AlmanacEventKind::Goal) {
++goals[mine];
++buckets[std::clamp((int(e.minute) - 1) / 15, 0, 5)][mine];
++kinds[std::min<int>(e.detail, 3)][mine];
if (first < 0) first = mine;
if (!mine) {
if (e.player != kAlmanacNone) ++scorers[e.player].first;
if (e.other != kAlmanacNone) ++scorers[e.other].second;
}
} else if (e.kind == AlmanacEventKind::YellowCard) ++yellow[mine];
else if (e.kind == AlmanacEventKind::RedCard || e.kind == AlmanacEventKind::SecondYellow) ++red[mine];
}
if (first >= 0) {
auto& r = first ? first_against : first_for;
++r.played; (own > other ? r.won : own < other ? r.lost : r.drawn)++;
}
if (m.type == 0) {
league = m.league;
total += own > other ? 3 : own == other ? 1 : 0;
points.push_back(total);
}
matches.push_back(O{{"opponent", s.clubs[home ? m.away : m.home].name}, {"home", home}, {"league", m.type == 0},
{"round", int(m.round)}, {"goalsFor", own}, {"goalsAgainst", other}, {"attendance", int64_t(m.attendance)}});
}
// the league beside it: goals and chances per team and match, points per team and match
int64_t league_matches = 0, league_goals = 0, league_chances = 0, league_points = 0;
if (league >= 0)
for (const auto& m : s.matches) {
if (m.type != 0 || m.league != league) continue;
++league_matches;
league_points += m.home_goals == m.away_goals ? 2 : 3;
for (const auto& e : m.events) {
if (e.kind == AlmanacEventKind::Goal || e.kind == AlmanacEventKind::Miss) ++league_chances;
if (e.kind == AlmanacEventKind::Goal) ++league_goals;
}
}
std::vector<std::pair<uint16_t, std::pair<int, int>>> ranked(scorers.begin(), scorers.end());
std::stable_sort(ranked.begin(), ranked.end(), [](const auto& a, const auto& b) {
return a.second.first * 2 + a.second.second > b.second.first * 2 + b.second.second;
});
A scorer_rows;
for (size_t i = 0; i < ranked.size() && i < 8; ++i) {
const uint16_t p = ranked[i].first;
if (p >= s.players.size()) continue;
const auto& player = s.players[p];
scorer_rows.push_back(O{{"id", player.id}, {"name", player.first.empty() ? player.last : player.first + " " + player.last},
{"goals", ranked[i].second.first}, {"assists", ranked[i].second.second}});
}
A bucket_rows, kind_rows;
for (int b = 0; b < 6; ++b) bucket_rows.push_back(O{{"from", b * 15 + 1}, {"for", buckets[b][0]}, {"against", buckets[b][1]}});
for (int k = 0; k < 4; ++k) kind_rows.push_back(O{{"kind", k}, {"for", kinds[k][0]}, {"against", kinds[k][1]}});
std::string league_name;
for (const auto& l : s.leagues) if (l.index == league) league_name = l.name;
return O{{"available", home_record.played + away_record.played > 0}, {"year", s.start_year}, {"leagueName", league_name},
{"matches", std::move(matches)}, {"points", std::move(points)}, {"buckets", std::move(bucket_rows)},
{"kinds", std::move(kind_rows)}, {"home", record(home_record)}, {"away", record(away_record)},
{"firstFor", record(first_for)}, {"firstAgainst", record(first_against)},
{"chances", O{{"for", chances[0]}, {"against", chances[1]}}}, {"goals", O{{"for", goals[0]}, {"against", goals[1]}}},
{"cards", O{{"yellow", yellow[0]}, {"red", red[0]}, {"yellowAgainst", yellow[1]}, {"redAgainst", red[1]}}},
{"league", O{{"matches", league_matches}, {"goals", league_goals}, {"chances", league_chances}, {"points", league_points}}},
{"scorers", std::move(scorer_rows)}, {"history", std::move(history)}};
}
cli::Json team_of_the_day(const ModernState& g, uint32_t from_date, uint32_t until_date) {
std::map<std::string, int> runtime; // world player id -> runtime index
for (size_t p = 0; p < g.world_player_id.size(); ++p)
+6
View File
@@ -53,6 +53,12 @@ cli::Json team_of_the_day(const ModernState& g, uint32_t from_date, uint32_t unt
// The last `count` recorded matches of a club (world club id), oldest first: each
// {form: "S"|"U"|"N", score: "own:other", opponent, home}. A shoot-out counts for its winner.
cli::Json recent_results(const ModernState& g, const std::string& club_id, size_t count);
// A club's running season read from the almanac, for charts: every match (opponent, score,
// attendance), goals by quarter of an hour, goal kinds, chances and their conversion, cards,
// the home and away records, who scored first and what came of it, the club's scorers, the
// points after each league match beside the league's average, and the final ranks of the
// finished seasons. Counts only: nothing is drawn and nothing the season core reads changes.
cli::Json club_analysis(const ModernState& g, const std::string& club_id);
// The ticker's headline and sentence for one event (kind as AlmanacEventKind); `home`/`away` is the
// score after it. Deterministic: the variant follows from the event's facts.
std::pair<std::string, std::string> ticker_phrase(int kind, const std::string& team, const std::string& who,
+7 -1
View File
@@ -7,7 +7,7 @@ void App::engine_reports_sync() {
engine_reports_context_=meta;engine_reports_index_=Json();engine_reports_read_=Json();engine_reports_roster_=Json();engine_reports_value_=Json();engine_reports_roster_value_=Json();
engine_fixtures_read_=Json();engine_fixtures_value_=Json();
engine_rankings_read_=Json();engine_rankings_value_=Json();engine_fairplay_read_=Json();engine_fairplay_value_=Json();engine_rankings_player_=Json();
engine_statistics_read_=Json();engine_statistics_value_=Json();engine_statistics_query_=Json();statistics_trophy_=Json::object();statistics_scrolls_=Json::object();
engine_statistics_read_=Json();engine_statistics_value_=Json();engine_analysis_value_=Json();engine_statistics_query_=Json();statistics_trophy_=Json::object();statistics_scrolls_=Json::object();
engine_other_index_=Json();engine_other_read_=Json();engine_other_value_=Json();
report_detail_kind_.clear();report_detail_club_.clear();report_detail_player_.clear();
}
@@ -55,6 +55,12 @@ void App::engine_other_load(const std::string &preferred,int round) {
void App::engine_reports_poll(const EngineReply &reply) {
if(reply.bundle.at("desktop").at("meta")!=engine_reports_context_)throw editor::Error("Der Berichtskontext hat sich geändert. Bitte neu öffnen.");
const auto &r=reply.response,&read=r.at("read");
if(r.at("kind")=="statistics"&&r.contains("analysis")) {
// counts only; an answer of another shape leaves the analysis empty
const auto &answer=r.at("analysis");
engine_analysis_value_=answer.is_object()&&answer.value("messageType","")=="snapshot"&&answer.at("data").value("kind","")=="analysis"&&
answer.at("data").at("teamId")==reply.bundle.at("desktop").at("meta").at("scope").at("teamId")?answer.at("data").at("analysis"):Json{{"available",false}};
}
if(r.at("kind")=="statistics"){engine_statistics_value_=engine_statistics_projection(reply.bundle,read);engine_statistics_read_=read;engine_statistics_query_=r.at("query");engine_notice_="Statistik geladen.";return;}
if(r.at("kind")=="rankings"||r.at("kind")=="fairplay") {
if(r.at("kind")=="rankings"){auto value=engine_rankings_projection(reply.bundle,r.at("index"),read,r.at("league"),r.at("scope"));engine_rankings_value_=std::move(value);engine_rankings_read_=read;engine_rankings_state_["league"]=r.at("league");engine_rankings_state_["scope"]=r.at("scope");}
+3 -2
View File
@@ -5,9 +5,10 @@ Json App::statistics_data() const {
}
void App::engine_statistics_load() {
if(engine_busy_||engine_files_busy_||!engine_fresh_)return;
if(engine_statistics_value_.is_object()&&engine_statistics_query_==statistics_view_){refresh();return;}
if(engine_statistics_value_.is_object()&&engine_statistics_query_==statistics_view_&&engine_analysis_value_.is_object()){refresh();return;}
const auto query=statistics_view_;auto link=engine_link_;
engine_start("Statistik wird geladen …",[link,query]{const auto bundle=link->snapshot();return EngineReply{link,bundle,{{"messageType","reports_preview"},{"kind","statistics"},{"query",query},{"read",link->read({{"kind","statistics"},{"query",query}})}},nullptr};});
// the archive table and the club's analysis travel together
engine_start("Statistik wird geladen …",[link,query]{const auto bundle=link->snapshot();return EngineReply{link,bundle,{{"messageType","reports_preview"},{"kind","statistics"},{"query",query},{"read",link->read({{"kind","statistics"},{"query",query}})},{"analysis",link->read({{"kind","analysis"}})}},nullptr};});
}
bool App::engine_statistics_player(const std::string &id,Rml::Element *target) {
if(!engine_statistics_value_.is_object())return false;
+166
View File
@@ -0,0 +1,166 @@
// SPDX-License-Identifier: GPL-3.0-only
// The club's running season as charts, counted by the engine from the almanac
// (read "analysis", modern::club_analysis). Bars are plain boxes so that every figure is
// type; only the points course is a drawing.
std::string App::render_statistics_analysis() {
const auto tabs = [&](const std::string &current) {
std::string out = "<nav class=\"bank-tabs an-tabs\" aria-label=\"Statistikansicht\">";
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 2>{{{"analysis", "Vereinsanalyse"}, {"archive", "Archiv"}}})
out += btn("statistics-mode", label, std::string("bank-tab") + (current == id ? " selected" : ""),
"id=\"statistics-mode-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (current == id ? "true" : "false") + "\"");
return out + "</nav>";
};
std::string out = "<section class=\"statistics-native an-screen\"><div class=\"an-head\"><div class=\"bank-brand\"><strong>Statistiken</strong><span>Vereinsanalyse</span></div>" + tabs("analysis") + "</div>";
const auto &data = engine_analysis_value_;
if (!data.is_object() || !data.value("available", false))
return out + "<p class=\"an-empty\">" + std::string(engine_busy_ ? "Die Auswertung wird geladen …" : "In dieser Saison ist noch kein Spiel aufgezeichnet.") + "</p></section>";
const auto one = [](double value) {
std::ostringstream text;
text << std::fixed << std::setprecision(1) << value;
auto result = text.str();
std::replace(result.begin(), result.end(), '.', ',');
return result;
};
const auto two = [](double value) {
std::ostringstream text;
text << std::fixed << std::setprecision(2) << value;
auto result = text.str();
std::replace(result.begin(), result.end(), '.', ',');
return result;
};
const auto card = [](const std::string &css, double x, double y, double w, double h, const std::string &title, const std::string &body) {
return "<div class=\"an-card " + css + "\" style=\"" + rect(x, y, w, h) + "\"><h3>" + title + "</h3>" + body + "</div>";
};
const auto &matches = data.at("matches"), &points = data.at("points"), &league = data.at("league");
const int played = int(matches.size()), league_played = int(points.size());
const int goals_for = data.at("goals").at("for"), goals_against = data.at("goals").at("against");
const int chances_for = data.at("chances").at("for"), chances_against = data.at("chances").at("against");
const double pace = league_played ? points.back().get<double>() / league_played : 0;
const double league_pace = league.at("matches").get<int64_t>() ? league.at("points").get<double>() / (2.0 * league.at("matches").get<double>()) : 0;
const double conversion = chances_for ? goals_for * 100.0 / chances_for : 0;
const double league_conversion = league.at("chances").get<int64_t>() ? league.at("goals").get<double>() * 100.0 / league.at("chances").get<double>() : 0;
const int year = data.value("year", 0);
out += "<p class=\"an-sub\">Saison " + std::to_string(year) + "/" + (year % 100 + 1 < 10 ? "0" : "") + std::to_string((year + 1) % 100) +
(data.value("leagueName", std::string()).empty() ? "" : " · " + esc(data.at("leagueName").get<std::string>())) + " · alle Pflicht- und Testspiele aus dem Spielarchiv</p>";
// the figures a manager asks for first
const std::array<std::array<std::string, 3>, 6> tiles{{
{std::to_string(played), "Spiele", std::to_string(league_played) + " in der Liga"},
{two(pace), "Punkte je Ligaspiel", "Liga-Schnitt " + two(league_pace)},
{std::to_string(goals_for), "Tore", played ? one(double(goals_for) / played) + " je Spiel" : ""},
{std::to_string(goals_against), "Gegentore", played ? one(double(goals_against) / played) + " je Spiel" : ""},
{one(conversion) + " %", "Chancenverwertung", "Liga-Schnitt " + one(league_conversion) + " %"},
{std::to_string(data.at("cards").at("yellow").get<int>()) + " / " + std::to_string(data.at("cards").at("red").get<int>()), "Gelbe / Rote Karten",
"Gegner " + std::to_string(data.at("cards").at("yellowAgainst").get<int>()) + " / " + std::to_string(data.at("cards").at("redAgainst").get<int>())}}};
for (size_t i = 0; i < tiles.size(); ++i)
out += "<div class=\"an-tile\" style=\"" + rect(30 + double(i) * 428.666, 230, 408.666, 230) + "\"><strong>" + tiles[i][0] + "</strong><span>" + tiles[i][1] + "</span><small>" + tiles[i][2] + "</small></div>";
// points after each league match beside the league's average pace; below it every match
{
std::string body;
if (league_played > 1) {
const double top = std::max({points.back().get<double>(), league_pace * league_played, 3.0}) * 1.12;
const auto px = [&](double match) { return 20 + match * 1400.0 / league_played; };
const auto py = [&](double value) { return 300 - value / top * 280; };
const std::string line = theme_ == "silver" ? "#25617a" : "#9ac7d8", gold = theme_ == "silver" ? "#9a7a3a" : "#d9bd7c", faint = theme_ == "silver" ? "#4a433430" : "#dfeaf530";
std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1440 320\"><defs><linearGradient id=\"under\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"" + line +
"\" stop-opacity=\".30\"/><stop offset=\"1\" stop-color=\"" + line + "\" stop-opacity=\".02\"/></linearGradient></defs>";
for (int row = 0; row < 4; ++row) svg += "<line x1=\"20\" y1=\"" + scalar(20 + row * 93.3) + "\" x2=\"1420\" y2=\"" + scalar(20 + row * 93.3) + "\" stroke=\"" + faint + "\" stroke-width=\"2\"/>";
std::string course = scalar(px(0)) + "," + scalar(py(0)) + " ";
for (int i = 0; i < league_played; ++i) course += scalar(px(i + 1)) + "," + scalar(py(points[size_t(i)].get<double>())) + " ";
svg += "<polygon points=\"" + course + scalar(px(league_played)) + ",300\" fill=\"url(#under)\"/><line x1=\"" + scalar(px(0)) + "\" y1=\"" + scalar(py(0)) + "\" x2=\"" + scalar(px(league_played)) + "\" y2=\"" +
scalar(py(league_pace * league_played)) + "\" stroke=\"" + gold + "\" stroke-width=\"5\" stroke-dasharray=\"16 12\"/><polyline points=\"" + course + "\" fill=\"none\" stroke=\"" + line +
"\" stroke-width=\"7\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><circle cx=\"" + scalar(px(league_played)) + "\" cy=\"" + scalar(py(points.back().get<double>())) + "\" r=\"11\" fill=\"" + line + "\"/></svg>";
body += "<div class=\"an-course\">" + picture(renderer_.diagram("analysis-course", svg, 2880), 1440, 320) + "</div><div class=\"an-axis\"><span>1. Spieltag</span><div class=\"an-legend\"><span class=\"key own\"></span><span>" +
std::to_string(points.back().get<int>()) + " Punkte</span><span class=\"key pace\"></span><span>Liga-Schnitt " + std::to_string(int(std::lround(league_pace * league_played))) + "</span></div><span>" +
std::to_string(league_played) + ". Spieltag</span></div>";
} else body += "<p class=\"an-none\">Der Punkteverlauf beginnt mit dem zweiten Ligaspiel.</p>";
body += "<h4>Alle Spiele · Höhe nach Tordifferenz</h4><div class=\"an-strip\">";
const size_t shown = std::min<size_t>(matches.size(), 40), start = matches.size() - shown;
for (size_t i = start; i < matches.size(); ++i) {
const auto &m = matches[i];
const int balance = m.at("goalsFor").get<int>() - m.at("goalsAgainst").get<int>();
const double height = std::min(std::abs(balance), 4) * 22.0;
const auto label = esc(std::string(m.at("home").get<bool>() ? "Heim" : "Auswärts") + " gegen " + m.at("opponent").get<std::string>() + " " + std::to_string(m.at("goalsFor").get<int>()) + ":" + std::to_string(m.at("goalsAgainst").get<int>()));
body += "<div class=\"an-strip-column\" title=\"" + label + "\"><div class=\"rise\">" + (balance > 0 ? "<div class=\"bar won\" style=\"height:" + scalar(height) + "dp;\"></div>" : std::string()) +
"</div><div class=\"mid " + (balance ? "" : "drawn") + "\"></div><div class=\"fall\">" + (balance < 0 ? "<div class=\"bar lost\" style=\"height:" + scalar(height) + "dp;\"></div>" : std::string()) + "</div></div>";
}
out += card("an-points", 30, 490, 1500, 710, "Punkteverlauf", body + "</div>");
}
// home and away, and what the first goal decided
{
const auto bar = [&](const std::string &label, const Json &r, const std::string &extra) {
const int games = r.at("played");
std::string row = "<div class=\"an-record\"><div class=\"an-record-head\"><span>" + label + "</span><strong>" + extra + "</strong></div><div class=\"an-stack\">";
for (const auto &[key, css, letter] : std::array<std::tuple<const char *, const char *, const char *>, 3>{{{"won", "won", "S"}, {"drawn", "drawn", "U"}, {"lost", "lost", "N"}}}) {
const int count = r.at(key);
if (count) row += "<div class=\"" + std::string(css) + "\" style=\"width:" + scalar(count * 100.0 / std::max(1, games)) + "%;\"><span>" + std::to_string(count) + " " + letter + "</span></div>";
}
if (!games) row += "<div class=\"none\" style=\"width:100%;\"><span>kein Spiel</span></div>";
return row + "</div></div>";
};
const auto ppg = [&](const Json &r) { return r.at("played").get<int>() ? two(r.at("points").get<double>() / r.at("played").get<double>()) + " Punkte je Spiel · " + std::to_string(r.at("goalsFor").get<int>()) + ":" + std::to_string(r.at("goalsAgainst").get<int>()) + " Tore" : std::string("—"); };
const auto share = [&](const Json &r) { return r.at("played").get<int>() ? std::to_string(int(std::lround(r.at("won").get<double>() * 100 / r.at("played").get<double>()))) + " % gewonnen" : std::string("—"); };
out += card("an-records", 1550, 490, 1032, 710, "Heim und Auswärts",
bar("Heim", data.at("home"), ppg(data.at("home"))) + bar("Auswärts", data.at("away"), ppg(data.at("away"))) +
"<h4>Das erste Tor</h4>" + bar("Selbst zuerst getroffen", data.at("firstFor"), share(data.at("firstFor"))) +
bar("Gegner trifft zuerst", data.at("firstAgainst"), share(data.at("firstAgainst"))));
}
// goals by quarter of an hour: scored upwards, conceded downwards
int best_bucket = 0, worst_bucket = 0;
{
const auto &buckets = data.at("buckets");
int greatest = 1;
for (const auto &b : buckets) greatest = std::max({greatest, b.at("for").get<int>(), b.at("against").get<int>()});
std::string body = "<div class=\"an-minutes\">";
for (size_t i = 0; i < buckets.size(); ++i) {
const int scored = buckets[i].at("for"), conceded = buckets[i].at("against");
if (scored > buckets[size_t(best_bucket)].at("for").get<int>()) best_bucket = int(i);
if (conceded > buckets[size_t(worst_bucket)].at("against").get<int>()) worst_bucket = int(i);
const int from = buckets[i].at("from");
body += "<div class=\"an-minute\"><div class=\"rise\"><span>" + std::to_string(scored) + "</span><div class=\"bar won\" style=\"height:" + scalar(scored * 190.0 / greatest) + "dp;\"></div></div><strong>" +
std::to_string(from) + "–" + (i + 1 == buckets.size() ? "Ende" : std::to_string(from + 14)) + "</strong><div class=\"fall\"><div class=\"bar lost\" style=\"height:" + scalar(conceded * 190.0 / greatest) +
"dp;\"></div><span>" + std::to_string(conceded) + "</span></div></div>";
}
out += card("an-minutes-card", 30, 1230, 960, 620, "Tore nach Spielminute", body + "</div><div class=\"an-axis\"><div class=\"an-legend\"><span class=\"key won\"></span><span>erzielt</span><span class=\"key lost\"></span><span>kassiert</span></div></div>");
}
// the club's scorers: goals solid, assists light
{
const auto &scorers = data.at("scorers");
int greatest = 1;
for (const auto &row : scorers) greatest = std::max(greatest, row.at("goals").get<int>() + row.at("assists").get<int>());
std::string body;
for (size_t i = 0; i < scorers.size() && i < 7; ++i) {
const auto &row = scorers[i];
const int goals = row.at("goals"), assists = row.at("assists");
body += "<div class=\"an-scorer\"><span class=\"name\">" + esc(row.at("name").get<std::string>()) + "</span><div class=\"an-scorer-bar\"><div class=\"goals\" style=\"width:" + scalar(goals * 100.0 / greatest) +
"%;\"></div><div class=\"assists\" style=\"width:" + scalar(assists * 100.0 / greatest) + "%;\"></div></div><span class=\"sum\">" + std::to_string(goals) + " T · " + std::to_string(assists) + " V</span></div>";
}
if (scorers.empty()) body = "<p class=\"an-none\">Noch kein Tor erzielt.</p>";
out += card("an-scorers", 1010, 1230, 800, 620, "Tore und Vorlagen", body);
}
// how the goals came about, and a reading of the season
{
const auto &kinds = data.at("kinds");
constexpr std::array<const char *, 4> names{"Aus dem Spiel", "Elfmeter / Freistoß", "Nachschuss", "Nach Ecke"};
int greatest = 1;
for (const auto &k : kinds) greatest = std::max(greatest, k.at("for").get<int>());
std::string body;
for (size_t i = 0; i < kinds.size() && i < 4; ++i)
body += "<div class=\"an-kind\"><span class=\"name\">" + std::string(names[i]) + "</span><div class=\"bank-part-track\"><div style=\"width:" + scalar(kinds[i].at("for").get<int>() * 100.0 / greatest) +
"%;\"></div></div><span class=\"sum\">" + std::to_string(kinds[i].at("for").get<int>()) + "</span></div>";
const auto &buckets = data.at("buckets");
const auto span = [&](int index) { const int from = buckets[size_t(index)].at("from"); return std::to_string(from) + ". bis " + (index == 5 ? std::string("letzten") : std::to_string(from + 14) + ".") + " Minute"; };
std::string reading = league_played ? (pace > league_pace + .15 ? "Die Mannschaft punktet über dem Liga-Schnitt (" : pace < league_pace - .15 ? "Die Mannschaft punktet unter dem Liga-Schnitt (" : "Die Mannschaft punktet im Liga-Schnitt (") +
two(pace) + " gegen " + two(league_pace) + " je Spiel). " : std::string();
if (chances_for) reading += "Aus " + std::to_string(chances_for) + " Chancen wurden " + std::to_string(goals_for) + " Tore; der Gegner kam zu " + std::to_string(chances_against) + " Chancen. ";
if (goals_for) reading += "Die meisten Tore fielen von der " + span(best_bucket) + ". ";
if (goals_against) reading += "Die meisten Gegentore fielen von der " + span(worst_bucket) + ".";
out += card("an-kinds", 1830, 1230, 752, 620, "Torarten", body + "<div class=\"an-reading\"><h4>Analyse</h4><p>" + reading + "</p></div>");
}
return out + "</section>";
}
+5
View File
@@ -15,6 +15,11 @@ bool App::statistics_picker_select(const std::string &kind,const std::string &va
bool App::statistics_action(const std::string &action,Rml::Element *target) {
if(!action.starts_with("statistics-"))return false;
if(menu_!="statistics"||(!source_&&!engine_mode_))return true;
if(action=="statistics-mode"&&target) {
const auto id=target->GetAttribute<Rml::String>("data-id","");
if(id=="analysis"||id=="archive"){statistics_mode_=id;focus_after_render_="statistics-mode-"+std::string(id=="analysis"?"analysis":"analysis");refresh();}
return true;
}
if(action=="statistics-trophy-close") {
if(statistics_trophy_.contains("asset")) {
focus_after_render_=statistics_trophy_.value("return_focus","");statistics_trophy_=Json::object();refresh();
+6 -5
View File
@@ -78,11 +78,12 @@ std::string App::statistics_trophy_asset(const std::string &id) const {
std::string App::render_statistics() {
statistics_remember_scroll();
if((!source_&&!engine_mode_)||!world_)return "<p>Statistiken sind nicht verfügbar.</p>";
if(engine_mode_&&statistics_mode_=="analysis")return render_statistics_analysis()+render_report_detail();
const auto data=statistics_data();
if(!data.value("ok",false))return "<p>Statistiken sind nicht verfügbar.</p>";
const int section=data.at("section").get<int>(),category=data.at("category").get<int>();
const bool winners=section==7,minutes=section==8,finals=section==4&&data.at("country")==3;
std::string out="<section class=\"statistics-native statistics-section-"+std::to_string(section)+(finals?" statistics-finals":"")+"\"><div class=\"statistics-panel\"><h2 class=\"statistics-heading\">"+esc(data.at("title").get<std::string>())+"</h2>";
std::string out="<section class=\"statistics-native statistics-section-"+std::to_string(section)+(finals?" statistics-finals":"")+"\"><div class=\"statistics-panel\">"+(engine_mode_?btn("statistics-mode","‹ Vereinsanalyse","statistics-back","id=\"statistics-mode-analysis\" data-id=\"analysis\""):std::string())+"<h2 class=\"statistics-heading\">"+esc(data.at("title").get<std::string>())+"</h2>";
if(winners)out+="<p class=\"statistics-winner-note\">"+statistics_text(data.value("note",""))+"</p>";
if(engine_mode_&&!data.value("available",false)){out+="<p class=\"statistics-empty\">"+statistics_text(data.value("reason","")=="not_recorded"?"Diese Auswertung wurde in der Karriere noch nicht aufgezeichnet.":"Keine Statistikdaten für diese Auswahl vorhanden.")+"</p>";}
else if(section==2) {
@@ -109,7 +110,7 @@ std::string App::render_statistics() {
const double rest=count>1?(table_width-first)/double(count-1):0;
const auto width=[&](size_t column){return finals?(column==1?160:1194):column?rest:first;};
const bool trophies=winners&&std::any_of(columns.begin(),columns.end(),[](const Json &column){return !column.value("trophy","").empty();});
const double head_height=trophies?200:winners?78:66;
const double head_height=trophies?400:winners?78:76;
out+="<div id=\"statistics-list\" class=\"statistics-list "+std::string(winners?"statistics-winners ":"")+(minutes?"statistics-minutes ":"")+"\" data-scroll-key=\""+esc(statistics_scroll_key(data))+"\"><div class=\"statistics-table\" role=\"table\"><div class=\"statistics-row statistics-head\" role=\"row\" style=\"height:"+scalar(head_height)+"dp;\">";
for(size_t c=0;c<count;++c) {
const auto &column=columns[c];
@@ -117,7 +118,7 @@ std::string App::render_statistics() {
std::string heading=statistics_text(column.at("text").get<std::string>());
if(column.contains("round"))heading="<span class=\"statistics-fixture-round\"><span>"+esc(column.at("round").get<std::string>())+"</span></span>"+heading;
if(!trophy.empty()) {
const auto art=asset.empty()?std::string():"<span class=\"statistics-trophy-icon\">"+img(asset,105,105,asset.starts_with("asset:"),false,320)+"</span>";
const auto art=asset.empty()?std::string():"<span class=\"statistics-trophy-icon\">"+img(asset,290,290,asset.starts_with("asset:"),false,640)+"</span>";
heading=btn("statistics-trophy",art+"<span class=\"statistics-trophy-label\">"+esc(column.at("text").get<std::string>())+"</span>","statistics-trophy-heading",
"id=\"statistics-trophy-heading-"+std::to_string(c)+"\" data-column=\""+std::to_string(c)+"\" data-row=\"-1\" aria-label=\""+esc(column.at("text").get<std::string>()+" · Siegerbild ansehen")+"\" "+(asset.empty()||!column.contains("winner")?"disabled":""));
}
@@ -127,7 +128,7 @@ std::string App::render_statistics() {
for(size_t r=0;r<rows.size();++r) {
const auto &cells=rows[r].at("cells");
const bool world_trophies=section==4&&(data.at("country")==0||data.at("country")==5);
const double row_height=minutes?200:winners?100:world_trophies?78:66;
const double row_height=minutes?200:winners?120:world_trophies?110:76;
out+="<div class=\"statistics-row "+std::string(r%2==0?"striped":"")+"\" role=\"row\" style=\"height:"+scalar(row_height)+"dp;\">";
for(size_t c=0;c<cells.size();++c) {
const auto &value=cells[c];const auto title=value.value("text","");const auto token=std::to_string(r)+"-"+std::to_string(c);
@@ -140,7 +141,7 @@ std::string App::render_statistics() {
content=btn("club-detail",reverse?name+badge:badge+name,"report-club-button statistics-club "+std::string(reverse?"name-first ":"")+(data.at("club")==id?"current":""),"id=\"statistics-club-"+token+"\" data-id=\""+esc(id)+"\" title=\""+esc(title)+"\"");
} else if(value.contains("trophy")) {
const auto asset=statistics_trophy_asset(value.at("trophy").get<std::string>());
content=btn("statistics-trophy",(asset.empty()?std::string():"<span class=\"statistics-world-trophy-art\">"+img(asset,58,58,asset.starts_with("asset:"),false,192)+"</span>")+statistics_text(title),"statistics-world-trophy","id=\"statistics-trophy-row-"+token+"\" data-row=\""+std::to_string(r)+"\" data-column=\""+std::to_string(c)+"\" "+(asset.empty()?"disabled":""));
content=btn("statistics-trophy",(asset.empty()?std::string():"<span class=\"statistics-world-trophy-art\">"+img(asset,92,92,asset.starts_with("asset:"),false,256)+"</span>")+statistics_text(title),"statistics-world-trophy","id=\"statistics-trophy-row-"+token+"\" data-row=\""+std::to_string(r)+"\" data-column=\""+std::to_string(c)+"\" "+(asset.empty()?"disabled":""));
} else content=statistics_text(value.value("prefix","")+title);
if(value.contains("round"))content="<span class=\"statistics-fixture-round\"><span>"+esc(value.at("round").get<std::string>())+"</span></span>"+content;
out+="<div class=\"statistics-cell statistics-col-"+std::to_string(c)+" "+esc(value.value("tone",""))+"\" role=\"cell\" style=\"width:"+scalar(width(c))+"dp;height:"+scalar(row_height)+"dp;\">"+content+"</div>";
+4
View File
@@ -4,6 +4,10 @@
Json statistics_scrolls_ = Json::object();
bool statistics_restore_pending_ = false;
std::string render_statistics();
// "analysis": the club's season as charts (engine careers); "archive": the tables of the original
std::string statistics_mode_ = "analysis";
Json engine_analysis_value_;
std::string render_statistics_analysis();
std::vector<std::pair<std::string, std::string>> statistics_picker_items(const std::string &) const;
std::string statistics_picker_value(const std::string &) const;
bool statistics_picker_select(const std::string &, const std::string &);
+1
View File
@@ -1664,6 +1664,7 @@ public:
#include "modern/ui/engine_friendlies.inc"
#include "modern/ui/engine_almanac.inc"
#include "modern/ui/engine_reports.inc"
#include "modern/ui/statistics_analysis.inc"
#include "modern/ui/engine_rankings.inc"
#include "modern/ui/engine_creation.inc"
#include "modern/ui/engine_files.inc"
+45
View File
@@ -225,7 +225,52 @@ void check_shootout_projection() {
"overlapping stoppage/extra-time goal minute has unknown partial score");
}
// The club analysis counts what the almanac recorded: records by venue, goals by quarter of
// an hour, chances, the first goal and the points course of the league matches.
void check_club_analysis() {
AlmanacSeason s;
s.season = 0; s.start_year = 2026; s.display_start_year = 2026;
s.leagues.push_back({0, "league:test", "Testliga"});
const uint16_t own = s.club({"club:own", "Eigene Elf"}), other = s.club({"club:other", "Gegner"});
const uint16_t striker = s.player({"player:striker", "Anna", "Sturm", "nation:de"});
const uint16_t helper = s.player({"player:helper", "Ben", "Pass", "nation:de"});
const auto event = [](AlmanacEventKind kind, int minute, int side, uint16_t player, uint16_t assistant, int detail) {
AlmanacEvent e; e.kind = kind; e.minute = uint8_t(minute); e.side = uint8_t(side); e.player = player; e.other = assistant; e.detail = uint8_t(detail);
return e;
};
AlmanacMatch home; // 2:1 at home: own goals in minutes 10 and 80, the guests score first in minute 5
home.type = 0; home.league = 0; home.round = 1; home.home = own; home.away = other; home.home_goals = 2; home.away_goals = 1; home.attendance = 30000;
home.events = {event(AlmanacEventKind::Goal, 5, 1, kAlmanacNone, kAlmanacNone, 0), event(AlmanacEventKind::Goal, 10, 0, striker, helper, 0),
event(AlmanacEventKind::Miss, 30, 0, striker, kAlmanacNone, 0), event(AlmanacEventKind::YellowCard, 40, 0, helper, kAlmanacNone, 0),
event(AlmanacEventKind::Goal, 80, 0, striker, kAlmanacNone, 3)};
AlmanacMatch away; // 0:0 away
away.type = 0; away.league = 0; away.round = 2; away.home = other; away.away = own; away.attendance = 12000;
away.events = {event(AlmanacEventKind::Miss, 50, 1, helper, kAlmanacNone, 0)};
s.matches = {home, away};
ModernState g; g.season = 0; g.display_start_year = 2026; g.almanac.current = s;
const auto a = club_analysis(g, "club:own");
const auto whole = [&](const cli::Json& j, const char* key) { return int(*field(j, key).integer()); };
check(std::get<bool>(field(a, "available").value) && field(a, "matches").array()->size() == 2, "analysis lists both matches");
check(whole(field(a, "home"), "won") == 1 && whole(field(a, "home"), "points") == 3 && whole(field(a, "away"), "drawn") == 1,
"analysis keeps the records by venue");
check(whole(field(a, "goals"), "for") == 2 && whole(field(a, "goals"), "against") == 1 && whole(field(a, "chances"), "for") == 4 &&
whole(field(a, "chances"), "against") == 1, "analysis counts goals and chances of both sides");
const auto& buckets = *field(a, "buckets").array();
check(buckets.size() == 6 && whole(buckets[0], "for") == 1 && whole(buckets[0], "against") == 1 && whole(buckets[5], "for") == 1,
"analysis sorts goals into quarters of an hour");
check(whole(field(a, "firstAgainst"), "played") == 1 && whole(field(a, "firstAgainst"), "won") == 1 && whole(field(a, "firstFor"), "played") == 0,
"analysis notes who scored first and what came of it");
const auto& points = *field(a, "points").array();
check(points.size() == 2 && *points[0].integer() == 3 && *points[1].integer() == 4, "analysis follows the points course");
const auto& scorers = *field(a, "scorers").array();
check(scorers.size() == 2 && whole(scorers[0], "goals") == 2 && whole(scorers[1], "assists") == 1 && whole(field(a, "cards"), "yellow") == 1,
"analysis ranks scorers and counts cards");
check(whole((*field(a, "kinds").array())[3], "for") == 1, "analysis keeps the goal kinds");
check(!std::get<bool>(field(club_analysis(g, "club:absent"), "available").value), "a club without a match has no analysis");
}
int main() {
check_club_analysis();
check_shootout_recording();
check_shootout_projection();
const AlmanacSeason s = sample();