Connect Almanac UI to revision-bound career history (by Codex)
This commit is contained in:
1 parent
4b6c18f654
commit
959154c3c0
18 files changed
+405
-44
No files matched your search
@@ -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 und Vereinsfreundschaftsspiele an die
|
||||
echte Modern-OBS-Karriere und bindet Schreibtisch, Trainingslager, Aufstellung, Taktik, Training, Bank, Eintrittspreis, Umfeld, Werbung, Spielerverträge, Vereinskalender, Spielverlegung, Vereins-/Nationalfreundschaftsspiele und den Almanach 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
|
||||
|
||||
@@ -38,7 +38,7 @@ Implementierung in der Spiel-Engine.
|
||||
| Bank | [Sparbuch, Immobilien, Aktien und Kredit](desktop/bank/README.md) |
|
||||
| Bilanz | [Aktuelle Bilanz und Zukunftsplanung](desktop/balance/README.md) |
|
||||
| Verträge | [Kaderdaten, Angebote, Versicherung und Prämien](desktop/contracts/README.md) |
|
||||
| Almanach | [Jahreskalender, Tagespartien und historische Spielberichte](desktop/almanac/README.md) |
|
||||
| Almanach | [Echte Archivjahre, Tagespartien und historische Spielberichte](desktop/almanac/README.md) |
|
||||
| Paarungsanordnung | [Mittige Ergebnisse und innenliegende Wappen](desktop/fixtures/README.md) |
|
||||
| Berichte | [Tabellen, Stärken, Ligaspiele, übrige Spiele und Profile](desktop/reports/README.md) |
|
||||
| Freundschaftsspiele | [Vereins-/Nationalgegner, echte Angebote und bestätigte Buchungen](desktop/friendlies/README.md) |
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
Stand: 24. Oktober 2026. Dieser Vertrag beschreibt die native
|
||||
Präsentationsschnittstelle des [Almanachs](README.md). Er ist kein neues
|
||||
Engine-Speicherformat. Die gegenwärtige Quelle ist ein unveränderliches
|
||||
Pseudoarchiv; eine spätere Modern-Sessionprojektion kann denselben
|
||||
Lesevertrag bedienen.
|
||||
Engine-Speicherformat. Die separate Demo verwendet ein unveränderliches
|
||||
Pseudoarchiv. Seit 28. Oktober 2026 bedient auch die tatsächliche Modern-Session
|
||||
diesen Lesevertrag im echten Engine-Einstieg.
|
||||
|
||||
## Besitz und Lesezugriff
|
||||
|
||||
@@ -20,7 +20,27 @@ Ergebniskopien zurück und verändern weder Archiv noch Revision,
|
||||
Änderungsmarkierung, Geld oder RNG. Die App hält ihre Navigation nur in
|
||||
flüchtigen Feldern. Das Laden eines UI-Demostands ändert den
|
||||
Abfragestichtag, importiert aber kein Enginearchiv. Bestehende `.obs`-
|
||||
Dateien und F10-Daten werden von diesem Paket weder gelesen noch geändert.
|
||||
Dateien und F10-Daten werden von dieser Demoquelle weder gelesen noch geändert.
|
||||
|
||||
### Tatsächliche Sessionquelle
|
||||
|
||||
`ModernSession::ui_read({kind:"almanac",query:<Request>})` kapselt
|
||||
`query_almanac` und liefert die normale Snapshot-Hülle mit `data.kind`,
|
||||
`data.query` und `data.result`. Die UI validiert Karriere, Welt, Datenrevision,
|
||||
Manager, Spielstandsrevision, Abfrageidentität und gespeicherte Datumswerte.
|
||||
Sie lädt die vier Anfragearten bei Bedarf über den seriellen Worker. Der
|
||||
begrenzte Cache wird bei einem geänderten Kontext verworfen; er wird nicht in
|
||||
den Spielstand geschrieben. Die Datenquelle sind hier die tatsächlichen
|
||||
Almanachaufzeichnungen im OBS, einschließlich der von der Engine verfügbaren
|
||||
abgeschlossenen Saisons. Es gibt keinen Import des Pseudoarchivs in eine OBS.
|
||||
|
||||
Die archivierten Namen und Aufstellungen werden unverändert übernommen.
|
||||
Fehlende Positionen bleiben unbekannt. Ein Enginebefund zu widersprüchlichen
|
||||
Phasenangaben ist als #18 erfasst. Die UI kennzeichnet ein gemeldetes,
|
||||
entschiedenes Elfmeterschießen mit gleichem Heim-/Auswärtswert als unklare
|
||||
Phasenüberlieferung und zeigt den gelieferten Endstand. Sie rekonstruiert kein
|
||||
Ersatzresultat. Die folgenden Demo-Validierungsdetails bleiben für den
|
||||
getrennten `DemoSource` gültig.
|
||||
|
||||
## Requests und Antworten
|
||||
|
||||
|
||||
@@ -16,6 +16,63 @@ Native Quellen sind
|
||||
[demo_almanac.hpp](../../../../src/modern/ui/demo_almanac.hpp) und
|
||||
[demo_almanac.cpp](../../../../src/modern/ui/demo_almanac.cpp).
|
||||
|
||||
## Echter Engineanschluss · 28. Oktober 2026
|
||||
|
||||
Aufbauend auf `0.3` / `4b6c18f` ist der vorhandene Almanach-Presenter an die
|
||||
abgeschlossenen Spiele der geladenen Modern-Karriere angebunden. Der Read
|
||||
`almanac` kapselt die bestehende `query_almanac`-Projektion in dieselbe
|
||||
Karriere-/Welt-/Manager-/Revisionshülle wie die anderen Engineansichten:
|
||||
|
||||
```json
|
||||
{"kind":"almanac","query":{"kind":"index"}}
|
||||
{"kind":"almanac","query":{"kind":"calendar","year":2026}}
|
||||
{"kind":"almanac","query":{"kind":"day","date":"2026-08-08"}}
|
||||
{"kind":"almanac","query":{"kind":"match","id":"match:2026-167"}}
|
||||
```
|
||||
|
||||
`data.query` wiederholt die gebundene Abfrage; `data.result` enthält die
|
||||
bestehende Archivantwort. Es werden keine Spiele, Statistiken oder Ereignisse
|
||||
im Client erzeugt. Die bisherige Präsentationsdemo bleibt eine eigene Quelle.
|
||||
|
||||
Der Schreibtisch öffnet den Kalender des neuesten vorhandenen Kalenderjahrs.
|
||||
Der Jahrpicker zeigt die tatsächlich archivierten Jahre. Nur Tage mit
|
||||
abgeschlossenen Partien sind anklickbar. Daraus führen die Tagespaarungen mit
|
||||
mittigem Ergebnis zum vollständigen Spielbericht, seinen Aufstellungen und
|
||||
Ereignissen. „Zurück“ und Escape gehen genau eine Ebene zurück; das X schließt
|
||||
das Fenster. Lange Tageslisten sind auch per Tab/Enter erreichbar. Der Fokus
|
||||
auf einer Partie scrollt diese beim Zurückgehen wieder ins Sichtfeld; die
|
||||
Ergebnisspalte bleibt mittig trotz Scrollbalken.
|
||||
|
||||
Die Bridge fragt ausschließlich bei Bedarf auf ihrem seriellen Hintergrund-
|
||||
Worker ab. Die UI hält höchstens je einen Index, Jahreskalender, Spieltag und
|
||||
Detailbericht. Wiederholtes Öffnen derselben Ansicht verwendet diesen Cache.
|
||||
Ein geänderter Karriere-/Welt-/Manager-/Revisionskontext verwirft den Cache.
|
||||
Der Renderer liest keine Session und veröffentlicht keine veraltete Antwort.
|
||||
Ein leeres Archiv zeigt das aktuelle Karrierejahr ohne erfundene Spieltage.
|
||||
|
||||
Historische Namen, Manager, Aufstellungen und Ereignisse stammen aus dem
|
||||
Archiv. Unbekannte Positionen werden nicht aus dem heutigen Kader ergänzt.
|
||||
Vorhandene Wappen werden ausschließlich anhand stabiler Vereins-IDs aus der
|
||||
aktiven Welt aufgelöst; das ist kein historisches Grafikarchiv. Der gemeinsame
|
||||
Wappenpfad unterstützt dabei den Silver-Kontrastfix.
|
||||
|
||||
Beim tatsächlichen Anschluss wurde [Engine-Issue #18](https://github.com/Weyoune/openbmh/issues/18)
|
||||
gefunden: einzelne abgeschlossene Datensätze melden ein Elfmeterschießen mit
|
||||
0:0. Der Presenter zeigt bei solchen widersprüchlichen Angaben den gelieferten
|
||||
Endstand und „Spielphasen nicht eindeutig überliefert“. Er erfindet weder
|
||||
Elfmeterschüsse noch eine Ersatzentscheidung. Die unveränderten Rohdaten
|
||||
bleiben im Prüfbeleg erhalten; der Recorder/Engine-Read muss separat geprüft
|
||||
werden. Andere gelieferte Phasenwerte werden ohne neue Spielregeln dargestellt.
|
||||
|
||||
Öffnen, Jahrwechsel, Navigation und Speichern verändern keine Archivspiele
|
||||
oder RNG-Zustände. Die private QA enthält einen regulär erzeugten OBS-Stand
|
||||
mit 1.965 Spielen über 2026/2027, tatsächliche Rohantworten, Neustartprüfungen,
|
||||
leere Archive und Aufnahmen in drei Themes:
|
||||
`bmh_4k_ui/docs/qa/engine-almanac-2026-10-28/`. Die native Laufzeitprüfung läuft
|
||||
unter Linux; Windows-/macOS-Ausführung wurde nicht durchgeführt.
|
||||
|
||||
Die folgenden Abschnitte beschreiben weiterhin die **getrennte Demoquelle**.
|
||||
|
||||
## Drei Ansichtsebenen
|
||||
|
||||
Das Desktop-Icon „Almanach“ öffnet zunächst den **Jahreskalender**.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
# Nativer Engine-Einstieg: Schreibtisch, Trainingslager, Aufstellung und Vorbereitung
|
||||
# Nativer Engine-Einstieg: Schreibtisch, Vereins-/Nationalplanung und Archiv
|
||||
|
||||
Der opt-in Einstieg lädt eine bestehende Modern-Karriere aus einer OBS-Datei.
|
||||
Er ist ein erster vertikaler Integrationsschritt, kein vollständiger spielbarer
|
||||
@@ -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`; parameterisierte Angebote über `friendly`. Karriere, Manager,
|
||||
- `ModernSession::ui_read`: `session`, `desktop`, `camps`, `squad`, `lineup`, `tactics`, `training`, `bank`, `stadium`, `credit`, `environment`, `advertising`, `contracts`, `calendar`, `scheduling`, `friendly-plan`; 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
|
||||
@@ -258,3 +258,20 @@ ab; reale Teststände werden über die OBS-Speicheraktion erzeugt.
|
||||
Die privaten Bilder, Eingangsspielstände und Replaybefehle liegen unter
|
||||
`bmh_4k_ui/docs/qa/engine-entry-2026-10-27/`. Plattformgrenzen stehen im dortigen
|
||||
Prüfbericht; ein CI-Build ist keine interaktive Windows-/macOS-Abnahme.
|
||||
|
||||
## Almanach · 28. Oktober 2026
|
||||
|
||||
Der bestehende Almanach-Presenter liest nun abgeschlossene Partien der echten
|
||||
Karriere über `ui_read {kind: "almanac", query: ...}`. Index, Jahreskalender,
|
||||
Tagespaarungen und Spielbericht werden bei Bedarf auf dem seriellen Worker
|
||||
abgefragt und an Karriere, Welt, Manager und Revision gebunden. Die UI hält
|
||||
höchstens einen Index, Kalender, Tag und Detailbericht. Es gibt keine
|
||||
zusätzlichen Almanachabfragen in jedem Schreibtisch-Snapshot.
|
||||
|
||||
Archivierte Namen, Aufstellungen, Ereignisse und Phasenwerte ersetzen die
|
||||
bisherigen Dummydaten im echten Einstieg. Unsichere Phasenangaben aus dem
|
||||
festgestellten Engine-Befund #18 sind gekennzeichnet; es werden keine Tore oder
|
||||
Entscheidungen rekonstruiert. Vorhandene Wappen kommen über die stabile
|
||||
Vereins-ID aus der aktiven Welt. Das Speichern als neue OBS erhält die bereits
|
||||
aufgezeichneten Archivbytes und beide RNGs. Einzelheiten und private QA stehen
|
||||
im [Almanach-Menüdokument](../desktop/almanac/README.md).
|
||||
@@ -428,6 +428,16 @@ 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 == "almanac") {
|
||||
const J* query = field(request, "query");
|
||||
if (!query || !query->object())
|
||||
return failure(request_id, "invalid_almanac_request", "Eine Almanachabfrage wird benötigt.", c.state_revision);
|
||||
J result = query_almanac(g, *query);
|
||||
const J* ok = field(result, "ok");
|
||||
if (!ok || !std::holds_alternative<bool>(ok->value) || !std::get<bool>(ok->value))
|
||||
return failure(request_id, text_field(result, "error").c_str(), "Der Spielarchiv-Eintrag ist nicht verfügbar.", c.state_revision);
|
||||
return snapshot(request_id, std::move(m), O{{"kind", "almanac"}, {"query", *query}, {"result", std::move(result)}});
|
||||
}
|
||||
if (kind == "news") {
|
||||
// the press events of a team (teamId, default the desk's team) from `from` to `until` (ISO,
|
||||
// default everything up to today), newest last, at most `limit` (default 50) of the newest
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
bool App::almanac_action(const std::string &action, Rml::Element *target) {
|
||||
if (!action.starts_with("alm-")) return false;
|
||||
if (engine_mode_) return engine_almanac_action(action,target);
|
||||
if (menu_ != "almanac" || !source_) return true;
|
||||
const auto id = target ? target->GetAttribute<Rml::String>("data-id", "") : "";
|
||||
if (action == "alm-year-cancel" || (action == "alm-back" && report_picker_ == "year")) {
|
||||
|
||||
@@ -74,6 +74,11 @@ std::string almanac_competition_label(const Json &record) {
|
||||
(almanac_text(almanac_field(competition, "type"), "") == "league"
|
||||
? "Spieltag" : "Runde");
|
||||
}
|
||||
bool almanac_phases_known(const Json &result) {
|
||||
if(!almanac_flag(result,"penalties_played"))return true;
|
||||
const auto &score=almanac_field(result,"penalties");
|
||||
return score.is_array()&&score.size()==2&&score[0].is_number_integer()&&score[1].is_number_integer()&&score[0]!=score[1];
|
||||
}
|
||||
std::string almanac_event_kind(const std::string &kind) {
|
||||
if (kind == "goal") return "Tor";
|
||||
if (kind == "miss") return "Fehlschuss";
|
||||
@@ -90,7 +95,7 @@ std::string almanac_event_kind(const std::string &kind) {
|
||||
std::string App::render_almanac() {
|
||||
const auto query = [&](const Json &request) -> Json {
|
||||
try {
|
||||
return source_ ? source_->read_almanac(request)
|
||||
return engine_mode_ ? engine_almanac_read(request) : source_ ? source_->read_almanac(request)
|
||||
: Json{{"ok", false}, {"error", "almanac_unavailable"}};
|
||||
} catch (const std::exception &) {
|
||||
return {{"ok", false}, {"error", "almanac_unavailable"}};
|
||||
@@ -106,8 +111,7 @@ std::string App::render_almanac() {
|
||||
years.push_back(value.get<int>());
|
||||
std::sort(years.begin(), years.end());
|
||||
years.erase(std::unique(years.begin(), years.end()), years.end());
|
||||
const auto snapshot = snap();
|
||||
const auto &reference = almanac_field(snapshot.state, "date");
|
||||
const auto reference = engine_mode_ ? engine_data_.at("desktop").at("meta").at("date") : snap().state.at("date");
|
||||
const auto date = almanac_date_parts(reference);
|
||||
if (almanac_year_ == 0 ||
|
||||
std::find(years.begin(), years.end(), almanac_year_) == years.end()) {
|
||||
@@ -140,11 +144,12 @@ std::string App::render_almanac() {
|
||||
: day_view ? almanac_date_label(almanac_day_)
|
||||
: "Spielarchiv" + (almanac_year_ ? " · " + std::to_string(almanac_year_) : "");
|
||||
const auto crest_image = [&](const Json &team, double size) {
|
||||
const auto &key = almanac_field(team, "crest");
|
||||
auto key = almanac_field(team, "crest");
|
||||
if (engine_mode_ && key.is_null()) if (const auto *club = world_->find("clubs", almanac_text(almanac_field(team,"id"),""))) key=club->value("crest",Json());
|
||||
return "<div class=\"alm-crest\" style=\"width:" + scalar(size) +
|
||||
"dp;height:" + scalar(size) + "dp;\">" +
|
||||
(key.is_string() && !key.get_ref<const std::string &>().empty()
|
||||
? img(key.get<std::string>(), size, size, true)
|
||||
? picture(renderer_.crest(key.get<std::string>(), theme_ == "silver"),size,size)
|
||||
: "<span class=\"alm-no-crest\">—</span>") + "</div>";
|
||||
};
|
||||
const auto team_label = [&](const Json &team, bool home) {
|
||||
@@ -176,7 +181,8 @@ std::string App::render_almanac() {
|
||||
for (size_t i = 0; i < matches.size(); ++i) {
|
||||
const auto &match = matches[i], &result = almanac_field(match, "result");
|
||||
const auto id = almanac_text(almanac_field(match, "id"), "");
|
||||
const bool penalties = almanac_flag(result, "penalties_played"), extra = almanac_flag(result, "extra_played");
|
||||
const bool known=almanac_phases_known(result);
|
||||
const bool penalties = known && almanac_flag(result, "penalties_played"), extra = known && almanac_flag(result, "extra_played");
|
||||
const auto description = almanac_name(almanac_field(match, "home")) + " " +
|
||||
almanac_score(almanac_field(result, "final")) + " " +
|
||||
almanac_name(almanac_field(match, "away")) + " · Spielbericht öffnen";
|
||||
@@ -186,7 +192,7 @@ std::string App::render_almanac() {
|
||||
"<div class=\"alm-row-score alm-list-score\"><span class=\"alm-list-score-value\">" +
|
||||
esc(almanac_score(almanac_field(result, penalties ? "penalties" : "final"))) +
|
||||
"</span><span class=\"alm-list-score-phase\">" +
|
||||
(penalties ? "i. E." : extra ? "n. V." : "") + "</span></div>"
|
||||
(!known ? "unklar" : penalties ? "i. E." : extra ? "n. V." : "") + "</span></div>"
|
||||
"<div class=\"alm-row-away\">" + team_label(almanac_field(match, "away"), false) +
|
||||
"</div></div><div class=\"alm-match-meta\"><span>" +
|
||||
esc(almanac_competition_label(match) + " · Saison " +
|
||||
@@ -260,11 +266,13 @@ std::string App::render_almanac() {
|
||||
} else {
|
||||
const auto &result = almanac_field(record, "result"), &weather = almanac_field(record, "weather");
|
||||
const bool extra = almanac_flag(result, "extra_played"), penalties = almanac_flag(result, "penalties_played");
|
||||
const auto phase = std::string(extra ? "Nach Verlängerung" : "Nach regulärer Spielzeit") +
|
||||
const bool known=almanac_phases_known(result);
|
||||
const auto phase = !known ? std::string("Endstand") : std::string(extra ? "Nach Verlängerung" : "Nach regulärer Spielzeit") +
|
||||
(penalties ? " · Entscheidung i. E." : "");
|
||||
std::string phases = "Reguläre Zeit: " + almanac_score(almanac_field(result, "regulation"));
|
||||
if (extra) phases += " · Verlängerung: " + almanac_score(almanac_field(result, "extra"));
|
||||
if (penalties) phases += " · i. E.: " + almanac_score(almanac_field(result, "penalties"));
|
||||
if (!known) phases="Spielphasen nicht eindeutig überliefert.";
|
||||
output += "<section class=\"alm-summary\"><div class=\"alm-summary-teams\">";
|
||||
const auto summary_team = [&](const char *side, const std::string &css) {
|
||||
const auto &team = almanac_field(record, side), &manager = almanac_field(team, "manager");
|
||||
@@ -390,3 +398,16 @@ std::string App::render_almanac() {
|
||||
output += btn("alm-year-cancel", "", "alm-picker-shield", "id=\"alm-year-shield\" aria-label=\"Jahresauswahl schließen\"");
|
||||
return output + "</div>";
|
||||
}
|
||||
|
||||
bool App::almanac_layout_update() {
|
||||
if (auto *history=element("alm-day-list")) if (auto *content=doc_->QuerySelector(".window .content")) {
|
||||
const float width=content->GetBox().GetSize(Rml::BoxArea::Content).x;
|
||||
if(std::abs(width-almanac_list_width_)>=.001f) {
|
||||
almanac_list_width_=width;history->SetProperty("width",scalar(width)+"px");
|
||||
Rml::ElementList rows;history->QuerySelectorAll(rows,".alm-list-head,.alm-match-row");
|
||||
for(auto *row:rows)row->SetProperty("width",scalar(width)+"px");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
void App::engine_almanac_sync() {
|
||||
const auto &meta=engine_data_.at("desktop").at("meta");
|
||||
if(meta==engine_almanac_context_)return;
|
||||
engine_almanac_context_=meta;engine_almanac_cache_=Json::object();
|
||||
almanac_year_=0;almanac_day_.clear();almanac_match_.clear();almanac_tab_="lineups";
|
||||
}
|
||||
Json App::engine_almanac_read(const Json &query) const {
|
||||
if(engine_almanac_context_==engine_data_.at("desktop").at("meta")) {
|
||||
const auto it=engine_almanac_cache_.find(engine_almanac_key(query));
|
||||
if(it!=engine_almanac_cache_.end())return *it;
|
||||
}
|
||||
return {{"ok",false},{"error","almanac_not_loaded"}};
|
||||
}
|
||||
void App::engine_almanac_select(const Json &query) {
|
||||
const auto kind=query.at("kind").get<std::string>();
|
||||
const auto data=engine_almanac_read(query);
|
||||
if(!data.value("ok",false))return;
|
||||
if(kind=="calendar") {
|
||||
almanac_year_=query.at("year");almanac_day_.clear();almanac_match_.clear();almanac_tab_="lineups";
|
||||
focus_after_render_="report-picker-year";
|
||||
} else if(kind=="day") {
|
||||
almanac_day_=query.at("date");almanac_match_.clear();almanac_tab_="lineups";focus_after_render_="alm-heading";
|
||||
} else if(kind=="match") {
|
||||
if(data.at("match").at("date")!=almanac_day_)throw editor::Error("Spielbericht gehört einem anderen Archivtag.");
|
||||
almanac_match_=query.at("id");almanac_tab_="lineups";focus_after_render_="alm-heading";
|
||||
}
|
||||
close_report_picker(false);refresh();
|
||||
}
|
||||
void App::engine_almanac_load(const Json &query) {
|
||||
if(engine_busy_||!engine_fresh_)return;
|
||||
if(engine_almanac_read(query).value("ok",false)){engine_almanac_select(query);refresh();return;}
|
||||
auto link=engine_link_;
|
||||
engine_start("Spielarchiv wird geladen …",[link,query] {
|
||||
const auto bundle=link->snapshot();
|
||||
Json queries=Json::array({query}),reads=Json::array({link->read({{"kind","almanac"},{"query",query}})});
|
||||
if(query.at("kind")=="index"&&reads[0].value("messageType","")=="snapshot") {
|
||||
const auto index=engine_almanac_projection(bundle,reads[0],query);
|
||||
const int year=index.at("years").empty()?std::stoi(bundle.at("desktop").at("meta").at("date").get<std::string>().substr(0,4)):index.at("years").back().get<int>();
|
||||
const Json calendar={{"kind","calendar"},{"year",year}};
|
||||
queries.push_back(calendar);reads.push_back(link->read({{"kind","almanac"},{"query",calendar}}));
|
||||
}
|
||||
return EngineReply{link,bundle,{{"messageType","almanac_preview"},{"queries",queries},{"reads",reads}},nullptr};
|
||||
});
|
||||
}
|
||||
void App::engine_almanac_poll(const EngineReply &reply) {
|
||||
if(reply.bundle.at("desktop").at("meta")!=engine_almanac_context_)
|
||||
throw editor::Error("Der Archivkontext hat sich geändert. Bitte das Archiv erneut öffnen.");
|
||||
const auto &queries=reply.response.at("queries"),&reads=reply.response.at("reads");
|
||||
if(queries.empty()||queries.size()!=reads.size())throw editor::Error("Unvollständige Archivantwort.");
|
||||
auto cache=engine_almanac_cache_;
|
||||
for(size_t i=0;i<queries.size();++i) {
|
||||
if(reads[i].value("messageType","")=="error") {
|
||||
engine_notice_=engine_text(reads[i].value("message",Json()));
|
||||
if(engine_notice_.empty()||engine_notice_=="—")engine_notice_="Das Spielarchiv ist derzeit nicht verfügbar.";
|
||||
return;
|
||||
}
|
||||
const auto result=engine_almanac_projection(reply.bundle,reads[i],queries[i]);
|
||||
const auto key=engine_almanac_key(queries[i]);
|
||||
// Keep one index, calendar, day and detail. Back navigation is immediate;
|
||||
// opening many seasons cannot accumulate entire archives in UI memory.
|
||||
const auto kind=queries[i].at("kind").get<std::string>();
|
||||
for(auto it=cache.begin();it!=cache.end();) {
|
||||
if(it.key()==kind||it.key().starts_with(kind+":"))it=cache.erase(it);else ++it;
|
||||
}
|
||||
cache[key]=result;
|
||||
}
|
||||
if(queries.back().at("kind")=="match"&&cache.at(engine_almanac_key(queries.back())).at("match").at("date")!=almanac_day_)
|
||||
throw editor::Error("Spielbericht gehört einem anderen Archivtag.");
|
||||
engine_almanac_cache_=std::move(cache);
|
||||
engine_notice_="Spielarchiv geladen.";
|
||||
if(menu_=="almanac")engine_almanac_select(queries.back());
|
||||
}
|
||||
bool App::engine_almanac_action(const std::string &action,Rml::Element *target) {
|
||||
if(!action.starts_with("alm-"))return false;
|
||||
if(menu_!="almanac"||engine_busy_||!engine_fresh_)return true;
|
||||
const auto id=target?target->GetAttribute<Rml::String>("data-id",""):std::string();
|
||||
if(action=="alm-year-cancel"||(action=="alm-back"&&report_picker_=="year")){close_report_picker(true);return true;}
|
||||
if(action=="alm-back") {
|
||||
if(!almanac_match_.empty()){focus_after_render_="alm-match-"+almanac_match_;almanac_match_.clear();}
|
||||
else if(!almanac_day_.empty()){focus_after_render_="alm-day-"+almanac_day_;almanac_day_.clear();}
|
||||
else{menu_.clear();focus_after_render_="object-app-almanac";}
|
||||
} else if(action=="alm-day") {
|
||||
const auto calendar=engine_almanac_read({{"kind","calendar"},{"year",almanac_year_}});
|
||||
if(calendar.value("ok",false))for(const auto &d:calendar.at("days"))if(d.at("date")==id){engine_almanac_load({{"kind","day"},{"date",id}});break;}
|
||||
return true;
|
||||
} else if(action=="alm-match") {
|
||||
const auto day=engine_almanac_read({{"kind","day"},{"date",almanac_day_}});
|
||||
if(day.value("ok",false))for(const auto &m:day.at("matches"))if(m.at("id")==id){engine_almanac_load({{"kind","match"},{"id",id}});break;}
|
||||
return true;
|
||||
} else if(action=="alm-tab") {
|
||||
if(almanac_match_.empty()||(id!="lineups"&&id!="events"))return true;
|
||||
almanac_tab_=id;focus_after_render_="alm-tab-"+id;
|
||||
} else return false;
|
||||
close_report_picker(false);refresh();return true;
|
||||
}
|
||||
@@ -47,6 +47,10 @@ Json engine_friendly_plan(const Json &bundle);
|
||||
Json engine_friendly_projection(const Json &bundle, const Json &read, const std::string &opponent, bool home);
|
||||
Json engine_friendly_command(const Json &bundle, const Json &read, const std::string &opponent, bool home, const std::string &date, bool accept_cost, bool opponent_consent, const std::string &request_id);
|
||||
|
||||
// Archive requests and immutable replies; no live-roster or current-name fallback.
|
||||
std::string engine_almanac_key(const Json &query);
|
||||
Json engine_almanac_projection(const Json &bundle, const Json &read, const Json &query);
|
||||
|
||||
// Single-session facade. Its owner serializes all calls on a background worker.
|
||||
// No RmlUI objects or callbacks cross this boundary.
|
||||
class EngineBridge {
|
||||
|
||||
@@ -12,6 +12,7 @@ void App::engine_poll() {
|
||||
try {
|
||||
auto result = engine_job_.get();
|
||||
validate_engine_desk(result.bundle);
|
||||
if(result.response.value("messageType","")=="almanac_preview"){engine_almanac_poll(result);refresh();return;}
|
||||
if (result.response.value("messageType", "") == "friendly_preview") {
|
||||
const auto &read = result.response.at("read");
|
||||
if (read.value("messageType", "") == "error") {
|
||||
@@ -52,6 +53,7 @@ void App::engine_poll() {
|
||||
} else engine_notice_ = "Spielstand geladen · Weitere Menüs werden schrittweise angebunden.";
|
||||
if (engine_response_.value("messageType", "") == "command_result") { advertising_selected_ = -1; advertising_offer_ = 0; }
|
||||
engine_credit_ = engine_data_.value("credit", Json()); engine_credit_edits_ = Json::array();
|
||||
engine_almanac_sync();
|
||||
engine_ticket_bind();
|
||||
engine_contracts_poll();
|
||||
engine_calendar_sync();
|
||||
@@ -71,6 +73,7 @@ void App::engine_frame() {
|
||||
engine_sports_update();
|
||||
if (ticket_) ticket_->update();
|
||||
render_popup(); context_->Update();
|
||||
if(almanac_layout_update())context_->Update();
|
||||
if (rendered && menu_ == "friendlies") if (auto *list = element("friendly-opponents")) list->SetScrollTop(engine_friendly_scroll_);
|
||||
if (menu_ == "contracts" && engine_contract_scroll_) {
|
||||
if (auto *roster = element("contracts-roster-scroll")) roster->SetScrollTop(*engine_contract_scroll_);
|
||||
@@ -82,7 +85,13 @@ void App::engine_frame() {
|
||||
lineup_roster_scroll_.reset();
|
||||
}
|
||||
if (!engine_busy_ && popup_.empty() && !focus_after_render_.empty()) {
|
||||
if (auto *node = element(focus_after_render_)) node->Focus(keyboard_navigation_);
|
||||
if (auto *node = element(focus_after_render_)) {
|
||||
node->Focus(keyboard_navigation_);
|
||||
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);
|
||||
}
|
||||
}
|
||||
focus_after_render_.clear();
|
||||
}
|
||||
if (amount_select_all_) {
|
||||
@@ -126,7 +135,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (!engine_busy_ && advertising_event(event)) return;
|
||||
if (!engine_busy_ && popup_.empty() && contracts_event(event)) return;
|
||||
if (!engine_busy_ && popup_.empty() && engine_friendly_event(event)) return;
|
||||
if (!engine_busy_ && planning_dialog_.empty() && popup_.empty() && menu_ == "friendlies" && report_picker_event(event)) return;
|
||||
if (!engine_busy_ && planning_dialog_.empty() && popup_.empty() && (menu_ == "friendlies" || menu_ == "almanac") && 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())
|
||||
@@ -151,8 +160,10 @@ void App::engine_event(Rml::Event &event) {
|
||||
}
|
||||
}
|
||||
if (type == "keydown" && event.GetParameter<int>("key_identifier", 0) == Rml::Input::KI_ESCAPE) {
|
||||
if (menu_ == "almanac" && engine_busy_) { event.StopImmediatePropagation(); return; }
|
||||
if (!popup_.empty()) { popup_.clear(); confirm_ = {}; dirty_ = true; }
|
||||
else if (!engine_busy_ && !engine_player_.empty()) { focus_after_render_ = "lineup-detail-" + engine_player_ + "-0"; engine_player_.clear(); refresh(); }
|
||||
else if (!engine_busy_ && menu_ == "almanac") engine_almanac_action("alm-back",nullptr);
|
||||
else if (!engine_busy_ && !menu_.empty()) { if (menu_ == "training" || menu_ == "tactics") engine_sports_reset(); menu_.clear(); refresh(); }
|
||||
else engine_quit();
|
||||
event.StopImmediatePropagation(); return;
|
||||
@@ -165,7 +176,12 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (!controls.empty()) {
|
||||
const auto found = std::find(controls.begin(), controls.end(), context_->GetFocusElement());
|
||||
const int index = found == controls.end() ? -1 : int(found - controls.begin());
|
||||
controls[size_t((index + int(controls.size()) + (event.GetParameter<int>("shift_key", 0) ? -1 : 1)) % int(controls.size()))]->Focus(true);
|
||||
auto *next=controls[size_t((index + int(controls.size()) + (event.GetParameter<int>("shift_key", 0) ? -1 : 1)) % int(controls.size()))];
|
||||
next->Focus(true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
event.StopImmediatePropagation(); return;
|
||||
}
|
||||
@@ -189,8 +205,9 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (action == "popup-confirm") { auto callback = std::move(confirm_); popup_.clear(); dirty_ = true; if (callback) callback(); }
|
||||
return;
|
||||
}
|
||||
if (almanac_action(action,node)) return;
|
||||
if (engine_friendly_action(action, node)) return;
|
||||
if (menu_ == "friendlies" && report_picker_action(action,node)) return;
|
||||
if ((menu_ == "friendlies" || menu_ == "almanac") && 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;
|
||||
@@ -204,6 +221,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 == "almanac") { menu_=id;engine_almanac_sync();engine_almanac_load({{"kind","index"}}); }
|
||||
else if (action == "engine-open" && id == "friendlies") { menu_ = id; planning_dialog_.clear(); engine_friendly_sync(); refresh(); }
|
||||
else if (action == "engine-open" && (id == "calendar" || id == "postpone")) { menu_ = id; engine_move_id_.clear(); engine_calendar_sync(); refresh(); }
|
||||
else if (action == "engine-open" && id == "contracts") { menu_ = id; engine_contracts_clear(false); contracts_player_.clear(); engine_contract_scroll_ = 0.f; refresh(); }
|
||||
@@ -228,5 +246,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_}, {"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_}, {"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_}};
|
||||
}
|
||||
@@ -721,4 +721,54 @@ Json engine_friendly_command(const Json &bundle,const Json &read,const std::stri
|
||||
const auto &dates=quote.at("dates");require(std::find(dates.begin(),dates.end(),Json(date))!=dates.end(),"Dieser Termin wird nicht mehr angeboten.");
|
||||
return sports_command(bundle,"friendly.book",{{"opponentId",opponent},{"home",home},{"date",date},{"acceptCost",true},{"opponentConsent",!quote.at("other_manager").is_null()&&consent}},request_id);
|
||||
}
|
||||
std::string engine_almanac_key(const Json &query) {
|
||||
require(query.is_object(),"Ungültige Archivabfrage.");
|
||||
const auto kind=query.at("kind").get<std::string>();
|
||||
if(kind=="index")return kind;
|
||||
if(kind=="calendar")return kind+":"+std::to_string(whole_in_range(query.at("year"),1,9999));
|
||||
if(kind=="day") { (void)calendar_iso_day(query.at("date"));return kind+":"+query.at("date").get<std::string>(); }
|
||||
if(kind=="match") {const auto id=query.at("id").get<std::string>();require(!id.empty()&&id.size()<=512,"Ungültige Archivspiel-ID.");return kind+":"+id;}
|
||||
throw editor::Error("Unbekannte Archivabfrage.");
|
||||
}
|
||||
Json engine_almanac_projection(const Json &bundle,const Json &read,const Json &query) {
|
||||
validate_engine_desk(bundle);auto context=bundle;context["almanac"]=read;
|
||||
const auto &data=lineup_read(context,"almanac");
|
||||
const auto key=engine_almanac_key(query);
|
||||
require(engine_almanac_key(data.at("query"))==key,"Archivantwort gehört einer anderen Abfrage.");
|
||||
const auto &result=data.at("result");require(result.at("ok")==true,"Archivantwort ist nicht verfügbar.");
|
||||
const auto today=calendar_iso_day(bundle.at("desktop").at("meta").at("date"));
|
||||
const auto date=[&](const Json &v){const auto d=calendar_iso_day(v);require(d<=today,"Archiv enthält eine zukünftige Partie.");};
|
||||
const auto text=[](const Json &v){require(v.is_string()&&!v.get_ref<const std::string &>().empty(),"Archividentität oder Name fehlt.");};
|
||||
const auto score=[](const Json &v){require(v.is_array()&&v.size()==2,"Ungültiges Archiv-Ergebnis.");for(const auto &n:v)(void)whole_in_range(n,0,10000);};
|
||||
const auto record=[&](const Json &r) {
|
||||
text(r.at("id"));date(r.at("date"));text(r.at("season"));
|
||||
require(r.at("home").at("id")!=r.at("away").at("id"),"Archivpaarung spielt gegen sich selbst.");
|
||||
for(const auto *side:{"home","away"}) {
|
||||
const auto &t=r.at(side);text(t.at("id"));text(t.at("name"));
|
||||
require(t.at("manager").is_null()||t.at("manager").is_object(),"Ungültiger archivierter Manager.");
|
||||
if(t.at("manager").is_object()){text(t.at("manager").at("id"));text(t.at("manager").at("name"));}
|
||||
const auto &lineup=r.at("lineups").at(side);
|
||||
if(!lineup.is_null()) {for(const auto *part:{"starters","bench"}){require(lineup.at(part).is_array(),"Archivaufstellung fehlt.");for(const auto &p:lineup.at(part)){if(p.is_null())continue;text(p.at("id"));text(p.at("name"));}}}
|
||||
}
|
||||
const auto &scores=r.at("result");score(scores.at("final"));
|
||||
for(const auto *phase:{"regulation","extra","penalties"})if(!scores.at(phase).is_null())score(scores.at(phase));
|
||||
require(scores.at("extra_played").is_boolean()&&scores.at("penalties_played").is_boolean(),"Archiv-Spielphasen fehlen.");
|
||||
require(r.at("events").is_array(),"Archivereignisse fehlen.");
|
||||
for(const auto &e:r.at("events")){text(e.at("kind"));(void)whole_in_range(e.at("minute"),0,1000);require(e.at("side")=="home"||e.at("side")=="away","Unbekannte Ereignisseite.");for(const auto *who:{"player","other"})if(!e.at(who).is_null()){text(e.at(who).at("id"));text(e.at(who).at("name"));}}
|
||||
};
|
||||
if(key=="index") {
|
||||
const auto &years=result.at("years");require(years.is_array(),"Archivjahre fehlen.");int last=0;
|
||||
for(const auto &year:years){const int y=whole_in_range(year,1,9999);require(y>last,"Doppelte oder unsortierte Archivjahre.");last=y;}
|
||||
const int count=whole_in_range(result.at("match_count"),0,std::numeric_limits<int>::max());
|
||||
if(!count)require(years.empty()&&result.at("first_date").is_null()&&result.at("last_date").is_null(),"Unvollständiges leeres Archiv.");
|
||||
else {date(result.at("first_date"));date(result.at("last_date"));require(!years.empty()&&result.at("first_date")<=result.at("last_date"),"Ungültiger Archivzeitraum.");}
|
||||
} else if(query.at("kind")=="calendar") {
|
||||
require(result.at("year")==query.at("year")&&result.at("days").is_array(),"Archivjahr stimmt nicht überein.");std::set<std::string> seen;
|
||||
for(const auto &d:result.at("days")){date(d.at("date"));const auto iso=d.at("date").get<std::string>();require(std::stoi(iso.substr(0,4))==query.at("year").get<int>()&&seen.insert(iso).second,"Doppelter oder falsch zugeordneter Archivtag.");const int n=whole_in_range(d.at("count"),1,std::numeric_limits<int>::max());require(d.at("highlights").is_array()&&d.at("highlights").size()<=size_t(n),"Ungültige Archiv-Highlights.");std::set<std::string> ids;for(const auto &id:d.at("highlights")){text(id);require(ids.insert(id.get<std::string>()).second,"Doppelte Highlight-ID.");}}
|
||||
} else if(query.at("kind")=="day") {
|
||||
require(result.at("date")==query.at("date")&&result.at("matches").is_array(),"Archivtag stimmt nicht überein.");std::set<std::string> ids;
|
||||
for(const auto &m:result.at("matches")){record(m);require(m.at("date")==query.at("date")&&ids.insert(m.at("id").get<std::string>()).second,"Partie steht am falschen Tag oder doppelt im Archiv.");}
|
||||
} else {record(result.at("match"));require(result.at("match").at("id")==query.at("id"),"Archivantwort gehört einer anderen Partie.");}
|
||||
return result;
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -37,6 +37,7 @@ Json App::engine_camp_view() const {
|
||||
}
|
||||
void App::engine_render() {
|
||||
if (ticket_) ticket_->close(false);
|
||||
almanac_list_width_=-1.f;
|
||||
if (menu_ == "friendlies") if (auto *list = element("friendly-opponents")) engine_friendly_scroll_ = list->GetScrollTop();
|
||||
if (menu_ == "contracts") if (auto *roster = element("contracts-roster-scroll")) engine_contract_scroll_ = roster->GetScrollTop();
|
||||
if (menu_ == "lineup") {
|
||||
@@ -112,11 +113,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 == "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 == "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_=="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>";
|
||||
if (menu_ == "friendlies") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Freundschaftsspiel", friendlies_available ? render_friendlies() : "<div class=\"fill center\">Freundschaftsplanung ist derzeit nicht verfügbar.</div>") + "</div>";
|
||||
if (menu_ == "calendar") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Kalender", calendar_available ? render_calendar() : "<div class=\"fill center\">Der Saisonkalender ist derzeit nicht verfügbar.</div>") + "</div>";
|
||||
if (menu_ == "postpone") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Verlegen", scheduling_available ? render_postpone() : "<div class=\"fill center\">Die Spielverlegung ist derzeit nicht verfügbar.</div>") + "</div>";
|
||||
@@ -129,7 +131,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") && !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") && !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();
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
void engine_contracts_poll();
|
||||
void engine_contracts_clear(bool focus = true);
|
||||
void engine_contracts_close(bool focus = true);
|
||||
Json engine_almanac_context_, engine_almanac_cache_ = Json::object();
|
||||
void engine_almanac_sync();
|
||||
void engine_almanac_load(const Json &);
|
||||
void engine_almanac_select(const Json &);
|
||||
void engine_almanac_poll(const EngineReply &);
|
||||
Json engine_almanac_read(const Json &) const;
|
||||
bool engine_almanac_action(const std::string &, Rml::Element *);
|
||||
int engine_calendar_day_ = -1;
|
||||
std::string engine_move_id_, engine_calendar_season_;
|
||||
bool engine_schedule_pending_ = false;
|
||||
|
||||
@@ -25,8 +25,8 @@ App::report_picker_items(const std::string &kind) const {
|
||||
return items;
|
||||
}
|
||||
if (kind == "year") {
|
||||
if (!source_) return items;
|
||||
const auto index = source_->read_almanac({{"kind", "index"}});
|
||||
if (!source_ && !engine_mode_) return items;
|
||||
const auto index = engine_mode_ ? engine_almanac_read({{"kind","index"}}) : source_->read_almanac({{"kind", "index"}});
|
||||
if (!index.value("ok", false)) return items;
|
||||
for (const auto &year : index.at("years"))
|
||||
items.emplace_back(std::to_string(year.get<int>()), std::to_string(year.get<int>()));
|
||||
@@ -218,6 +218,8 @@ bool App::report_picker_action(const std::string &action, Rml::Element *target)
|
||||
engine_friendly_filter(kind, value);
|
||||
} else if (menu_ == "statistics") {
|
||||
statistics_picker_select(kind, value);
|
||||
} else if (kind == "year" && menu_ == "almanac" && engine_mode_) {
|
||||
engine_almanac_load({{"kind","calendar"},{"year",std::stoi(value)}});
|
||||
} else if (kind == "year" && menu_ == "almanac") {
|
||||
almanac_year_ = std::stoi(value);
|
||||
almanac_day_.clear();
|
||||
|
||||
+3
-13
@@ -787,6 +787,7 @@ class App final : public Rml::EventListener {
|
||||
bool stadium_event(Rml::Event &);
|
||||
std::string render_almanac();
|
||||
bool almanac_action(const std::string &, Rml::Element *);
|
||||
bool almanac_layout_update();
|
||||
std::string render_indoor();
|
||||
bool indoor_action(const std::string &, Rml::Element *);
|
||||
std::string training_balls(const std::string &, int, int, bool,
|
||||
@@ -1084,19 +1085,7 @@ class App final : public Rml::EventListener {
|
||||
bool changed = false;
|
||||
// History can contain every competition on one date. Keep its whole-row
|
||||
// buttons on the same centre even when the long list gains a scrollbar.
|
||||
if (auto *history = element("alm-day-list")) {
|
||||
if (auto *content = doc_->QuerySelector(".window .content")) {
|
||||
const float width = content->GetBox().GetSize(Rml::BoxArea::Content).x;
|
||||
if (std::abs(width - almanac_list_width_) >= .001f) {
|
||||
almanac_list_width_ = width;
|
||||
history->SetProperty("width", scalar(width) + "px");
|
||||
Rml::ElementList rows;
|
||||
history->QuerySelectorAll(rows, ".alm-list-head,.alm-match-row");
|
||||
for (auto *row : rows) row->SetProperty("width", scalar(width) + "px");
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
changed |= almanac_layout_update();
|
||||
auto *list = element("report-list");
|
||||
if (!list || !list->IsClassSet("match-list"))
|
||||
return changed;
|
||||
@@ -1541,6 +1530,7 @@ public:
|
||||
#include "modern/ui/engine_contracts.inc"
|
||||
#include "modern/ui/engine_calendar.inc"
|
||||
#include "modern/ui/engine_friendlies.inc"
|
||||
#include "modern/ui/engine_almanac.inc"
|
||||
} // namespace
|
||||
bool is_modern_world(const fs::path &file) {
|
||||
try {
|
||||
|
||||
@@ -10,24 +10,27 @@ using namespace bmh;
|
||||
using namespace bmh::modern_ui;
|
||||
int main(int argc, char **argv) {
|
||||
try {
|
||||
if (argc != 4 || (std::string(argv[1]) != "prepare-national" && std::string(argv[1]) != "verify-national" && std::string(argv[1]) != "inspect-friendlies" && std::string(argv[1]) != "inspect" && std::string(argv[1]) != "prepare-two" && std::string(argv[1]) != "prepare" && std::string(argv[1]) != "verify" && std::string(argv[1]) != "verify-lineup" && std::string(argv[1]) != "verify-sports" && std::string(argv[1]) != "verify-bank" && std::string(argv[1]) != "verify-commerce" && std::string(argv[1]) != "verify-contracts" && std::string(argv[1]) != "verify-calendar" && std::string(argv[1]) != "verify-friendlies")) throw std::runtime_error("usage: modern_engine_bridge_probe prepare-national|verify-national|inspect-friendlies|inspect|prepare|prepare-two|verify|verify-lineup|verify-sports|verify-bank|verify-commerce|verify-contracts|verify-calendar|verify-friendlies <world.obw> <new-output-directory>");
|
||||
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"};
|
||||
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]> <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)); };
|
||||
if (std::string(argv[1]) == "prepare-national" || std::string(argv[1]) == "prepare" || std::string(argv[1]) == "prepare-two") {
|
||||
if (mode == "prepare-almanac" || std::string(argv[1]) == "prepare-national" || std::string(argv[1]) == "prepare" || std::string(argv[1]) == "prepare-two") {
|
||||
auto package = modern::open_world_package(world);
|
||||
content::Mount mount(world, package.classic); modern::set_current_world(package.world);
|
||||
modern::app::ModernSession session(mount.root(), 17u);
|
||||
ui::SetupOptions options; options.mode = 3; if (std::string(argv[1]) == "prepare-national") options.league = false; options.managers = std::string(argv[1]) == "prepare-two" ? 2 : 1;
|
||||
ui::SetupOptions options; options.mode = 3; if(mode=="prepare-almanac") options.world=false; if (std::string(argv[1]) == "prepare-national") options.league = false; options.managers = std::string(argv[1]) == "prepare-two" ? 2 : 1;
|
||||
ui::ManagerChoice manager; manager.name = "Codex Engine QA"; manager.master_club = 0;
|
||||
std::string error; ui::CareerInitializationResult result;
|
||||
if (!session.confirm_manager(options, manager, error)) throw std::runtime_error(error);
|
||||
if (options.managers == 2) { manager.name = "Codex Opponent QA"; manager.master_club = 1; manager.portrait = 1; if (!session.confirm_manager(options, manager, error)) throw std::runtime_error(error); }
|
||||
if (!session.finish(result, error)) throw std::runtime_error(error);
|
||||
if (std::string(argv[1]) == "prepare-national") {
|
||||
if (mode == "prepare-national" || mode == "prepare-almanac") {
|
||||
uint64_t rev = 0; bool found = false; Json expiry = Json::object(), log = Json::array();
|
||||
for (int k = 0; k < 200; ++k) {
|
||||
const auto desk = Json::parse(cli::dump_json(session.ui_read(cli::Json::Object{{"kind","desktop"}},rev)));
|
||||
if (desk.at("meta").at("scope").at("role") == "national") { found = true; break; }
|
||||
if (mode=="prepare-national" && desk.at("meta").at("scope").at("role") == "national") { found = true; break; }
|
||||
if(mode=="prepare-almanac") {const auto index=Json::parse(cli::dump_json(session.read_almanac(cli::Json::Object{{"kind","index"}})));if(index.value("ok",false)&&index.at("years").size()>=2){found=true;break;}}
|
||||
const auto &meta = desk.at("meta");
|
||||
const Json command{{"messageType","command"},{"contractVersion",meta.at("contractVersion")},{"requestId","request:prepare-national-"+std::to_string(k)},{"careerId",meta.at("careerId")},{"expectedRevision",meta.at("stateRevision")},{"owner",{{"managerId",meta.at("scope").at("managerId")}}},{"kind","session.advance"},{"payload",{{"contractExpiry",expiry}}}};
|
||||
const auto reply = Json::parse(cli::dump_json(session.ui_command(cli::parse_json(command.dump()),rev))); log.push_back(reply);
|
||||
@@ -36,7 +39,7 @@ int main(int argc, char **argv) {
|
||||
throw std::runtime_error(reply.dump());
|
||||
}
|
||||
write("preparation-advance.json",log);
|
||||
if (!found) throw std::runtime_error("no national desk reached through session.advance");
|
||||
if (!found) throw std::runtime_error("requested fixture not reached through session.advance: "+mode);
|
||||
}
|
||||
if (!session.save_game(out / "input.obs", 0, false, error)) throw std::runtime_error(error);
|
||||
modern::set_current_world(nullptr);
|
||||
@@ -274,6 +277,34 @@ int main(int argc, char **argv) {
|
||||
for(const auto *kind:{"friendly-plan","calendar"})if(loaded.at(kind).at("data")!=after.at(kind).at("data"))throw std::runtime_error("national plan/calendar lost on restart");
|
||||
if(loaded.at("desktop").at("data").at("accounts")!=after.at("desktop").at("data").at("accounts"))throw std::runtime_error("national funds lost on restart");
|
||||
}
|
||||
if(mode=="inspect-almanac"||mode=="verify-almanac") {
|
||||
const auto run=[&](const Json &q){const auto read=link->read({{"kind","almanac"},{"query",q}});if(link->read({{"kind","almanac"},{"query",q}})!=read)throw std::runtime_error("archive read changed on repeat");return std::pair{read,engine_almanac_projection(before,read,q)};};
|
||||
const auto [index_read,index]=run({{"kind","index"}});write("index-read.json",index_read);
|
||||
Json catalogue=Json::array();int total=0;
|
||||
for(const auto &year:index.at("years")) {
|
||||
const auto [cr,calendar]=run({{"kind","calendar"},{"year",year}});write(("calendar-"+std::to_string(year.get<int>())+".json").c_str(),cr);
|
||||
for(const auto &day:calendar.at("days")) {
|
||||
const auto [dr,d]=run({{"kind","day"},{"date",day.at("date")}});if(d.at("matches").size()!=size_t(day.at("count").get<int>()))throw std::runtime_error("archive day count mismatch");total+=day.at("count").get<int>();
|
||||
for(const auto &m:d.at("matches"))catalogue.push_back({{"id",m.at("id")},{"date",m.at("date")},{"home",m.at("home")},{"away",m.at("away")},{"result",m.at("result")},{"events",m.at("events").size()},{"competition",m.at("competition")}});
|
||||
}
|
||||
}
|
||||
if(total!=index.at("match_count"))throw std::runtime_error("archive index count differs from calendars");write("catalogue.json",catalogue);
|
||||
Json selected=Json::array();std::set<std::string> selected_ids;
|
||||
for(const auto &m:catalogue) {
|
||||
const bool human=!m.at("home").at("manager").is_null()||!m.at("away").at("manager").is_null();
|
||||
if(selected.size()<2 || (human&&std::none_of(selected.begin(),selected.end(),[](const auto &r){return r.value("human",false);})) || (m.at("result").at("extra_played")==true&&std::none_of(selected.begin(),selected.end(),[](const auto &r){return r.value("extra",false);})) || (m.at("result").at("penalties_played")==true&&std::none_of(selected.begin(),selected.end(),[](const auto &r){return r.value("penalties",false);})) || (m.at("date").get<std::string>().substr(0,4)=="2027"&&std::none_of(selected.begin(),selected.end(),[](const auto &r){return r.at("date").template get<std::string>().substr(0,4)=="2027";}))) {
|
||||
if(!selected_ids.insert(m.at("id").get<std::string>()).second)continue;
|
||||
const auto [read,record]=run({{"kind","match"},{"id",m.at("id")}});write(("match-"+std::to_string(selected.size())+".json").c_str(),read);
|
||||
selected.push_back({{"id",m.at("id")},{"date",m.at("date")},{"human",human},{"extra",m.at("result").at("extra_played")},{"penalties",m.at("result").at("penalties_played")}});
|
||||
}
|
||||
}
|
||||
write("selected.json",selected);
|
||||
if(link->snapshot()!=before)throw std::runtime_error("archive browsing changed engine or RNG projection");
|
||||
const auto unknown=link->read({{"kind","almanac"},{"query",{{"kind","match"},{"id","match:unknown"}}}});write("unknown-match.json",unknown);if(unknown.value("messageType","")!="error")throw std::runtime_error("unknown archived match not rejected");
|
||||
const auto foreign=link->read({{"kind","almanac"},{"managerId","manager:not-active"},{"query",{{"kind","index"}}}});write("foreign-owner.json",foreign);if(foreign.value("code","")!="manager_not_active")throw std::runtime_error("foreign archive scope accepted");
|
||||
write("saved.json",link->save_copy(out/"reads.obs"));link.reset();link=EngineBridge::open(world,out/"reads.obs");const auto loaded=link->snapshot();write("loaded.json",loaded);
|
||||
if(loaded.at("desktop").at("data")!=before.at("desktop").at("data")||link->read({{"kind","almanac"},{"query",{{"kind","index"}}}}).at("data")!=index_read.at("data"))throw std::runtime_error("archive or desk changed across OBS restart");
|
||||
}
|
||||
std::cout << "engine bridge " << argv[1] << " passed\n"; return 0;
|
||||
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
}
|
||||
@@ -320,6 +320,41 @@ int main() {
|
||||
bad_nq=nq;bad_nq["data"]["ratings"]={73};rejects([&]{engine_friendly_projection(np,bad_nq,"nt:two",true);});
|
||||
bad_nq=nq;bad_nq["data"]["ratings"]={73,-1};rejects([&]{engine_friendly_projection(np,bad_nq,"nt:two",true);});
|
||||
bad_nq=nq;bad_nq["meta"]["stateRevision"]="0";rejects([&]{engine_friendly_projection(np,bad_nq,"nt:two",true);});
|
||||
// Archive DTOs retain historic names and unknown fields; only their bound
|
||||
// owner/revision/query may supply a record to the existing presenter.
|
||||
auto archive_bundle=cal;for(auto &[kind,r]:archive_bundle.items())r["meta"]["date"]="2027-01-02";
|
||||
const Json archived_person={{"id","player:archived"},{"name","Historical Player"}};
|
||||
const Json archived_record={{"id","match:2026-1"},{"date","2026-08-01"},{"season","2026/27"},{"round",1},
|
||||
{"competition",{{"id","league:old"},{"name","Historical League"},{"type","league"}}},
|
||||
{"home",{{"id","club:old-a"},{"name","Historical Home"},{"crest",nullptr},{"manager",{{"id","manager:old"},{"name","Historical Manager"}}}}},
|
||||
{"away",{{"id","club:old-b"},{"name","Historical Away"},{"crest",nullptr},{"manager",nullptr}}},
|
||||
{"result",{{"final",{2,1}},{"regulation",nullptr},{"extra",nullptr},{"penalties",nullptr},{"extra_played",false},{"penalties_played",false}}},
|
||||
{"referee",nullptr},{"attendance",12000},{"weather",{{"temperature",19},{"rain",2}}},
|
||||
{"lineups",{{"home",{{"starters",{archived_person}},{"bench",Json::array()}}},{"away",nullptr}}},
|
||||
{"events",{{{"kind","goal"},{"minute",82},{"side","home"},{"player",archived_person},{"other",nullptr},{"detail",0}}}}};
|
||||
const auto archived_read=[&](const Json &query,const Json &result){return Json{{"messageType","snapshot"},{"meta",archive_bundle.at("desktop").at("meta")},{"data",{{"kind","almanac"},{"query",query},{"result",result}}}};};
|
||||
const Json archive_match_query={{"kind","match"},{"id","match:2026-1"}};
|
||||
const Json archive_match_result={{"ok",true},{"match",archived_record}};
|
||||
const auto archive_reply=archived_read(archive_match_query,archive_match_result);
|
||||
const auto archive_value=engine_almanac_projection(archive_bundle,archive_reply,archive_match_query);
|
||||
require(archive_value==archive_match_result && archive_value.at("match").at("result").at("regulation").is_null() && !archive_value.at("match").at("lineups").at("home").at("starters")[0].contains("position"),"archive presentation invented phase or current player data");
|
||||
const Json archive_index_query={{"kind","index"}},archive_index={{"ok",true},{"years",{2026}},{"match_count",1},{"first_date","2026-08-01"},{"last_date","2026-08-01"}};
|
||||
require(engine_almanac_projection(archive_bundle,archived_read(archive_index_query,archive_index),archive_index_query)==archive_index,"archive index lost");
|
||||
const Json archive_calendar_query={{"kind","calendar"},{"year",2026}},archive_calendar={{"ok",true},{"year",2026},{"days",{{{"date","2026-08-01"},{"count",1},{"highlights",{"match:2026-1"}}}}}};
|
||||
(void)engine_almanac_projection(archive_bundle,archived_read(archive_calendar_query,archive_calendar),archive_calendar_query);
|
||||
const Json archive_day_query={{"kind","day"},{"date","2026-08-01"}},archive_day={{"ok",true},{"date","2026-08-01"},{"matches",{archived_record}}};
|
||||
(void)engine_almanac_projection(archive_bundle,archived_read(archive_day_query,archive_day),archive_day_query);
|
||||
auto bad_archive=archive_reply;bad_archive["meta"]["careerId"]="other";rejects([&]{engine_almanac_projection(archive_bundle,bad_archive,archive_match_query);});
|
||||
bad_archive=archive_reply;bad_archive["meta"]["stateRevision"]="42";rejects([&]{engine_almanac_projection(archive_bundle,bad_archive,archive_match_query);});
|
||||
bad_archive=archive_reply;bad_archive["data"]["query"]["id"]="match:other";rejects([&]{engine_almanac_projection(archive_bundle,bad_archive,archive_match_query);});
|
||||
bad_archive=archive_reply;bad_archive["data"]["result"]["match"]["id"]="match:other";rejects([&]{engine_almanac_projection(archive_bundle,bad_archive,archive_match_query);});
|
||||
bad_archive=archive_reply;bad_archive["data"]["result"]["match"]["date"]="2028-08-01";rejects([&]{engine_almanac_projection(archive_bundle,bad_archive,archive_match_query);});
|
||||
auto bad_archive_day=archive_day;bad_archive_day["matches"].push_back(archived_record);rejects([&]{engine_almanac_projection(archive_bundle,archived_read(archive_day_query,bad_archive_day),archive_day_query);});
|
||||
bad_archive_day=archive_day;bad_archive_day["matches"][0]["date"]="2026-08-02";rejects([&]{engine_almanac_projection(archive_bundle,archived_read(archive_day_query,bad_archive_day),archive_day_query);});
|
||||
auto bad_archive_calendar=archive_calendar;bad_archive_calendar["year"]=2025;rejects([&]{engine_almanac_projection(archive_bundle,archived_read(archive_calendar_query,bad_archive_calendar),archive_calendar_query);});
|
||||
rejects([&]{engine_almanac_key({{"kind","calendar"},{"year",2026.5}});});
|
||||
rejects([&]{engine_almanac_key({{"kind","day"},{"date","2026-02-30"}});});
|
||||
rejects([&]{engine_almanac_key({{"kind","match"},{"id",""}});});
|
||||
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; }
|
||||
|
||||
Reference in new issue
Block a user