Bind cup reports and linked competition phases to live engine data (by Codex)

This commit is contained in:
Codex committed 2026-10-28 23:03:36 +01:00
1 parent 545e16f153
commit 6b4aa9772d
26 files changed
+402 -33

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@ jobs:
- name: Configure opt-in UI without external assets
run: cmake -S . -B build-ui -G Ninja -DCMAKE_BUILD_TYPE=Release -DOPENBMH_BUILD_MODERN_UI=ON -DOPENBMH_BUILD_EDITOR=OFF -DBMH_DATA=
- name: Compile native frontend and synthetic checks
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests modern_reports_tests modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests modern_statistics_ui_tests modern_news_ui_tests modern_settings_ui_tests modern_desktop_ui_tests modern_files_ui_tests modern_mods_ui_tests modern_entry_ui_tests modern_opening_ui_tests modern_select_menu_tests modern_career_ui_tests modern_live_ui_tests modern_national_ui_tests modern_news_catalog_tests modern_post_match_ui_tests modern_engine_dto_tests modern_report_read_tests --parallel 2
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests modern_reports_tests modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests modern_statistics_ui_tests modern_news_ui_tests modern_settings_ui_tests modern_desktop_ui_tests modern_files_ui_tests modern_mods_ui_tests modern_entry_ui_tests modern_opening_ui_tests modern_select_menu_tests modern_career_ui_tests modern_live_ui_tests modern_national_ui_tests modern_news_catalog_tests modern_post_match_ui_tests modern_engine_dto_tests modern_report_read_tests modern_other_read_tests --parallel 2
- name: Check controls, fonts, density and draft cancellation
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_|statistics_ui_|news_ui_|settings_ui_|desktop_ui_|files_ui_|mods_ui_|entry_ui_|opening_ui_|select_menu_|career_ui_|live_ui_|national_ui_|news_catalog_|post_match_ui_|engine_dto_|report_read_)" -LE external-data --output-on-failure --output-junit modern-ui-results.xml
- name: Upload test report
+4
View File
@@ -1217,6 +1217,10 @@ add_test(NAME modern_camp_tests COMMAND modern_camp_tests)
add_executable(modern_almanac_tests tests/modern_almanac_tests.cpp)
target_link_libraries(modern_almanac_tests PRIVATE bmh_modern_content)
add_test(NAME modern_almanac_tests COMMAND modern_almanac_tests)
add_executable(modern_other_read_tests tests/modern_other_read_tests.cpp)
target_link_libraries(modern_other_read_tests PRIVATE bmh_modern_content)
add_test(NAME modern_other_read_tests COMMAND modern_other_read_tests)
add_executable(modern_report_read_tests tests/modern_report_read_tests.cpp)
target_link_libraries(modern_report_read_tests PRIVATE bmh_modern_content)
add_test(NAME modern_report_read_tests COMMAND modern_report_read_tests)
+4
View File
@@ -88,3 +88,7 @@ body.silver .report-row.striped,body.silver .report-list.match-list {background-
body.silver .report-reset,body.silver .report-round {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
body.matchday .report-row.striped,body.matchday .report-list.match-list {background-color:#f8e7e00a;}
body.matchday .report-reset,body.matchday .report-round {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
/* Cup legs share one fixed score column; scores retain the displayed sides. */
.report-score-lines {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4dp;font-size:30dp;}
.report-score-note {display:block;font-size:25dp;white-space:nowrap;}
+1 -1
View File
@@ -57,7 +57,7 @@ Für 0.3 gilt außerdem:
| M3 | Modern-Weltlader, Namen (Vor-/Nachname, UTF-8), Asset-Schlüssel | Weltlader erledigt: Modern-Datensatz spielt zwei Saisons; Namen/Assets für die UI liegen in `ModernState`, Spielstände folgen mit M6 |
| M4 | Trainingslager: 18 Lager, drei Karten, 6-Sterne-Wirkung | Engine erledigt (Katalog, Preis, 6-Sterne-Wirkung, Test); Saisonwirkung wird in M7 gemessen |
| M5 | Datenrevision 1.4 des Modern-Datensatzes (privat), Wirtschaftsprüfung | erledigt: Revision 1.4 abgenommen (Lager, 100 Schiedsrichter, Geburtsdaten; siehe Phasen) |
| M6 | Modern-Spielstände (`modern-career-v1`), Projektionen für die UI | Spielstände erledigt (Rundreise identisch); UI-Projektionen schrittweise angebunden (u. a. Tabellen, Stärken, Ligaspiele, Almanach) |
| M6 | Modern-Spielstände (`modern-career-v1`), Projektionen für die UI | Spielstände erledigt (Rundreise identisch); UI-Projektionen schrittweise angebunden (u. a. Tabellen, Stärken, Liga-/Pokalspiele, Almanach) |
| M7 | Balance-Läufe und Anpassungen | erledigt: Spielerwerte nach Rangfolge, Langläufe über 12 Saisons ohne Drift gegenüber Classic ([Balance](balance.md)); offen nur Läufe mit aktivem Manager |
| M8 | Fußball-Almanach: alle Spiele mit Ereignissen und Aufstellungen ([Almanach](almanach.md)) | Engine und Leseprojektionen vorhanden; nativer Almanach angeschlossen; Elfmeterschuss-Aufzeichnung und belegte Altarchive korrigiert (#18) |
| M9 | Nationalteams mit echten Kadern ([Nationalteams](nationalteams.md)) | Engine erledigt: 24 von 61 Nationen des Diamond-Datensatzes spielen mit Spielern |
+11
View File
@@ -135,3 +135,14 @@ nutzt dieselbe mittige Paarungsgeometrie wie die HTML-Vorlage.
Synthetische Marker-/Bereichs-/Kontexttests, alle Runden der neun tatsächlichen
Ligen und private GUI-Reads einschließlich Verlegung/Rücknahme und OBS-Neustart
liegen unter `bmh_4k_ui/docs/qa/engine-fixtures-2026-10-28/`.
### M6 · Übrige Spiele, 28. Oktober 2026
`other-index`/`other-fixtures` kapseln `other_games_from_game` als reine
Runtime-Reads. Der optionale Metadatenaufruf liest noch keine Teilnehmer- oder
Ergebnislisten; bestehende Aufrufer behalten ihr Verhalten. Die native Ansicht
verwendet die gelieferten aktiven Wettbewerbe, Gruppen/Phasen und Runden.
Keine Änderung an Spielregeln, Zufallsverbrauch, Spielstand- oder OBW-Format;
keine Editoranpassung nötig. Tests decken offene/gespielte Spiele, Zukunftsrunden,
vertauschte Zweitspielwerte und Kontextgrenzen ab. Private Belege:
`bmh_4k_ui/docs/qa/engine-other-2026-10-28/`.
+22
View File
@@ -36,3 +36,25 @@ Code: `src/modern/content/projections.hpp/.cpp`. Prüfen: `MODERN_STATS=1 modern
- Je Menü der fertigen GUI: Codex nennt die benötigten Felder (am einfachsten als Beispiel-JSON aus der Demo), die Engine baut die Abfrage, beide Seiten testen gegen dasselbe Beispiel.
- Aktionen (`ModernSession::apply`) nach demselben Muster, mit Revision wie bei den bestehenden Desk-Aktionen.
## Aktive Pokalansichten für RmlUI
`ui_read {kind: "other-index"}` liefert mit Snapshot-Hülle `views` und
`defaultViewId`. Jede Ansicht enthält `id`, `name`, `competition`, `page`,
`entry`, `rounds`, `currentRound`, `knockout`, `twoLegs`. Der Katalog folgt
`ActiveSelectors` und den Gruppen-/Phasenlinks der vorhandenen Core-Projektion.
`ui_read {kind: "other-fixtures", viewId, round?}` liefert diese Metadaten
sowie `viewId`, `round`, `heading`, `available`, `reason`, `matches`.
`name` bezeichnet hier den Wettbewerb; Gruppen-/Phasenzusätze stehen in der
Überschrift und im ausführlichen Pickernamen des Index.
Ohne `round` gilt die aktuelle Core-Runde; explizite Runden beginnen bei 1.
Jede Paarung hat `id`, `home`, `away`, `status`, `result`, `phase`, `secondLeg`,
`secondLegPhase`, `secondLegVisible`, `date`, `homeHasSquad`, `awayHasSquad`.
Nur `played` enthält `result: [Heimtore, Auswärtstore]`. `open` und `scheduled`
enthalten `null`; letztere können ein ISO-Datum haben. `secondLeg` verwendet
dieselben angezeigten Seiten, obwohl die gespeicherte zweite Partie vertauscht
liegt. `phase` ist der gespeicherte Pokalmarker (0 normal, 1 Verlängerung,
2 Elfmeterschießen), kein rekonstruierter Phasen-Teilstand. `available: false`
enthält keine Paarungen; `reason` ist `round_pending` oder `stage_pending`.
Ungültige Ansichten/Runden und fehlende Core-Daten werden abgewiesen.
+1 -1
View File
@@ -6,7 +6,7 @@ Die normale Classic-Konfiguration bleibt unverändert; die neue Oberfläche
wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
Der [opt-in Engine-Einstieg](integration/ENGINE_ENTRY.md) lädt inzwischen eine
echte Modern-OBS-Karriere und bindet Schreibtisch, Trainingslager, Aufstellung, Taktik, Training, Bank, Eintrittspreis, Umfeld, Werbung, Spielerverträge, Vereinskalender, Spielverlegung, Vereins-/Nationalfreundschaftsspiele, den Almanach sowie Tabellen, Stärken und Ligaspiele an die
echte Modern-OBS-Karriere und bindet Schreibtisch, Trainingslager, Aufstellung, Taktik, Training, Bank, Eintrittspreis, Umfeld, Werbung, Spielerverträge, Vereinskalender, Spielverlegung, Vereins-/Nationalfreundschaftsspiele, den Almanach sowie Tabellen, Stärken, Ligaspiele und übrige Spiele an die
Session. Kader und Profile zeigen die tatsächlichen Sessionwerte; Spielertausch
verwendet die bestätigte Engineaktion. Preisbestätigung, Buchung und Speichern als neue OBS-Datei sind echte
Engineoperationen. Dieser Einstieg ist auf diesen Umfang begrenzt; die übrigen
+1 -1
View File
@@ -40,7 +40,7 @@ Implementierung in der Spiel-Engine.
| Verträge | [Kaderdaten, Angebote, Versicherung und Prämien](desktop/contracts/README.md) |
| Almanach | [Echte Archivjahre, Tagespartien und historische Spielberichte](desktop/almanac/README.md) |
| Paarungsanordnung | [Mittige Ergebnisse und innenliegende Wappen](desktop/fixtures/README.md) |
| Berichte | [Echte Tabellen, Stärken, Ligaspiele und Profile; getrennte übrige Spielvorschau](desktop/reports/README.md) |
| Berichte | [Echte Tabellen, Stärken, Liga-/Pokalspiele und Profile](desktop/reports/README.md) |
| Freundschaftsspiele | [Vereins-/Nationalgegner, echte Angebote und bestätigte Buchungen](desktop/friendlies/README.md) |
| Verlegen | [Kalendergestützte Verlegung mit Rücknahme](desktop/postpone/README.md) |
| Hallentabellen | [16 Vereine, Sortierung und Hallenmasters-Info](desktop/indoor/README.md) |
+46 -1
View File
@@ -20,7 +20,7 @@ Tabellen und Stärken jetzt denselben vorhandenen RmlUI-Presenter mit Sessiondat
aktuellen Teilnehmern, Vereinszahl, Spieltagen und Fortschritt. Die Länder- und
Ligaauswahl verwendet ausschließlich diesen Index, einschließlich der erweiterten
internationalen Ligen. Ligaspiele sind ebenfalls angebunden (siehe unten);
„Übrige Spiele“ bleibt bis zum eigenen Anschluss eine Präsentationsansicht.
„Übrige Spiele“ ist über die vorhandene Pokalprojektion angebunden (siehe unten).
`league-report {leagueId, filter}` liefert Tabelle und Kaderstärken im selben
Karriere-/Welt-/Manager-/Revisionskontext. Filter 0–4 bedeuten Alle Spiele,
@@ -93,6 +93,51 @@ Private Screenshots, Spielstände und Messdaten:
`bmh_4k_ui/docs/qa/engine-fixtures-2026-10-28/`. Ausführung Linux x64;
Windows und macOS sind nicht nativ geprüft.
## Echte übrige Spiele · 28. Oktober 2026
Ausgangsstand `0.3` / `545e16f`. `other-index` liefert die tatsächlich aktiven
Wettbewerbe aus der vorhandenen Modern-Projektion `other_games_from_game`.
Verknüpfte Gruppen und Phasen stehen als eigene Einträge im bestehenden
Wettbewerbspicker; IDs lauten `cup-view:<Wettbewerb>:<Seite>`. Das ist eine
Ansichtskennung innerhalb des aktuellen Saison-/Revisionskontexts, keine neue
OBW-Wettbewerbsdefinition. Abgeschlossene, nicht mehr aktive Wettbewerbe
bleiben über den Almanach erreichbar.
`other-fixtures {viewId,round?}` liefert die gewählte Phase mit einsbasierter
Runde, Originalüberschrift, Verfügbarkeit und allen dort sichtbaren Paarungen.
Der Core-Presenter arbeitet dafür im vollständigen kompakten Modus; die native
Oberfläche zeigt dessen gesamte Liste mit Scrollbalken. Für den Index kann die
Core-Projektion nur Metadaten liefern, ohne noch uninitialisierte Ergebnis- oder
Teilnehmerlisten zu lesen. Die Ablauf-, Auslosungs- und Ergebnislogik wird
nicht verändert. Zukunftsrunden und unvollständige Vorgängerphasen liefern
keine geratenen Teams, sondern eine leere Liste und einen sichtbaren Hinweis.
Offene Spiele haben kein Ergebnis. Geplante Wettbewerbseinträge enthalten ein
Datum und keine aus Tagesoffsets decodierten Tore. Bei Hin-/Rückspielen werden
die beiden gespeicherten Ergebnisse auf dieselben angezeigten Mannschaftsseiten
bezogen; der Rückspielstand und der Hinspielstand bleiben getrennt. Die
Originalmarker für Verlängerung und Elfmeterschießen werden mit `n.V.`/`n.E.`
gekennzeichnet. Die gepackten Pokalwerte werden nicht als getrennte reguläre
oder Verlängerungs-Teilstände ausgegeben; diese ausführliche Phasenauswertung
bleibt beim historischen Almanachbericht.
Wettbewerbswahl, Rundenpfeile und Profile verwenden den bestehenden
Berichtspresenter und dessen Kontextschutz. Vereine ohne tatsächlichen
Runtime-Kader erhalten keinen erfundenen Kader; der Spielerknopf ist gesperrt.
Nicht gelieferte aktuelle Stärken/Kapazitäten bleiben unbekannt. Schließen,
Wiederöffnen und reine Auswahl erzeugen keine Spieländerung. Eine
Sessionmutation verwirft auch diesen Cache.
Private Nachweise: `bmh_4k_ui/docs/qa/engine-other-2026-10-28/`.
52 synthetische CTests, 109 Haupt-GUI-Prüfungen, 15 Randfallprüfungen und
5.268 Geometrieprüfungen bestehen. Die reale Karriere liefert 18 aktive
Wettbewerbs-/Phasenansichten mit insgesamt 61 Runden. Drei Themes bei 1080p,
Silver zusätzlich bei 720p; reine Reads, bestätigter Aufstellungstausch mit
Cacheverwerfung und OBS-Neustarts sind geprüft. Der echte Einstieg bestätigt
native Buttons nun ebenfalls per Enter/Leertaste; fokussierte Auswahloptionen
und Paarungsnamen werden sichtbar gescrollt. Native Ausführung Linux x64;
Windows und macOS wurden nicht ausgeführt.
Die folgenden Beschreibungen gelten für die **getrennte Präsentationsdemo**.
## Sichtbare Daten
+12 -1
View File
@@ -17,7 +17,7 @@ werden. Die Quelle wird nicht in DemoSource überführt.
## Gebundener Umfang
- `ModernSession::ui_read`: `session`, `desktop`, `camps`, `squad`, `lineup`, `tactics`, `training`, `bank`, `stadium`, `credit`, `environment`, `advertising`, `contracts`, `calendar`, `scheduling`, `friendly-plan`, `report-index`, `league-report`, `league-fixtures`; parameterisierte Angebote über `friendly` und Archivabfragen über `almanac`. Karriere, Manager,
- `ModernSession::ui_read`: `session`, `desktop`, `camps`, `squad`, `lineup`, `tactics`, `training`, `bank`, `stadium`, `credit`, `environment`, `advertising`, `contracts`, `calendar`, `scheduling`, `friendly-plan`, `report-index`, `league-report`, `league-fixtures`, `other-index`, `other-fixtures`; parameterisierte Angebote über `friendly` und Archivabfragen über `almanac`. Karriere, Manager,
Mannschaft, Datum, Saison, Geld, Lagerqualitäten und Angebote kommen aus der
Engine. Katalog und Engine müssen dieselbe Welt-ID und Datenrevision haben.
- Der bestehende RmlUI-Schreibtisch verwendet die gemeinsamen App-Buttons und
@@ -301,3 +301,14 @@ Snapshot und verwirft sie nach einer Sessionmutation. Browsing ändert weder
Revision, RNG noch Archiv. Private Nachweise mit realer Verlegung/Rücknahme:
`bmh_4k_ui/docs/qa/engine-fixtures-2026-10-28/`. „Übrige Spiele“ bleibt
vorerst separat. [Vertrag und Bedienung](../desktop/reports/README.md).
## Übrige Spiele · 28. Oktober 2026
`other-index` nennt aktive Wettbewerbsansichten mit ihren verknüpften Gruppen
und Phasen. `other-fixtures {viewId,round?}` delegiert an die vorhandene reine
Modern-Pokalprojektion. Beide Antworten verwenden die übliche revisionsgebundene
Snapshot-Hülle. Runden ohne abgeschlossene Vorgänger beziehungsweise ohne
Auslosung bleiben ohne Paarungen; es gibt keinen Demoersatz. Hin-/Rückspiele,
Verlängerungs-/Elfmetermarker und geplante Datumszeilen bleiben unterscheidbar.
Vereinsprofile verwenden die gemeldeten Teilnehmer, Spielerprofile ausschließlich
tatsächlich vorhandene Runtime-Kader. [Vertrag und Grenzen](../desktop/reports/README.md).
+103
View File
@@ -15,6 +15,9 @@
#include "modern/game/almanac.hpp"
#include "modern/game/desk_actions.hpp"
#include "modern/game/matchday.hpp"
#include "modern/game/other_games.hpp"
#include "modern/game/cup.hpp"
#include <set>
namespace bmh::modern {
@@ -156,6 +159,104 @@ J table(const ModernState& g, int league) {
return O{{"ok", true}, {"league", league_json(g, league)}, {"played", played}, {"rows", std::move(rows)}};
}
std::string cup_view_id(int competition, int page) {
return "cup-view:" + std::to_string(competition) + ":" + std::to_string(page);
}
J cup_view(const OtherGamesProjection& p, int page, bool linked) {
std::string name = p.competition == 11 ? "Hallenturnier" : almanac_utf8(p.title);
if (linked) {
std::string stage = almanac_utf8(p.round_heading);
if (stage.starts_with(name)) stage.erase(0, name.size());
while (!stage.empty() && (stage.front() == ' ' || stage.front() == '-')) stage.erase(0, 1);
name += " · " + stage;
}
return O{{"id", cup_view_id(p.competition, page)}, {"name", name},
{"competition", p.competition}, {"page", page}, {"entry", p.entry_index},
{"rounds", p.rounds}, {"currentRound", p.round + 1},
{"knockout", p.knockout}, {"twoLegs", p.two_legs}};
}
J other_index(const ModernState& g) {
if (!g.texts) return error("unavailable");
A views; std::set<int> seen; std::string selected;
for (int slot = 0; slot < 8; ++slot) {
const int competition = g.memory.u8(::bmh::layout::ActiveSelectors + uint32_t(slot));
if (competition == 0x14 || !seen.insert(competition).second) continue;
const auto current = modern::other_games_from_game(g, *g.texts, competition, 0, -1,
OtherGamesDisplayMode::compact, 0, true, false);
if (current.linked_pages.empty()) {
views.push_back(cup_view(current, 0, false));
if (selected.empty()) selected = cup_view_id(competition, 0);
} else {
for (const auto& page : current.linked_pages) {
const auto p = modern::other_games_from_game(g, *g.texts, competition, page.ordinal, -1,
OtherGamesDisplayMode::compact, 0, false, false);
views.push_back(cup_view(p, page.ordinal, true));
if (selected.empty() && p.entry_index == current.entry_index)
selected = cup_view_id(competition, page.ordinal);
}
}
}
if (selected.empty() && !views.empty()) selected = *views.front().object()->at("id").string();
return O{{"ok", true}, {"kind", "other-index"}, {"views", std::move(views)}, {"defaultViewId", selected.empty() ? J(nullptr) : J(selected)}};
}
J cup_score(uint16_t value) {
return value == 0xcccc ? J(nullptr) : J(A{J(int((value >> 5) & 31)), J(int(value & 31))});
}
J other_fixtures(const ModernState& g, const J& request) {
const J* view = field(request, "viewId"), *round = field(request, "round");
if (!view || !view->string() || (round && (!round->integer() || *round->integer() < 1 || *round->integer() > 64)))
return error("invalid_request");
const auto index = other_index(g); const auto* object = index.object();
if (!object || !object->count("views")) return index;
const J* chosen = nullptr;
for (const auto& v : *object->at("views").array())
if (*v.object()->at("id").string() == *view->string()) chosen = &v;
if (!chosen) return error("invalid_competition");
const auto& v = *chosen->object();
const int requested = round ? int(*round->integer()) - 1 : -1;
const auto p = modern::other_games_from_game(g, *g.texts, int(*v.at("competition").integer()),
int(*v.at("page").integer()), requested, OtherGamesDisplayMode::compact, 0, false);
A matches;
for (const auto& row : p.rows) {
const bool scheduled = row.kind == OtherGamesRowKind::scheduled_competition;
O m{{"id", "fixture:cup-" + std::to_string(p.entry_index) + "-" + std::to_string(p.round + 1) + "-" + std::to_string(row.source_match)},
{"home", club_json(g, row.home_team)}, {"away", club_json(g, row.away_team)},
{"status", scheduled ? "scheduled" : row.played ? "played" : "open"},
{"result", scheduled ? J(nullptr) : cup_score(row.source_result)},
{"phase", !scheduled && row.played ? J(int(row.source_result >> 10)) : J(nullptr)},
{"secondLeg", nullptr}, {"secondLegPhase", nullptr}, {"secondLegVisible", row.second_leg_visible}, {"date", nullptr},
{"homeHasSquad", row.home_team < league_clubs()}, {"awayHasSquad", row.away_team < league_clubs()}};
if (row.second_leg_visible && row.second_leg_array_present) {
// The source second-leg word is reversed relative to this row's sides.
if (row.source_second_leg != 0xcccc) {
m["secondLeg"] = A{J(int(row.source_second_leg & 31)), J(int((row.source_second_leg >> 5) & 31))};
m["secondLegPhase"] = int(row.source_second_leg >> 10);
}
}
if (scheduled && row.scheduled_source_day != 0xffff) {
const auto date = almanac_date(row.scheduled_source_day, g.display_start_year);
char iso[16]; std::snprintf(iso, sizeof iso, "%04d-%02d-%02d", date.year, date.month, date.day); m["date"] = iso;
}
matches.push_back(std::move(m));
}
O out = v;
out["ok"] = true; out["kind"] = "other-fixtures"; out["viewId"] = *view;
out["name"] = p.competition == 11 ? "Hallenturnier" : almanac_utf8(p.title);
out["round"] = p.round + 1;
std::string heading = almanac_utf8(p.round_heading);
const auto& title = *out.at("name").string();
if (heading.starts_with(title)) {
heading.erase(0, title.size());
while (!heading.empty() && (heading.front() == ' ' || heading.front() == '-')) heading.erase(0, 1);
}
if (!p.knockout && p.rounds > 1) heading += " · " + std::to_string(p.round + 1) + ". Spieltag";
out["heading"] = heading;
out["available"] = p.fixtures_available;
out["reason"] = p.fixtures_available ? J(nullptr) : J(p.unfinished_predecessor ? "stage_pending" : "round_pending");
out["matches"] = std::move(matches);
return out;
}
J fixtures(const ModernState& g, int league, int matchday) {
const int matchdays = league_matchdays(league);
if (matchday < 1 || matchday > matchdays) return error("invalid_matchday");
@@ -277,6 +378,8 @@ cli::Json query_projection(const ModernState& g, int manager, const cli::Json& r
if (!kind || !kind->string()) return error("invalid_request");
const std::string& k = *kind->string();
try {
if (k == "other-index") return other_index(g);
if (k == "other-fixtures") return other_fixtures(g, request);
if (k == "status") return status(g, manager);
if (k == "toto") return toto(g, manager);
if (k == "sponsor") return sponsor(g, manager);
+2
View File
@@ -12,6 +12,8 @@
// Each match has a stable id, home/away club refs, status and result.
// Only played matches have [home, away] scores; open/postponed/rescheduled/
// unavailable matches have null results, including packed status variants.
// {kind: "other-index"} active cups and linked groups/stages
// {kind: "other-fixtures", viewId, round?} actual cup pairings; 1-based round
// {kind: "squad", club?} a squad with names, values and fitness
#include "cli/json.hpp"
+7
View File
@@ -483,6 +483,13 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
if (kind == "session") return snapshot(request_id, std::move(m), session_data(g, c));
if (kind == "desktop") return snapshot(request_id, std::move(m), desktop_data(g, c, today));
if (kind == "camps") return snapshot(request_id, std::move(m), camps_data(g, c, std::to_string(c.state_revision)));
if (kind == "other-index" || kind == "other-fixtures") {
J data = query_projection(g, c.manager, request);
auto* values = std::get_if<O>(&data.value);
if (!values || !values->count("ok") || !std::holds_alternative<bool>(values->at("ok").value) || !std::get<bool>(values->at("ok").value))
return failure(request_id, "other_reports_unavailable", "Wettbewerb oder Runde ist derzeit nicht verfügbar.", c.state_revision);
values->erase("ok"); return snapshot(request_id, std::move(m), std::move(data));
}
if(kind=="report-index") {
A leagues;for(int l=0;l<kLeagueCount;++l)leagues.push_back(report_league(g,l,team_of(g,c.manager)));
return snapshot(request_id,std::move(m),O{{"kind","report-index"},{"leagues",std::move(leagues)}});
+2 -2
View File
@@ -210,7 +210,7 @@ void add_second_leg_and_winner(OtherGamesRow& row, uint16_t second, bool present
OtherGamesProjection other_games_from_game(const ModernState& game, const TextDb& texts,
int competition, int linked_page, int requested_round,
OtherGamesDisplayMode display_mode, int participant_offset,
bool source_new_selection) {
bool source_new_selection, bool include_rows) {
const StaticMemory& memory = game.memory;
if (competition < 0 || competition >= 0x14) invalid("unsupported competition selector");
if (linked_page < 0 || linked_page >= kCupEntries) invalid("invalid linked-page index");
@@ -319,7 +319,7 @@ OtherGamesProjection other_games_from_game(const ModernState& game, const TextDb
if (out.descriptor_competition == 12) out.scheduled_day_mode = true;
// Source paints TEXTD1186 and returns before touching team/result/schedule arrays for a
// blocked future or unfinished stage. Preserve that boundary for incomplete live records.
if (!out.fixtures_available) return out;
if (!out.fixtures_available || !include_rows) return out;
const uint32_t team_list = memory.pointer(address);
const uint32_t first_results = memory.pointer(address + 0x0c);
+3 -1
View File
@@ -29,6 +29,7 @@ namespace bmh::modern {
// therefore not evidence that the entire Original menu interaction is Native-neutral.
// `linked_page` follows the descriptor's Source +0x17 parallel-group link, then +0x16 next-stage
// link. `round == -1` selects CupRound's live round; otherwise it is range-checked.
// `include_rows=false` returns metadata only, without touching participant/result arrays.
// `participant_offset` is Source's low-seven-bit display cursor (multiples of 16). The
// displayed-round group row list remains complete; the mode/offset applies to knockout rows.
OtherGamesProjection other_games_from_game(const ModernState& game, const TextDb& texts,
@@ -36,6 +37,7 @@ OtherGamesProjection other_games_from_game(const ModernState& game, const TextDb
int round = -1,
OtherGamesDisplayMode display_mode = OtherGamesDisplayMode::detail,
int participant_offset = 0,
bool source_new_selection = true);
bool source_new_selection = true,
bool include_rows = true);
} // namespace bmh::modern
+3
View File
@@ -56,6 +56,9 @@ Json engine_report_projection(const Json &bundle,const Json &index,const Json &r
Json engine_report_squad(const Json &bundle,const Json &read,const std::string &team);
Json engine_fixtures_projection(const Json &bundle,const Json &index,const Json &read,const std::string &league,int round);
Json engine_other_index(const Json &bundle,const Json &read);
Json engine_other_projection(const Json &bundle,const Json &index,const Json &read,const std::string &view,int round);
// Single-session facade. Its owner serializes all calls on a background worker.
// No RmlUI objects or callbacks cross this boundary.
class EngineBridge {
+15 -3
View File
@@ -89,6 +89,7 @@ void App::engine_frame() {
if (!engine_busy_ && popup_.empty() && !focus_after_render_.empty()) {
if (auto *node = element(focus_after_render_)) {
node->Focus(keyboard_navigation_);
if(node->GetId().starts_with("report-club-")||node->GetId().starts_with("report-option-"))node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
if(menu_=="almanac"&&node->GetId().starts_with("alm-match-")) {
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
if(auto *list=element("alm-day-list"))list->SetScrollLeft(0);
@@ -138,7 +139,7 @@ void App::engine_event(Rml::Event &event) {
if (!engine_busy_ && popup_.empty() && contracts_event(event)) return;
if (engine_reports_event(event)) return;
if (!engine_busy_ && popup_.empty() && engine_friendly_event(event)) return;
if (!engine_busy_ && planning_dialog_.empty() && popup_.empty() && (menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league") && report_picker_event(event)) return;
if (!engine_busy_ && planning_dialog_.empty() && popup_.empty() && (menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league" || menu_=="other") && report_picker_event(event)) return;
if (engine_sports_event(event)) return;
Rml::ElementFormControl *range = nullptr;
for (auto *node = target; node && node != doc_; node = node->GetParentNode())
@@ -181,6 +182,7 @@ void App::engine_event(Rml::Event &event) {
const int index = found == controls.end() ? -1 : int(found - controls.begin());
auto *next=controls[size_t((index + int(controls.size()) + (event.GetParameter<int>("shift_key", 0) ? -1 : 1)) % int(controls.size()))];
next->Focus(true);
if(next->GetId().starts_with("report-club-"))next->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
if(menu_=="almanac"&&next->GetId().starts_with("alm-match-")) {
next->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
if(auto *list=element("alm-day-list"))list->SetScrollLeft(0);
@@ -199,6 +201,15 @@ void App::engine_event(Rml::Event &event) {
element("camp-value-3")->SetInnerRML("—");
element("camp-focus-3")->SetProperty("visibility", "hidden"); dirty_ = true; return;
}
if(type=="keydown") {
const auto key=Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier",0));
if(key==Rml::Input::KI_RETURN||key==Rml::Input::KI_SPACE) {
for(auto *node=target;node&&node!=doc_;node=node->GetParentNode())if(node->GetTagName()=="button") {
if(!node->HasAttribute("disabled"))node->DispatchEvent("click",{});
event.StopImmediatePropagation();return;
}
}
}
if (type != "click") return;
for (auto *node = target; node && node != doc_; node = node->GetParentNode()) {
if (!node->HasAttribute("data-action") || node->HasAttribute("disabled")) continue;
@@ -211,7 +222,7 @@ void App::engine_event(Rml::Event &event) {
if (engine_reports_action(action,node)) return;
if (almanac_action(action,node)) return;
if (engine_friendly_action(action, node)) return;
if ((menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league") && report_picker_action(action,node)) return;
if ((menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league" || menu_=="other") && report_picker_action(action,node)) return;
if (engine_calendar_action(action, node)) return;
if (contracts_action(action, node)) return;
if (environment_action(action, node)) return;
@@ -225,6 +236,7 @@ void App::engine_event(Rml::Event &event) {
ticket_->open(node, device_ratio_, price.at("min"), price.at("max")); dirty_ = true;
}
else if (action == "engine-open" && (id == "environment" || id == "advertising")) { menu_ = id; advertising_selected_ = -1; advertising_offer_ = 0; refresh(); }
else if(action=="engine-open"&&id=="other"){menu_=id;engine_reports_sync();engine_other_load(engine_other_value_.is_object()?engine_other_value_.at("viewId").get<std::string>():"",engine_other_value_.is_object()?engine_other_value_.at("round").get<int>():0);}
else if(action=="engine-open"&&id=="league"){menu_=id;engine_reports_sync();const auto league=engine_reports_state_.at("league").get<std::string>();engine_fixtures_load(league,engine_fixtures_value_.is_object()&&engine_fixtures_value_.at("leagueId")==league?engine_fixtures_value_.at("round").get<int>():0);}
else if(action=="engine-open"&&(id=="tables"||id=="strengths")){menu_=id;engine_reports_sync();engine_reports_load(engine_reports_state_.at("league"),engine_reports_state_.at("filter"));}
else if (action == "engine-open" && id == "almanac") { menu_=id;engine_almanac_sync();engine_almanac_load({{"kind","index"}}); }
@@ -252,5 +264,5 @@ void App::engine_event(Rml::Event &event) {
}
Json App::engine_snapshot() const {
return {{"mode", engine_mode_}, {"busy", engine_busy_}, {"dirty", engine_dirty_}, {"fresh", engine_fresh_}, {"bundle", engine_data_},
{"response", engine_response_}, {"fixtures_read",engine_fixtures_read_},{"reports_state",engine_reports_state_},{"reports_index",engine_reports_index_},{"reports_read",engine_reports_read_},{"reports_roster",engine_reports_roster_},{"almanac_cache",engine_almanac_cache_}, {"almanac_context",engine_almanac_context_}, {"friendly_quote", engine_friendly_read_}, {"friendly_league", engine_friendly_league_}, {"friendly_opponent", engine_friendly_opponent_}, {"friendly_date", engine_friendly_date_}, {"friendly_home", engine_friendly_home_}, {"friendly_stage", engine_friendly_stage_}, {"friendly_month", engine_friendly_month_}, {"calendar_day", engine_calendar_day_}, {"move_id", engine_move_id_}, {"credit_preview", engine_credit_}, {"credit_edits", engine_credit_edits_}, {"training_draft", engine_training_draft_}, {"tactics_draft", engine_tactics_draft_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
{"response", engine_response_}, {"other_index",engine_other_index_},{"other_read",engine_other_read_},{"fixtures_read",engine_fixtures_read_},{"reports_state",engine_reports_state_},{"reports_index",engine_reports_index_},{"reports_read",engine_reports_read_},{"reports_roster",engine_reports_roster_},{"almanac_cache",engine_almanac_cache_}, {"almanac_context",engine_almanac_context_}, {"friendly_quote", engine_friendly_read_}, {"friendly_league", engine_friendly_league_}, {"friendly_opponent", engine_friendly_opponent_}, {"friendly_date", engine_friendly_date_}, {"friendly_home", engine_friendly_home_}, {"friendly_stage", engine_friendly_stage_}, {"friendly_month", engine_friendly_month_}, {"calendar_day", engine_calendar_day_}, {"move_id", engine_move_id_}, {"credit_preview", engine_credit_}, {"credit_edits", engine_credit_edits_}, {"training_draft", engine_training_draft_}, {"tactics_draft", engine_tactics_draft_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
}
+31
View File
@@ -840,4 +840,35 @@ Json engine_fixtures_projection(const Json &bundle,const Json &index,const Json
}
return out;
}
Json engine_other_index(const Json &bundle,const Json &read) {
auto context=bundle;context["other-index"]=read;auto data=lineup_read(context,"other-index");
require(data.at("views").is_array(),"Wettbewerbsliste fehlt.");std::set<std::string> ids;
for(const auto &v:data.at("views")) {
const auto id=v.at("id").get<std::string>();require(!id.empty()&&ids.insert(id).second&&v.at("name").is_string(),"Doppelter oder unbenannter Wettbewerb.");
const int total=whole_in_range(v.at("rounds"),1,64);(void)whole_in_range(v.at("currentRound"),1,total);
require(v.at("knockout").is_boolean()&&v.at("twoLegs").is_boolean(),"Wettbewerbsart fehlt.");
}
require(data.at("views").empty()?data.at("defaultViewId").is_null():data.at("defaultViewId").is_string()&&ids.contains(data.at("defaultViewId").get<std::string>()),"Standardwettbewerb fehlt.");return data;
}
Json engine_other_projection(const Json &bundle,const Json &index,const Json &read,const std::string &view,int round) {
const auto catalogue=engine_other_index(bundle,index);const Json *selected=nullptr;for(const auto &v:catalogue.at("views"))if(v.at("id")==view)selected=&v;
require(selected,"Fremder Wettbewerb.");auto context=bundle;context["other-fixtures"]=read;auto data=lineup_read(context,"other-fixtures");
require(data.at("viewId")==view&&data.at("round")==round&&data.at("rounds")==selected->at("rounds")&&data.at("entry")==selected->at("entry"),"Paarungen gehören einer anderen Wettbewerbsphase.");
(void)whole_in_range(data.at("round"),1,data.at("rounds"));require(data.at("available").is_boolean()&&data.at("heading").is_string()&&data.at("matches").is_array(),"Unvollständige Pokalansicht.");
require(data.at("available").get<bool>()||data.at("matches").empty(),"Gesperrte Runde enthält Paarungen.");std::set<std::string> ids;
for(auto &m:data["matches"]) {
const auto id=m.at("id").get<std::string>();require(!id.empty()&&ids.insert(id).second,"Doppelte Pokalpaarung.");
for(const auto *side:{"home","away"}){const auto &id=m.at(side).at("id");require(id.is_string()&&!id.get_ref<const std::string &>().empty()&&m.at(side).at("name").is_string(),"Teilnehmeridentität fehlt.");}
require(m.at("home").at("id")!=m.at("away").at("id"),"Teilnehmer spielt gegen sich selbst.");
const auto status=m.at("status").get<std::string>();require(status=="played"||status=="open"||status=="scheduled","Ungültiger Pokalstatus.");
const auto score=[](const Json &v){require(v.is_array()&&v.size()==2,"Pokalergebnis fehlt.");for(const auto &n:v)(void)whole_in_range(n,0,31);};
if(status=="played")score(m.at("result"));else require(m.at("result").is_null(),"Ungespielte Partie enthält Tore.");
require(m.at("secondLegVisible").is_boolean()&&m.at("homeHasSquad").is_boolean()&&m.at("awayHasSquad").is_boolean(),"Teilnehmer-/Rückspielstatus fehlt.");
if(!m.at("secondLeg").is_null()){require(m.at("secondLegVisible").get<bool>(),"Verdecktes Rückspielergebnis.");score(m.at("secondLeg"));}
if(!m.at("date").is_null())(void)calendar_iso_day(m.at("date"));
for(const auto *key:{"phase","secondLegPhase"})if(!m.at(key).is_null())(void)whole_in_range(m.at(key),0,63);
m["home_team"]=m.at("home");m["away_team"]=m.at("away");m["home"]=m.at("home_team").at("id");m["away"]=m.at("away_team").at("id");m["home_goals"]=status=="played"?m.at("result")[0]:Json();m["away_goals"]=status=="played"?m.at("result")[1]:Json();
}
return data;
}
} // namespace bmh::modern_ui
+28 -5
View File
@@ -5,6 +5,7 @@ void App::engine_reports_sync() {
if(engine_reports_context_.is_null()||meta.at("careerId")!=engine_reports_context_.at("careerId")||meta.at("scope").at("managerId")!=engine_reports_context_.at("scope").at("managerId"))engine_reports_state_["league"]="";
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_other_index_=Json();engine_other_read_=Json();engine_other_value_=Json();
report_detail_kind_.clear();report_detail_club_.clear();report_detail_player_.clear();
}
void App::engine_reports_load(const std::string &preferred,int filter) {
@@ -36,9 +37,26 @@ void App::engine_fixtures_load(const std::string &preferred,int round) {
return EngineReply{link,bundle,{{"messageType","reports_preview"},{"kind","fixtures"},{"index",index},{"read",report},{"league",id},{"filter",filter},{"fixtures",fixtures},{"round",selected}},nullptr};
});
}
void App::engine_other_load(const std::string &preferred,int round) {
if(engine_busy_||!engine_fresh_)return;
if(engine_other_value_.is_object()&&engine_other_value_.at("viewId")==preferred&&engine_other_value_.at("round")==round){refresh();return;}
auto link=engine_link_;engine_start("Wettbewerb wird geladen …",[link,preferred,round] {
const auto bundle=link->snapshot(),index=link->read({{"kind","other-index"}});const auto data=engine_other_index(bundle,index);
const Json *view=nullptr;for(const auto &v:data.at("views"))if(v.at("id")==preferred)view=&v;
if(!view)for(const auto &v:data.at("views"))if(v.at("id")==data.at("defaultViewId"))view=&v;
Json response={{"messageType","reports_preview"},{"kind","other"},{"index",index},{"read",nullptr},{"view",nullptr},{"round",0}};
if(view){const auto id=view->at("id").get<std::string>();const int total=view->at("rounds"),selected=round>0?std::clamp(round,1,total):view->at("currentRound").get<int>();response["view"]=id;response["round"]=selected;response["read"]=link->read({{"kind","other-fixtures"},{"viewId",id},{"round",selected}});}
return EngineReply{link,bundle,response,nullptr};
});
}
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")=="other") {
(void)engine_other_index(reply.bundle,r.at("index"));
auto value=read.is_null()?Json():engine_other_projection(reply.bundle,r.at("index"),read,r.at("view"),r.at("round"));
engine_other_index_=r.at("index");engine_other_read_=read;engine_other_value_=std::move(value);engine_notice_="Wettbewerb geladen.";return;
}
if(read.value("messageType","")=="error"){engine_notice_=engine_text(read.value("message",Json()));return;}
if(r.at("kind")=="league"||r.at("kind")=="fixtures") {
auto value=engine_report_projection(reply.bundle,r.at("index"),read,r.at("league"),r.at("filter"));
@@ -53,17 +71,20 @@ void App::engine_reports_poll(const EngineReply &reply) {
engine_notice_="Ligabericht geladen.";
}
Json App::engine_reports_rows(const std::string &mode) const {
if(mode=="other")return engine_other_value_.at("matches");
if(mode=="league")return engine_fixtures_value_.at("matches");
std::vector<Json> rows;
for(const auto &r:engine_reports_value_.at(mode=="tables"?"table":"strengths"))rows.push_back(r);
return sort_report_rows(std::move(rows),engine_reports_state_.at("sorts").at(mode));
}
Json App::engine_report_team(const std::string &id) const {
if(menu_=="other"&&engine_other_value_.is_object())for(const auto &m:engine_other_value_.at("matches"))for(const auto *side:{"home_team","away_team"})if(m.at(side).at("id")==id)return m.at(side);
if(engine_reports_value_.is_object())for(const auto &r:engine_reports_value_.at("table"))if(r.at("club")==id)return r.at("team");
return Json();
}
std::vector<std::pair<std::string,std::string>> App::engine_reports_picker_items(const std::string &kind) const {
std::vector<std::pair<std::string,std::string>> out;
if(menu_=="other"){if(kind=="competition"&&engine_other_index_.is_object())for(const auto &v:engine_other_index_.at("data").at("views"))out.emplace_back(v.at("id"),v.at("name"));return out;}
if(kind=="filter"){const char* values[]={"Alle Spiele","Hinrunde","Rückrunde","Heim","Auswärts"};for(int i=0;i<5;++i)out.emplace_back(std::to_string(i),values[i]);return out;}
const auto &leagues=engine_reports_index_.at("data").at("leagues");std::set<std::string> seen;std::string nation;
for(const auto &l:leagues)if(l.at("id")==engine_reports_state_.at("league"))nation=l.at("nationId").is_string()?l.at("nationId").get<std::string>():"__other__";
@@ -79,10 +100,11 @@ std::vector<std::pair<std::string,std::string>> App::engine_reports_picker_items
return out;
}
bool App::engine_reports_action(const std::string &action,Rml::Element *target) {
if(menu_!="tables"&&menu_!="strengths"&&menu_!="league")return false;
if(menu_!="tables"&&menu_!="strengths"&&menu_!="league"&&menu_!="other")return false;
const auto id=target?target->GetAttribute<Rml::String>("data-id",""):std::string();
if(action=="report-detail-close") {focus_after_render_=report_detail_return_focus_;report_detail_kind_.clear();report_detail_club_.clear();report_detail_player_.clear();refresh();return true;}
if(engine_busy_||!engine_fresh_)return action.starts_with("report-")||action=="club-detail"||action=="player-detail";
if(action=="report-round"&&menu_=="other"){if(id!="1"&&id!="-1")return true;const int current=engine_other_value_.at("round"),total=engine_other_value_.at("rounds");focus_after_render_=target->GetId();engine_other_load(engine_other_value_.at("viewId"),std::clamp(current+std::stoi(id),1,total));return true;}
if(action=="report-round"&&menu_=="league") {if(id!="1"&&id!="-1")return true;const int current=engine_fixtures_value_.at("round"),total=engine_fixtures_value_.at("rounds");const int next=std::clamp(current+std::stoi(id),1,total);focus_after_render_=target->GetId();engine_fixtures_load(engine_reports_state_.at("league"),next);return true;}
if(action=="report-sort") {
const std::set<std::string> table{"rank","played","wins","draw","loss","form","points","gf","diff"},strength{"club","keeper","defence","midfield","attack","strength"};
@@ -107,7 +129,7 @@ bool App::engine_reports_action(const std::string &action,Rml::Element *target)
return false;
}
bool App::engine_reports_event(Rml::Event &event) {
if((menu_!="tables"&&menu_!="strengths"&&menu_!="league")||report_detail_kind_.empty())return false;
if((menu_!="tables"&&menu_!="strengths"&&menu_!="league"&&menu_!="other")||report_detail_kind_.empty())return false;
const auto type=event.GetType();
if(type=="keydown"&&event.GetParameter<int>("key_identifier",0)==Rml::Input::KI_ESCAPE){engine_reports_action("report-detail-close",nullptr);event.StopImmediatePropagation();return true;}
if(type=="keydown"&&event.GetParameter<int>("key_identifier",0)==Rml::Input::KI_TAB){Rml::ElementList nodes;if(auto *root=element("report-detail-dialog"))root->QuerySelectorAll(nodes,"button");std::erase_if(nodes,[](auto *n){return n->HasAttribute("disabled");});if(!nodes.empty()){const auto it=std::find(nodes.begin(),nodes.end(),context_->GetFocusElement());int i=it==nodes.end()?-1:int(it-nodes.begin()),n=int(nodes.size());auto *next=nodes[size_t((i+n+(event.GetParameter<int>("shift_key",0)?-1:1))%n)];next->Focus(true);next->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));}event.StopImmediatePropagation();return true;}
@@ -121,7 +143,7 @@ std::string App::engine_reports_detail() {
std::string title=engine_text(team.at("name")),body,actions=close;
if(report_detail_kind_=="club") {
std::string strength="—",manager="Computer";
for(const auto &r:engine_reports_value_.at("strengths"))if(r.at("club")==report_detail_club_)strength=report_number(r.at("strength"));
if(engine_reports_value_.is_object())for(const auto &r:engine_reports_value_.at("strengths"))if(r.at("club")==report_detail_club_)strength=report_number(r.at("strength"));
for(const auto &m:engine_data_.at("session").at("data").at("managers"))if(m.at("teamId")==report_detail_club_&&m.at("status")=="active")manager=engine_text(m.at("name"));
std::string stadium_name="—",places="—";const auto *club=world_->find("clubs",report_detail_club_);const Json *stadium=nullptr;
if(club&&club->value("stadium",Json()).is_string())stadium=world_->find("stadiums",club->at("stadium"));
@@ -130,12 +152,13 @@ std::string App::engine_reports_detail() {
const auto &live_stadium=engine_data_.at("stadium");
if(live_stadium.value("messageType","")=="snapshot"&&live_stadium.at("data").at("teamId")==report_detail_club_) {int64_t sum=0;for(const auto &block:live_stadium.at("data").at("blocks"))sum+=block.at("places").get<int64_t>();places=number(sum);}
body="<div class=\"report-detail-badge\">"+crest(world_->find("clubs",report_detail_club_),192)+"</div><p class=\"report-detail-note\">Vereinsprofil</p>"+report_detail_fields({{"Stadion",stadium_name},{"Plätze",places},{"Stärke",strength},{"Manager",manager}},72);
actions=btn("report-club-roster","Spieler","report-detail-action","id=\"report-detail-roster\"")+close;
bool has_squad=true;if(menu_=="other")for(const auto &m:engine_other_value_.at("matches")){if(m.at("home")==report_detail_club_)has_squad=m.at("homeHasSquad");if(m.at("away")==report_detail_club_)has_squad=m.at("awayHasSquad");}
actions=btn("report-club-roster","Spieler","report-detail-action",std::string("id=\"report-detail-roster\" ")+(has_squad?"":"disabled"))+close;
} else if(report_detail_kind_=="roster") {
title+=" · Kader";body="<div class=\"report-detail-roster-scroll\" id=\"report-detail-roster-scroll\"><div class=\"report-detail-table\"><div class=\"report-detail-row report-detail-table-head\">";
for(const auto *h:{"Spieler","Pos.","Stärke","Alter"})body+="<div class=\"report-detail-cell\">"+std::string(h)+"</div>";
body+="</div>";
if(!engine_reports_roster_value_.is_object())body+="<p class=\"report-detail-empty\">"+esc(engine_busy_?"Kader wird geladen …":"Kader derzeit nicht verfügbar.")+"</p>";
if(!engine_reports_roster_value_.is_object())body+="<div class=\"report-detail-row\"><div class=\"report-detail-cell\">"+esc(engine_busy_?"Kader wird geladen …":"Kader derzeit nicht verfügbar.")+"</div><div class=\"report-detail-cell\"></div><div class=\"report-detail-cell\"></div><div class=\"report-detail-cell\"></div></div>";
else {size_t n=0;for(const auto &r:engine_reports_roster_value_.at("players")){const auto i=n++;body+="<div class=\"report-detail-row "+std::string(i%2==0?"report-detail-striped":"")+"\"><div class=\"report-detail-cell\">"+btn("player-detail",esc(engine_text(r.at("player").at("name"))),"report-detail-player-link","id=\"report-detail-player-"+std::to_string(i)+"\" data-id=\""+esc(r.at("player").at("id").get<std::string>())+"\"")+"</div><div class=\"report-detail-cell\">"+esc(report_detail_position(r.at("player")))+"</div><div class=\"report-detail-cell\">"+report_number(r.at("live_strength"))+"</div><div class=\"report-detail-cell\">"+report_number(r.at("age"))+"</div></div>";}}
body+="</div></div>";
} else {
+4 -3
View File
@@ -114,11 +114,12 @@ void App::engine_render() {
const auto route = id.substr(4);
const bool camp_allowed = desk.at("menuAvailability").at("camps").value("status", "") == "available";
const auto commands = meta.at("scope").value("allowedCommands", Json::array());
const bool supported = ((route=="tables"||route=="strengths"||route=="league")&&engine_fresh_&&meta.at("scope").at("role")=="club") || (route == "almanac" && engine_fresh_) || (route == "friendlies" && friendlies_available && engine_fresh_) || (route == "calendar" && calendar_available && engine_fresh_) || (route == "postpone" && scheduling_available && engine_fresh_) || (route == "contracts" && contracts_available && engine_fresh_) || (route == "environment" && environment_available && engine_fresh_) || (route == "advertising" && advertising_available && engine_fresh_) || (route == "bank" && bank_available && engine_fresh_) || (route == "training" && training_available && engine_fresh_) || (route == "tactics" && tactics_available && engine_fresh_) || (route == "lineup" && lineup_available && engine_fresh_) || route == "save" || (route == "camp" && engine_fresh_ && camp_allowed && std::find(commands.begin(), commands.end(), Json("camp.book")) != commands.end());
const bool supported = ((route=="tables"||route=="strengths"||route=="league"||route=="other")&&engine_fresh_&&meta.at("scope").at("role")=="club") || (route == "almanac" && engine_fresh_) || (route == "friendlies" && friendlies_available && engine_fresh_) || (route == "calendar" && calendar_available && engine_fresh_) || (route == "postpone" && scheduling_available && engine_fresh_) || (route == "contracts" && contracts_available && engine_fresh_) || (route == "environment" && environment_available && engine_fresh_) || (route == "advertising" && advertising_available && engine_fresh_) || (route == "bank" && bank_available && engine_fresh_) || (route == "training" && training_available && engine_fresh_) || (route == "tactics" && tactics_available && engine_fresh_) || (route == "lineup" && lineup_available && engine_fresh_) || route == "save" || (route == "camp" && engine_fresh_ && camp_allowed && std::find(commands.begin(), commands.end(), Json("camp.book")) != commands.end());
out += desktop_button(id, o, "engine-open", supported && !engine_busy_);
}
}
out += "</div>";
if(menu_=="other")out+="<div class=\"fill\" style=\"z-index:100;\">"+window("Übrige Spiele",engine_other_value_.is_object()?render_reports("other"):"<div class=\"fill center\">"+esc(engine_busy_?"Wettbewerbe werden geladen …":engine_other_index_.is_object()?"Keine aktiven Wettbewerbe.":engine_notice_)+"</div>")+"</div>";
if(menu_=="league")out+="<div class=\"fill\" style=\"z-index:100;\">"+window("Ligaspiele",engine_fixtures_value_.is_object()?render_reports("league"):"<div class=\"fill center\">"+esc(engine_busy_?"Ligaspiele werden geladen …":engine_notice_)+"</div>")+"</div>";
if(menu_=="tables"||menu_=="strengths")out+="<div class=\"fill\" style=\"z-index:100;\">"+window(menu_=="tables"?"Tabelle":"Stärken",engine_reports_read_.is_object()?render_reports(menu_):"<div class=\"fill center\">"+esc(engine_busy_?"Ligabericht wird geladen …":engine_notice_)+"</div>")+"</div>";
if(menu_=="almanac") out+="<div class=\"fill\" style=\"z-index:100;\">"+window("Almanach",engine_almanac_cache_.contains("index")?render_almanac():"<div class=\"fill center\">"+esc(engine_busy_?"Spielarchiv wird geladen …":engine_notice_)+"</div>")+"</div>";
@@ -134,7 +135,7 @@ void App::engine_render() {
if (menu_ == "lineup") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Aufstellung", render_lineup()) + "</div>";
if (menu_ == "camp") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Trainingslager", render_camp()) + "</div>";
}
if ((menu_ == "bank" || menu_ == "environment" || menu_ == "advertising" || menu_ == "contracts" || menu_ == "calendar" || menu_ == "postpone" || menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league") && !amount_ && contracts_dialog_.empty() && planning_dialog_.empty()) out += "<div class=\"panel\" style=\"position:absolute;bottom:12dp;left:700dp;right:700dp;padding:9dp;font-size:25dp;z-index:110;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
if ((menu_ == "bank" || menu_ == "environment" || menu_ == "advertising" || menu_ == "contracts" || menu_ == "calendar" || menu_ == "postpone" || menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league" || menu_=="other") && !amount_ && contracts_dialog_.empty() && planning_dialog_.empty()) out += "<div class=\"panel\" style=\"position:absolute;bottom:12dp;left:700dp;right:700dp;padding:9dp;font-size:25dp;z-index:110;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
if (menu_.empty() || engine_data_.empty()) out += "<div class=\"panel\" style=\"position:absolute;left:850dp;bottom:24dp;right:100dp;padding:18dp;font-size:27dp;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
element("canvas")->SetInnerRML(out); ++document_generation_;
scale_chalk_shadow();
@@ -157,7 +158,7 @@ void App::engine_render() {
Rml::ElementList underlay; doc_->QuerySelectorAll(underlay, ".window>.content,.window>.titlebar");
for (auto *node : underlay) { node->SetProperty("pointer-events", "none"); node->SetProperty("filter", "blur(10dp)"); }
}
if(!report_detail_kind_.empty()&&(menu_=="tables"||menu_=="strengths"||menu_=="league")){Rml::ElementList nodes;doc_->QuerySelectorAll(nodes,"#report-underlay button,#window-close");for(auto *n:nodes){n->SetAttribute("disabled",true);n->SetProperty("pointer-events","none");}}
if(!report_detail_kind_.empty()&&(menu_=="tables"||menu_=="strengths"||menu_=="league"||menu_=="other")){Rml::ElementList nodes;doc_->QuerySelectorAll(nodes,"#report-underlay button,#window-close");for(auto *n:nodes){n->SetAttribute("disabled",true);n->SetProperty("pointer-events","none");}}
if (engine_busy_) {
Rml::ElementList controls; doc_->QuerySelectorAll(controls, "#canvas button,#canvas input");
for (auto *node : controls) node->SetAttribute("disabled", true);
+2
View File
@@ -14,6 +14,8 @@
Json engine_reports_context_, engine_reports_index_, engine_reports_read_, engine_reports_roster_, engine_reports_value_, engine_reports_roster_value_;
Json engine_reports_state_={{"league",""},{"filter",0},{"sorts",{{"tables",{{"key","rank"},{"desc",false}}},{"strengths",{{"key","strength"},{"desc",true}}}}}};
Json engine_fixtures_read_, engine_fixtures_value_;
Json engine_other_index_, engine_other_read_, engine_other_value_;
void engine_other_load(const std::string &,int);
void engine_fixtures_load(const std::string &,int);
void engine_reports_sync();
void engine_reports_load(const std::string &,int);
+6 -4
View File
@@ -16,7 +16,7 @@ App::report_picker_items(const std::string &kind) const {
std::vector<std::pair<std::string, std::string>> items;
if (!world_ || !report_picker_kind(kind))
return items;
if (engine_mode_ && (menu_=="tables"||menu_=="strengths"||menu_=="league")) return engine_reports_picker_items(kind);
if (engine_mode_ && (menu_=="tables"||menu_=="strengths"||menu_=="league"||menu_=="other")) return engine_reports_picker_items(kind);
if (engine_mode_ && menu_ == "friendlies") return engine_friendly_picker_items(kind);
if (menu_ == "statistics")
return statistics_picker_items(kind);
@@ -75,7 +75,8 @@ App::report_picker_items(const std::string &kind) const {
std::string App::report_picker_value(const std::string &kind) const {
if (!world_ || !report_picker_kind(kind))
return {};
if(engine_mode_&&(menu_=="tables"||menu_=="strengths"||menu_=="league")){if(kind=="filter")return std::to_string(engine_reports_state_.at("filter").get<int>());if(kind=="league")return engine_reports_state_.at("league");const auto live_index=engine_report_index(engine_data_,engine_reports_index_);for(const auto &l:live_index.at("leagues"))if(l.at("id")==engine_reports_state_.at("league"))return l.at("nationId").is_string()?l.at("nationId").get<std::string>():"__other__";return {}; }
if(engine_mode_&&menu_=="other")return kind=="competition"&&engine_other_value_.is_object()?engine_other_value_.at("viewId").get<std::string>():"";
if(engine_mode_&&(menu_=="tables"||menu_=="strengths"||menu_=="league"||menu_=="other")){if(kind=="filter")return std::to_string(engine_reports_state_.at("filter").get<int>());if(kind=="league")return engine_reports_state_.at("league");const auto live_index=engine_report_index(engine_data_,engine_reports_index_);for(const auto &l:live_index.at("leagues"))if(l.at("id")==engine_reports_state_.at("league"))return l.at("nationId").is_string()?l.at("nationId").get<std::string>():"__other__";return {}; }
if (menu_ == "statistics")
return statistics_picker_value(kind);
if (kind == "year") return std::to_string(almanac_year_);
@@ -212,11 +213,12 @@ bool App::report_picker_action(const std::string &action, Rml::Element *target)
return item.first == value;
}))
return true;
const Json selection = kind == "filter" || kind == "competition"
const Json selection = kind == "filter" || (kind == "competition" && !engine_mode_)
? Json(std::stoi(value)) : Json(value);
close_report_picker(false);
// Commit even an unchanged country: the Gold resets its first league.
if(engine_mode_&&(menu_=="tables"||menu_=="strengths"||menu_=="league")){
if(engine_mode_&&menu_=="other")engine_other_load(value,0);
else if(engine_mode_&&(menu_=="tables"||menu_=="strengths"||menu_=="league"||menu_=="other")){
std::string league=engine_reports_state_.at("league");int filter=engine_reports_state_.at("filter");
if(kind=="league")league=value;
else if(kind=="filter")filter=std::stoi(value);
+22 -8
View File
@@ -38,7 +38,7 @@ std::string App::render_reports(const std::string &mode) {
const auto *league = world_->find("competitions", state.value("league", ""));
const int tier = league ? league->value("tier", 1) : 1;
const bool strengths = mode == "strengths", matches = mode == "league" || mode == "other";
const bool opening = mode == "other" && state.value("competition", 0) == 3 &&
const bool opening = !engine_mode_ && mode == "other" && state.value("competition", 0) == 3 &&
snapshot.state.value("opening_created", false);
const auto rows = engine_mode_?engine_reports_rows(mode):matches ? (opening ? report_opening_pairs(*world_, snapshot.state.at("opening_flow"))
: report_match_rows(*world_, state, mode == "other"))
@@ -54,9 +54,11 @@ std::string App::render_reports(const std::string &mode) {
{"rank", "Pl. / Verein"}, {"played", "Sp."}, {"wins", "S"},
{"draw", "U"}, {"loss", "N"}, {"form", "Letzte 8"},
{"points", "Punkte"}, {"gf", "Tore"}, {"diff", "Diff."}};
const bool real_other=engine_mode_&&mode=="other";
const auto &fixture=real_other?engine_other_value_:engine_fixtures_value_;
std::vector<double> widths;
if (matches)
widths = {1224, 160, 1224}; // Match card has two 2dp borders.
widths = real_other?std::vector<double>{1184,240,1184}:std::vector<double>{1224,160,1224}; // Match card has two 2dp borders.
else if (strengths) {
widths.push_back(2612 * .38);
for (int i = 0; i < 5; ++i) widths.push_back(2612 * .62 / 5);
@@ -70,10 +72,11 @@ std::string App::render_reports(const std::string &mode) {
: rows.size() >= 20 ? (1682 - heading_height) / rows.size() : 80;
std::string body = "<div id=\"report-underlay\" class=\"report-underlay\">";
if (matches) {
const int round = engine_mode_?engine_fixtures_value_.at("round").get<int>()-1:std::clamp(state.value("round", 0), 0,
const int round = engine_mode_?fixture.at("round").get<int>()-1:std::clamp(state.value("round", 0), 0,
report_round_count(*world_, state, mode == "other") - 1);
std::string subtitle;
if(engine_mode_){const auto &l=engine_fixtures_value_.at("league");subtitle=(l.at("nationId").is_string()?world_->nation_name(l.at("nationId")):std::string())+" · "+l.at("name").get<std::string>();}
if(real_other)subtitle=fixture.at("name").get<std::string>();
else if(engine_mode_){const auto &l=fixture.at("league");subtitle=(l.at("nationId").is_string()?world_->nation_name(l.at("nationId")):std::string())+" · "+l.at("name").get<std::string>();}
else if (mode == "league" || state.value("competition", 0) == 0)
subtitle = (league ? world_->nation_name(league->value("nation", "")) : "") +
" · " + (league ? world_->name(*league) : "");
@@ -82,7 +85,7 @@ std::string App::render_reports(const std::string &mode) {
subtitle = choices.at(size_t(state.value("competition", 0))).second;
}
body += "<header class=\"report-match-heading\"><h2>" +
(opening ? std::string("1. Runde") : std::to_string(round + 1) + ". Spieltag") +
(real_other?fixture.at("heading").get<std::string>():opening ? std::string("1. Runde") : std::to_string(round + 1) + ". Spieltag") +
"</h2><p>" + esc(subtitle) + "</p></header>";
}
body += "<div id=\"report-list\" class=\"report-list " +
@@ -144,13 +147,24 @@ std::string App::render_reports(const std::string &mode) {
value = report_number(row["gf"]) + ":" + report_number(row["ga"]);
else
value = report_number(row.at(headings[column].first));
body += "<span class=\"report-value\">" + esc(value) + "</span>";
if(real_other&&matches) {
const auto phase=[](const Json &v){return v==1?std::string(" n.V."):v==2?std::string(" n.E."):std::string();};
value+=phase(row.at("phase"));
std::string detail;
if(row.at("secondLegVisible").get<bool>()) {
detail="Hin: "+(row.at("secondLeg").is_null()?std::string("–"):report_number(row.at("secondLeg")[0])+":"+report_number(row.at("secondLeg")[1])+phase(row.at("secondLegPhase")));
value="Rück: "+value;
} else if(row.at("status")=="scheduled"&&row.at("date").is_string())detail=row.at("date").get<std::string>();
body+="<div class=\"report-score-lines\"><span class=\"report-value\">"+esc(value)+"</span>"+(detail.empty()?"":"<span class=\"report-score-note\">"+esc(detail)+"</span>")+"</div>";
} else body += "<span class=\"report-value\">" + esc(value) + "</span>";
}
body += "</div>";
}
body += "</div>";
}
body += "</div></div>";
body += "</div>";
if(real_other&&rows.empty())body+="<p class=\"report-detail-empty\">"+std::string(!fixture.at("available").get<bool>()?"Diese Runde ist noch nicht ausgelost oder die vorherige Phase ist noch nicht abgeschlossen.":"Keine Paarungen vorhanden.")+"</p>";
body+="</div>";
if (!matches && !strengths && !engine_mode_) {
const auto legend = tier == 1
? std::vector<std::pair<std::string, std::string>>{
@@ -172,7 +186,7 @@ std::string App::render_reports(const std::string &mode) {
body += btn("report-round", i ? "›" : "‹", "report-round",
"id=\"report-round-" + std::string(i ? "next" : "previous") +
"\" data-id=\"" + (i ? "1" : "-1") + "\" style=\"" +
rect(i * 130, 0, 110, 94) + "\" " + ((opening||(engine_mode_&&(i?engine_fixtures_value_.at("round")==engine_fixtures_value_.at("rounds"):engine_fixtures_value_.at("round")==1))) ? "disabled" : ""));
rect(i * 130, 0, 110, 94) + "\" " + ((opening||(engine_mode_&&(i?fixture.at("round")==fixture.at("rounds"):fixture.at("round")==1))) ? "disabled" : ""));
body += mode == "league" ? report_picker("country", 260, 1060) + report_picker("league", 1340, 1272)
: report_picker("competition", 260, 2352);
} else if (strengths)
+12 -1
View File
@@ -11,7 +11,7 @@ using namespace bmh::modern_ui;
int main(int argc, char **argv) {
try {
const std::string mode=argc>1?argv[1]:"";
const std::set<std::string> modes{"prepare","prepare-two","prepare-national","prepare-almanac","inspect","inspect-friendlies","inspect-almanac","verify","verify-lineup","verify-sports","verify-bank","verify-commerce","verify-contracts","verify-calendar","verify-friendlies","verify-national","verify-almanac","verify-shootouts","verify-reports","verify-fixtures"};
const std::set<std::string> modes{"prepare","prepare-two","prepare-national","prepare-almanac","inspect","inspect-friendlies","inspect-almanac","verify","verify-lineup","verify-sports","verify-bank","verify-commerce","verify-contracts","verify-calendar","verify-friendlies","verify-national","verify-almanac","verify-shootouts","verify-reports","verify-fixtures","verify-other"};
if(argc!=4||!modes.contains(mode))throw std::runtime_error("usage: modern_engine_bridge_probe <prepare[-two|-national|-almanac]|inspect[-friendlies|-almanac]|verify[-lineup|-sports|-bank|-commerce|-contracts|-calendar|-friendlies|-national|-almanac|-shootouts]> <world.obw> <new-output-directory>");
const fs::path world = argv[2], out = argv[3]; fs::create_directories(out);
const auto write = [&](const char *file, const Json &j) { editor::write_atomic(out / file, j.dump(2)); };
@@ -337,6 +337,17 @@ int main(int argc, char **argv) {
write("saved.json",link->save_copy(out/"reports.obs"));link.reset();link=EngineBridge::open(world,out/"reports.obs");
if(link->read({{"kind","report-index"}}).at("data")!=index_read.at("data"))throw std::runtime_error("report index changed after OBS restart");
}
if(mode=="verify-other") {
const auto index=link->read({{"kind","other-index"}}),data=engine_other_index(before,index);write("other-index.json",index);Json all=Json::array();
for(const auto &v:data.at("views"))for(int round=1;round<=v.at("rounds").get<int>();++round) {
const Json request={{"kind","other-fixtures"},{"viewId",v.at("id")},{"round",round}};
const auto read=link->read(request);(void)engine_other_projection(before,index,read,v.at("id"),round);
if(link->read(request)!=read)throw std::runtime_error("cup read changed on repetition");all.push_back(read);
}
write("all-rounds.json",all);if(link->snapshot()!=before)throw std::runtime_error("cup reads mutated session");
write("saved.json",link->save_copy(out/"other.obs"));link.reset();link=EngineBridge::open(world,out/"other.obs");
if(link->read({{"kind","other-index"}}).at("data")!=index.at("data"))throw std::runtime_error("cup index changed on restart");
}
if(mode=="verify-fixtures") {
const auto ir=link->read({{"kind","report-index"}}),idx=engine_report_index(before,ir);write("fixture-index.json",ir);Json rounds=Json::array();
for(const auto &l:idx.at("leagues")) {
+8
View File
@@ -379,6 +379,14 @@ int main() {
bad_fixture=fixture_read;bad_fixture["data"]["round"]=2;rejects([&]{engine_fixtures_projection(report_bundle,report_index_read,bad_fixture,"league:live",1);});
bad_fixture=fixture_read;bad_fixture["data"]["matches"][0]["away"]["id"]="club:6";rejects([&]{engine_fixtures_projection(report_bundle,report_index_read,bad_fixture,"league:live",1);});
bad_fixture=fixture_read;bad_fixture["meta"]["stateRevision"]="42";rejects([&]{engine_fixtures_projection(report_bundle,report_index_read,bad_fixture,"league:live",1);});
const auto other_index=report_wrap("other-index",{{"kind","other-index"},{"views",{{{"id","cup-view:0:0"},{"name","Synthetic Cup"},{"entry",0},{"rounds",2},{"currentRound",1},{"knockout",true},{"twoLegs",false}}}},{"defaultViewId","cup-view:0:0"}});
auto other_data=fixture_read_data;other_data["kind"]="other-fixtures";other_data["viewId"]="cup-view:0:0";other_data["entry"]=0;other_data["available"]=true;other_data["heading"]="Round 1";
auto &om=other_data["matches"][0];om["homeHasSquad"]=true;om["awayHasSquad"]=false;om["secondLegVisible"]=false;om["secondLeg"]=nullptr;om["phase"]=nullptr;om["secondLegPhase"]=nullptr;om["date"]=nullptr;
const auto other_read=report_wrap("other-fixtures",other_data);require(engine_other_projection(report_bundle,other_index,other_read,"cup-view:0:0",1).at("matches")[0].at("home_goals").is_null(),"open cup got a score");
auto bad_other=other_read;bad_other["data"]["available"]=false;rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
bad_other=other_read;bad_other["data"]["matches"][0]["result"]={1,2};rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
bad_other=other_read;bad_other["data"]["entry"]=1;rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
bad_other=other_read;bad_other["meta"]["stateRevision"]="42";rejects([&]{engine_other_projection(report_bundle,other_index,bad_other,"cup-view:0:0",1);});
std::cout << "engine DTO, exact money, scope and booking tests passed\n";
return 0;
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
+51
View File
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: GPL-3.0-only
// Authored cup records exercise the existing Modern overview, without original data.
#include "modern/content/ui_contract.hpp"
#include "modern/content/projections.hpp"
#include "modern/game/cup.hpp"
#include "formats/executable_layout.hpp"
#include "formats/textd.hpp"
#include <iostream>
#include <stdexcept>
using namespace bmh;
namespace {
using J=cli::Json;using O=J::Object;
const J& at(const J& j,const char* k){return j.object()->at(k);}
void check(bool yes,const char* why){if(!yes)throw std::runtime_error(why);}
}
int main() try {
modern::ModernState g;g.manager_teams={0};g.manager_records.resize(0xb0c);g.display_start_year=2026;
g.memory.add_block(layout::CupTable,modern::kCupEntries*modern::kCupEntrySize);
g.memory.add_block(layout::ActiveSelectors,8);
g.memory.add_block(layout::SyntheticCupParticipantsBegin,0x100);
g.memory.add_block(layout::SyntheticCupResultsBegin,0x100);
for(int i=0;i<modern::kCupEntries;++i){g.memory.set16(modern::cup_entry_address(i)+0x18,0xffff);g.memory.set8(modern::cup_entry_address(i)+0x15,0xff);}
for(int i=0;i<8;++i)g.memory.set8(layout::ActiveSelectors+i,0x14);
g.memory.set8(layout::ActiveSelectors,0);g.memory.set8(layout::ActiveSelectors+1,1);
g.club_ids.resize(4);g.club_names.resize(8);g.world_club_id.resize(4);g.world_club_name.resize(4);
for(int i=0;i<4;++i){g.club_ids[i]=i*2;g.club_names[i*2]='A'+i;g.world_club_id[i]="club:"+std::to_string(i);g.world_club_name[i]="Synthetic "+std::to_string(i);g.memory.set16(layout::SyntheticCupParticipantsBegin+i*2,i);}
g.squad_slots.resize(4000,kEmptySlot);g.team_morale.resize(500);
const auto descriptor=[&](int entry,int comp,int teams,int rounds,int flags){auto a=modern::cup_entry_address(entry);g.memory.set_pointer(a,layout::SyntheticCupParticipantsBegin);g.memory.set_pointer(a+0x0c,layout::SyntheticCupResultsBegin+entry*16);g.memory.set16(a+0x18,comp);g.memory.set8(a+0x14,flags);g.memory.set8(a+0x1a,teams);g.memory.set8(a+0x1b,rounds);};
descriptor(0,0,4,2,4);descriptor(1,1,2,1,5);
g.memory.set16(layout::SyntheticCupResultsBegin,0x41);g.memory.set16(layout::SyntheticCupResultsBegin+2,0xcccc);
g.memory.set16(layout::SyntheticCupResultsBegin+16,0x400|0x21);
g.memory.set_pointer(modern::cup_entry_address(1)+0x10,layout::SyntheticCupResultsBegin+32);g.memory.set16(layout::SyntheticCupResultsBegin+32,0x800|0x62);g.memory.set8(modern::cup_entry_address(1)+0x1d,1);
TextDb texts;texts.strings.resize(1200);for(size_t i=567;i<620;++i)texts.strings[i]="Synthetic round";g.texts=&texts;
modern::UiContext c;c.manager=0;c.state_revision=9;
const auto read=[&](const char* view,int round){return modern::ui_read(g,c,O{{"kind","other-fixtures"},{"viewId",view},{"round",round}});};
const auto index=modern::ui_read(g,c,O{{"kind","other-index"}});check(at(at(index,"data"),"views").array()->size()==2,"active cup index differs");
const auto first=read("cup-view:0:0",1);const auto &m=*at(at(first,"data"),"matches").array();check(m.size()==2,"full first round missing");check(*at(m[0],"status").string()=="played"&&*at(m[0],"result").array()->at(0).integer()==2,"score changed");check(std::holds_alternative<std::nullptr_t>(at(m[1],"result").value),"open fixture has invented score");
const auto future=read("cup-view:0:0",2);check(!std::get<bool>(at(at(future,"data"),"available").value)&&at(at(future,"data"),"matches").array()->empty(),"future draw invented");
const auto legs=read("cup-view:1:0",1);const auto &leg=at(at(legs,"data"),"matches").array()->at(0);check(*at(leg,"phase").integer()==1&&*at(leg,"secondLegPhase").integer()==2,"cup phases lost");check(*at(leg,"secondLeg").array()->at(0).integer()==2&&*at(leg,"secondLeg").array()->at(1).integer()==3,"second leg not oriented to displayed sides");
check(*at(read("cup-view:0:0",0),"messageType").string()=="error"&&*at(read("cup-view:0:0",3),"messageType").string()=="error","invalid cup rounds accepted");
check(*at(read("cup-view:99:0",1),"messageType").string()=="error","foreign cup accepted");
g.memory.add_block(layout::CalendarState_FormatError_RuntimeField3,2);g.memory.set16(layout::CalendarState_FormatError_RuntimeField3,10);
descriptor(2,12,2,1,4);g.memory.set8(layout::ActiveSelectors+2,12);
g.memory.set_pointer(modern::cup_entry_address(2),0);g.memory.set_pointer(modern::cup_entry_address(2)+0x0c,0);
const auto metadata=modern::ui_read(g,c,O{{"kind","other-index"}});check(at(at(metadata,"data"),"views").array()->size()==3,"metadata index accessed uninitialised row arrays");
g.memory.set_pointer(modern::cup_entry_address(2),layout::SyntheticCupParticipantsBegin);g.memory.set_pointer(modern::cup_entry_address(2)+0x0c,layout::SyntheticCupResultsBegin+32);g.memory.set16(layout::SyntheticCupResultsBegin+32,5);
const auto scheduled=read("cup-view:12:0",1);const auto &planned=at(at(scheduled,"data"),"matches").array()->at(0);
check(*at(planned,"status").string()=="scheduled"&&std::holds_alternative<std::nullptr_t>(at(planned,"result").value)&&at(planned,"date").string(),"scheduled offset was decoded as score");
check(g.memory.u16(layout::SyntheticCupResultsBegin)==0x41&&g.memory.u8(layout::ActiveSelectors)==0,"pure read changed source bytes");
std::cout<<"cup index, null results, future draws, phases and reversed legs passed\n";return 0;
} catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}