Bind national friendly planning to engine offers and saved schedules (by Codex)

This commit is contained in:
Codex committed 2026-10-28 17:30:31 +01:00
1 parent 15d2ac0a4d
commit d615f03e15
14 files changed
+259 -30

No files matched your search

+18 -11
View File
@@ -454,14 +454,15 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
// Read the saved plan, never a UI-local booking log. These are the same
// verified 30 day/team entries used by book_friendly_match.
const int own = team_of(g, c.manager);
if (own < 0 || own >= league_clubs())
return failure(request_id, "no_club", "Vereinsplanung ist hier nicht verfügbar.", c.state_revision);
const bool national = own == no_team();
if (!national && (own < 0 || own >= league_clubs()))
return failure(request_id, "no_club", "Freundschaftsplanung ist hier nicht verfügbar.", c.state_revision);
constexpr uint32_t entries = 30;
if (!g.memory.has(layout::FriendlyDays + entries * 2 - 1) ||
!g.memory.has(layout::FriendlyTeams + entries * 4 - 1))
return failure(request_id, "friendly_plan_unavailable", "Der Spielplan ist unvollständig.", c.state_revision);
A opponents, bookings;
for (int t = 0; t < first_foreign_cup(); ++t) {
for (int t = national ? no_team() + 1 : 0; t < (national ? world_layout().total_teams() : first_foreign_cup()); ++t) {
if (t == own) continue;
const int league = team_league(t);
const std::string league_id = league >= 0 && size_t(league) < g.world_league_id.size() ? g.world_league_id[size_t(league)] : std::string{};
@@ -481,7 +482,7 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
bookings.push_back(O{{"id", "friendly:" + date + ":" + team_id(g, home) + ":" + team_id(g, away)},
{"date", date}, {"home", team_ref(g, home, date)}, {"away", team_ref(g, away, date)}});
}
return snapshot(request_id, std::move(m), O{{"kind", "friendly-plan"}, {"teamId", team_id(g, own)},
return snapshot(request_id, std::move(m), O{{"kind", "friendly-plan"}, {"national", national}, {"teamId", team_id(g, own)},
{"opponents", std::move(opponents)}, {"bookings", std::move(bookings)}});
}
if (kind == "calendar") {
@@ -499,13 +500,19 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
const std::string date = date_of(d.day);
if (date < from || date > until) continue;
A kinds, ids;
if (d.competitions & 0x1f) kinds.push_back("league");
for (int bit = 5; bit < 15; ++bit)
if (d.competitions >> bit & 1) kinds.push_back("cup:" + std::to_string(bit - 5));
if (d.competitions & 0x8000) kinds.push_back("replay");
if (d.competitions & 0x10000) kinds.push_back("indoor");
if (d.competitions & 0x40000) kinds.push_back("special");
if (d.competitions & 0x800000) kinds.push_back("national");
if (own == no_team()) {
// day_competitions rotates the national qualifiers/finals through
// bits 9..12. Club tournament flags do not describe this desk.
if (d.competitions & 0x801e00) kinds.push_back("national");
} else {
if (d.competitions & 0x1f) kinds.push_back("league");
for (int bit = 5; bit < 15; ++bit)
if (d.competitions >> bit & 1) kinds.push_back("cup:" + std::to_string(bit - 5));
if (d.competitions & 0x8000) kinds.push_back("replay");
if (d.competitions & 0x10000) kinds.push_back("indoor");
if (d.competitions & 0x40000) kinds.push_back("special");
if (d.competitions & 0x800000) kinds.push_back("national");
}
if (d.friendly) kinds.push_back("friendly");
for (const ClubCalendarMatch& cm : d.matches) {
const std::string id = "fixture:league-" + std::to_string(cm.league) + "-" + std::to_string(cm.round + 1) + "-" + std::to_string(cm.match);