Modern UI statistics screen: transfer history and the six curves

Section 1 lists the manager's transfers from the original's own records,
section 2 the six curves of the original (its labels, weekly values and the
absolute scale); the interface scales them itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 09:05:57 +01:00
1 parent 015fa65f56
commit 6054a44acf
5 files changed
+64 -5

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ Fehler: `unknown_read`, `manager_not_active`, `no_active_manager`, `unknown_team
Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt auf; Antwort `{ok, ...}` wie in ihrer Demo.
- `ModernSession::read_almanac`: `index` (Jahre, Anzahl, erstes/letztes Datum), `calendar {year}` (Spieltage mit Anzahl und Höhepunkten), `day {date}` (alle Spiele des Tages), `match {id}` (`match:<Saisonstartjahr>-<Nr.>`). Ein Spiel trägt Datum, Saison, Wettbewerb (`league`/`cup`/`friendly`), Runde, beide Seiten (mit Manager, wenn menschlich), Ergebnis getrennt nach regulärer Zeit, Verlängerung (über die Torminuten) und Elfmeterschießen, Schiedsrichter, Zuschauer, Wetter, Aufstellungen (unter elf Spielern `null`) und Ereignisse (`goal`, `miss`, `yellow`, `second_yellow`, `red`, `injury`, `substitution`, `shootout`).
- `ModernSession::read_statistics_screen`: der Statistikbildschirm mit den Filtern seiner Demo (`section` 0–8, `category`, `country`, `winner_country`, `absolute`, `curves`), `fictional: false`. Aus dem Almanach: 3 Ewige Tabelle (je Land die erste Liga, 5 die eigene), 4 WM-Statistiken (Sieger mit Finale, Torschützen, Länder-Historie), 6 Serien und Rekorde (eigene Liga), 7 Sieger (national, Europapokale, Hallen-Masters), 8 Minuten-Statistik (eigener Verein). Noch ohne Aufzeichnung (`available: false`, `reason: not_recorded`): 0 Möglichkeiten, 1 Transferhistorie, 2 Analytics-Kurven, 5 Saisonfinanzen, bei 4 Gruppen und Finalrunde.
- `ModernSession::read_statistics_screen`: der Statistikbildschirm mit den Filtern seiner Demo (`section` 0–8, `category`, `country`, `winner_country`, `absolute`, `curves`), `fictional: false`. Aus dem Almanach: 3 Ewige Tabelle (je Land die erste Liga, 5 die eigene), 4 WM-Statistiken (Sieger mit Finale, Torschützen, Länder-Historie), 6 Serien und Rekorde (eigene Liga), 7 Sieger (national, Europapokale, Hallen-Masters), 8 Minuten-Statistik (eigener Verein). Aus den Aufzeichnungen des Originals: 1 Transferhistorie (Käufe, Verkäufe, Leihen des Managers mit Ablöse) und 2 Analytics: die sechs Kurven des Originals mit ihren Namen, `values` je erfasster Woche und `absoluteMin`/`absoluteMax`; **die UI skaliert selbst** (`points` bleibt leer, die Demo lieferte Bildschirmkoordinaten). Noch ohne Aufzeichnung (`available: false`, `reason: not_recorded`): 0 Möglichkeiten, 5 Saisonfinanzen (das Original speichert nur die laufende Saison), bei 4 Gruppen und Finalrunde.
- `ModernSession::read_statistics`: `competitions`, `winners`, `player_stats` ([Statistik](statistik.md)) für eine eigene Spieler- und Siegerstatistik.
## Commands
+58
View File
@@ -8752,6 +8752,64 @@ std::string ui_text(const cli::Json& j, const char* key) {
} // namespace
cli::Json ModernSession::read_statistics_screen(const cli::Json& request) const {
using O = cli::Json::Object;
using A = cli::Json::Array;
const int manager = int(g_.memory.has(::bmh::layout::ActiveManager) ? g_.memory.u8(::bmh::layout::ActiveManager) : 0);
cli::Json answer = modern::query_statistics_screen(g_, manager, request);
auto* out = std::get_if<O>(&answer.value);
if (!out || !out->count("section") || !(*out)["section"].integer()) return answer;
const int64_t section = *(*out)["section"].integer();
if (section != 1 && section != 2) return answer;
const bool club = manager >= 0 && size_t(manager) < g_.manager_teams.size() &&
g_.manager_teams[size_t(manager)] >= 0 && g_.manager_teams[size_t(manager)] < league_clubs();
try {
if (section == 1 && club) {
// the manager's transfer list of the original (+0x760/+0x7d8): date, kind, player, other club, fee
const ui::TransferHistoryProjection h = ui::transfer_history_from_game(g_, manager);
auto& cols = std::get<A>((*out)["columns"].value);
for (const char* c : {"Saison / Spieler", "Von", "Nach", "Ablöse"}) cols.push_back(O{{"text", c}});
const size_t team = size_t(g_.manager_teams[size_t(manager)]);
const std::string own = team < g_.world_club_name.size() && !g_.world_club_name[team].empty()
? g_.world_club_name[team] : ui::original_to_utf8(g_.club_name(int(team)));
static constexpr const char* kKinds[4] = {"Verkauf", "Kauf", "Verleih", "Leihe"};
for (const auto& r : h.rows) {
const AlmanacDate d = almanac_date(r.source_date_counter, g_.display_start_year);
const std::string other = r.special_counterparty ? "Ausland" : ui::original_to_utf8(r.counterparty_club_name);
const bool outgoing = (r.source_kind & 3) == 0 || (r.source_kind & 3) == 2;
std::get<A>((*out)["rows"].value).push_back(O{{"cells", A{
O{{"text", std::to_string(d.year) + " · " + ui::original_to_utf8(r.saved_player_name)}, {"kind", kKinds[r.source_kind & 3]}},
O{{"text", outgoing ? own : other}}, O{{"text", outgoing ? other : own}},
O{{"text", std::to_string(r.source_fee) + " €"}, {"value", int64_t(r.source_fee)}, {"money", modern::ui_money(r.source_fee)}}}}});
}
}
if (section == 2 && club) {
// the six curves of the original (labels from the executable), values per recorded week;
// the interface scales them (absolute: min/max of the original's absolute scale)
const ui::AnalyticsState a = ui::analytics_from_game(g_, exe_, manager, Image(320, 240)); // (the underlay only draws)
const A* active = (*out)["curves"].array();
auto& series = std::get<A>((*out)["series"].value);
for (size_t i = 0; i < a.series.size(); ++i) {
A values;
for (int32_t v : a.series[i].values) values.push_back(int64_t(v));
series.push_back(O{{"name", ui::original_to_utf8(a.series[i].label)}, {"color", int(a.series[i].color)},
{"active", active && i < active->size() ? (*active)[i] : cli::Json(true)},
{"values", std::move(values)}, {"absoluteMin", int64_t(a.series[i].absolute_min)},
{"absoluteMax", int64_t(a.series[i].absolute_max)}, {"points", A{}}});
}
}
} catch (const std::exception& e) {
(*out)["reasonDetail"] = std::string(e.what()); // stays "not recorded"
return answer;
}
const bool filled = section == 1 ? !std::get<A>((*out)["rows"].value).empty() : !std::get<A>((*out)["series"].value).empty();
if (filled) {
(*out)["available"] = true;
out->erase("reason");
}
return answer;
}
cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) const {
using O = cli::Json::Object;
using A = cli::Json::Array;
+2 -3
View File
@@ -834,9 +834,8 @@ public:
// The almanac screen (index, calendar, day, match; docs/new_engine/ui-anbindung.md). Read-only.
cli::Json read_almanac(const cli::Json& request) const { return query_almanac(g_, request); }
// The statistics screen for the manager at the desk (docs/new_engine/ui-anbindung.md). Read-only.
cli::Json read_statistics_screen(const cli::Json& request) const {
return query_statistics_screen(g_, int(g_.memory.has(::bmh::layout::ActiveManager) ? g_.memory.u8(::bmh::layout::ActiveManager) : 0), request);
}
// Sections 1 (transfer history) and 2 (the six curves) come from the original's own records.
cli::Json read_statistics_screen(const cli::Json& request) const;
// The read queries of the new interface (docs/new_engine/ui-abfragen.md): status, leagues,
// table, fixtures, squad and the statistics, for the manager at the desk. Read-only.
cli::Json read(const cli::Json& request) const {
+1 -1
View File
@@ -750,7 +750,7 @@ int main(int argc, char** argv) {
for (const auto& filter : {cli::Json::Object{{"section", 3}}, cli::Json::Object{{"section", 4}, {"country", 0}},
cli::Json::Object{{"section", 4}, {"country", 2}}, cli::Json::Object{{"section", 6}},
cli::Json::Object{{"section", 7}}, cli::Json::Object{{"section", 7}, {"category", 1}},
cli::Json::Object{{"section", 8}}, cli::Json::Object{{"section", 1}}}) {
cli::Json::Object{{"section", 8}}, cli::Json::Object{{"section", 1}}, cli::Json::Object{{"section", 2}}}) {
std::string answer = cli::dump_json(session.read_statistics_screen(filter));
if (answer.size() > 1500) answer = answer.substr(0, 1500) + " ...";
std::printf("statistics screen %s\n -> %s\n", cli::dump_json(filter).c_str(), answer.c_str());
+2
View File
@@ -277,6 +277,8 @@ int main(int argc, char** argv) {
check(truth(at(transfers, "ok")) && !truth(at(transfers, "available")) && s(at(transfers, "reason")) == "not_recorded",
"transfer history not recorded");
check(s(at(session.read_statistics_screen(O{{"section", 9}}), "error")) == "invalid_statistics_filter", "bad section");
const J curves = session.read_statistics_screen(O{{"section", 2}});
check(at(curves, "series").array() && at(curves, "series").array()->size() == 6, "the six curves of the original");
}
} catch (const std::exception& ex) {
std::fprintf(stderr, "FAIL: %s\n", ex.what());