From c361dccd3427ab9f7a61d94c2c8136d974d2501d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 09:11:04 +0100 Subject: [PATCH] Modern UI contract: national line-up and tactics The national coach's desk reads the national team's line-up and tactics (the original's desk has them) instead of no_club, and lineup.commit prepares the national board without the clubs' designated set-piece extension, whose records the national team has not. Co-Authored-By: Claude Opus 5.5 --- docs/new_engine/ui-anbindung.md | 2 +- src/modern/app/modern_session.cpp | 10 +++++++--- tests/modern_ui_contract_tests.cpp | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/new_engine/ui-anbindung.md b/docs/new_engine/ui-anbindung.md index 6158fea..573bc61 100644 --- a/docs/new_engine/ui-anbindung.md +++ b/docs/new_engine/ui-anbindung.md @@ -28,7 +28,7 @@ Revision kommt vom Aufrufer (Konsole bzw. AppController), der Read ändert nicht | `desktop` | Manager, Team (`TeamRef`), Kontostand (`accounts.cash`; Festgeld und Kredit im Read `bank` bzw. `credit`), nächstes Spiel, `menuAvailability` | | `squad` | ein Kader (`teamId`, sonst der eigene Verein; auch Nationalteams mit Kader): Spieler-ID, Name, Nation, Position, Rolle (`starter`/`bench`/`reserve`), Verfügbarkeit, Verletzung und Sperre in Wochen, Alter, Werte (Stärke, Kondition, Technik, Form), Fähigkeiten; für den eigenen Verein Monatsgehalt und Restlaufzeit in Monaten (fremde Vereine: `null`) | | `camps` | Karten und Lager (Qualität 0–6, Ort, Nation, Exklusiv-Sponsor-Chance), je Lager ein bindendes Angebot für den eigenen Kader (Grundpreis + Kaderzuschlag, ohne Zufall; `allowed`, `reasonCode` `booked_this_week`/`visit_limit`/`no_club`, `exceedsCash`), Schwerpunkte, Aufenthalte der Saison, Buchung dieser Woche | -| `lineup` | die Kaderzeilen in Reihenfolge (die ersten elf spielen) mit Rolle, die Plätze der Startelf auf der Taktiktafel (`depth` 0–19, `lane` 0–8; das JSON hat keine Kommazahlen), `manual` (Aufstellung von Hand) | +| `lineup` | die Kaderzeilen in Reihenfolge (die ersten elf spielen) mit Rolle, die Plätze der Startelf auf der Taktiktafel (`depth` 0–19, `lane` 0–8; das JSON hat keine Kommazahlen), `manual` (Aufstellung von Hand). Auch am Schreibtisch des Bundestrainers (das Nationalteam; ohne die Standardschützen-Erweiterung der Vereine), ebenso `tactics` und `lineup.commit` | | `tactics` | die acht Einstellungen (`tactic:0` Grundausrichtung bis `tactic:7` Einsatz) mit Wert und Maximum aus der EXE; die Bedeutung der Diagramm-Einstellungen 1–3, 5, 6 ist nicht belegt, daher neutrale Namen | | `training` | Bälle je Spielertyp und Trainingsbereich (1–3) mit den Grenzen, je Spieler Intensität und Schwerpunkt, ob das Training eingerichtet ist, Automatik-Bits | | `contracts` | je Spieler Restlaufzeit, Monatsgehalt, Versicherung, Prämien; das offene Angebot (`quote`: ID, Spieler, Monatsforderung für 1–4 Jahre, Höchstgehalt 200.000 €) | diff --git a/src/modern/app/modern_session.cpp b/src/modern/app/modern_session.cpp index 3ed04e4..0558b2c 100644 --- a/src/modern/app/modern_session.cpp +++ b/src/modern/app/modern_session.cpp @@ -6126,10 +6126,11 @@ bool ModernSession::dispatch_lineup(const ui::LineupRequest& request, uint64_t& prepare_lineup_entry(staged, request.runtime_club); // PrepareLineupEntry. modern::open_lineup_screen(staged, active); // OpenBMH deviates from the original: supports designated set-piece record initialization and validation. // supported rule profile NormalizePitchSetPieceSource entry initialization. - if (!initialize_pitch_set_piece_source(staged, active, request.runtime_club)) + // (the designated set-piece takers are a club extension: the national team has none) + if (request.runtime_club != no_team() && !initialize_pitch_set_piece_source(staged, active, request.runtime_club)) throw std::runtime_error("set-piece set-piece record did not validate"); const uint32_t display=uint32_t(::bmh::layout::CareerSession_AnyOf_ExecutableField+active*2); - if(staged.memory.has(display)&&(staged.memory.u16(display)&0x80)&& + if(request.runtime_club!=no_team()&&staged.memory.has(display)&&(staged.memory.u16(display)&0x80)&& !normalize_pitch_set_piece_source(staged,active,request.runtime_club)) throw std::runtime_error("set-piece reentry redraw did not validate"); } catch (const std::exception& e) { @@ -9061,7 +9062,10 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co {"tables", std::move(tables)}}); } const int team = g_.manager_teams[size_t(manager)]; - if (team < 0 || team >= league_clubs()) + // the national coach has his team's line-up and tactics as well (the original's desk); the + // club views (bank, contracts, stadium, ...) are not his + const bool national_view = team == no_team() && (kind == "lineup" || kind == "tactics"); + if (!national_view && (team < 0 || team >= league_clubs())) return modern::ui_error(request_id, "no_club", "Am Schreibtisch des Bundestrainers gibt es das nicht.", revision, false); if (kind == "lineup") { // the squad rows in order: the first eleven start (+0x8000), the bench (+0x4000) follows; diff --git a/tests/modern_ui_contract_tests.cpp b/tests/modern_ui_contract_tests.cpp index 51e856a..2075b2e 100644 --- a/tests/modern_ui_contract_tests.cpp +++ b/tests/modern_ui_contract_tests.cpp @@ -686,6 +686,28 @@ int main(int argc, char** argv) { const J again = session.ui_read(O{{"kind", "friendly"}, {"opponentId", "team:384"}}, rev); const auto* dates = at(at(nf, "data"), "dates").array(); check(cli::dump_json(at(nf, "data")) == cli::dump_json(at(again, "data")) && dates, "national friendly read is pure"); + // the national team's line-up and tactics at the coach's desk + { + const J lineup = session.ui_read(O{{"kind", "lineup"}}, rev); + const J tactics = session.ui_read(O{{"kind", "tactics"}}, rev); + const auto* order = at(at(lineup, "data"), "order").array(); + std::printf("(national line-up: %s)\n", cli::dump_json(lineup).substr(0, 160).c_str()); + check(s(at(lineup, "messageType")) == "snapshot" && order && order->size() >= 11, "national line-up read"); + check(s(at(tactics, "messageType")) == "snapshot", "national tactics read"); + if (order && order->size() >= 11) { + const uint64_t was = rev; + const J kept = session.ui_command(cmd("request:nl" + std::to_string(k), "lineup.commit", O{{"order", J(*order)}}), rev); + std::printf("(national line-up commit: %s)\n", cli::dump_json(kept).substr(0, 200).c_str()); + check(s(at(kept, "messageType")) == "command_result" && rev == was + 1, "national line-up commit"); + J::Array swapped = *order; + std::swap(swapped[0], swapped[1]); + const J moved = session.ui_command(cmd("request:nm" + std::to_string(k), "lineup.commit", O{{"order", J(swapped)}}), rev); + const J after_swap = session.ui_read(O{{"kind", "lineup"}}, rev); + const auto* now = at(at(after_swap, "data"), "order").array(); + check(s(at(moved, "messageType")) == "command_result" && now && s((*now)[0]) == s((*order)[1]), + "national line-up: two players swapped"); + } + } std::printf("(national friendly: %s)\n", cli::dump_json(at(nf, "data")).substr(0, 300).c_str()); national_friendly = 0; if (dates && !dates->empty()) {