Bind friendly planning quotes bookings and explicit hotseat consent (by Codex)
This commit is contained in:
1 parent
cbde7b367e
commit
15d2ac0a4d
20 files changed
+422
-22
No files matched your search
@@ -10,6 +10,7 @@
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "game/table.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "modern/content/projections.hpp"
|
||||
#include "modern/content/press_journal.hpp"
|
||||
#include "modern/content/statistics.hpp"
|
||||
@@ -449,6 +450,40 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req
|
||||
{"events", std::move(events)},
|
||||
{"sources", A{J("almanac"), J("journal")}}});
|
||||
}
|
||||
if (kind == "friendly-plan") {
|
||||
// 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);
|
||||
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) {
|
||||
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{};
|
||||
opponents.push_back(O{{"team", team_ref(g, t, today)},
|
||||
{"competitionId", league_id.empty() ? J(nullptr) : J(league_id)},
|
||||
{"strength", t < league_clubs() ? J(team_average(g, t, 0xff).value) : J(nullptr)}});
|
||||
}
|
||||
for (uint32_t i = 0; i < entries; ++i) {
|
||||
const int day = g.memory.u16(layout::FriendlyDays + i * 2);
|
||||
if (!day) continue;
|
||||
const int home = int16_t(g.memory.u16(layout::FriendlyTeams + i * 4));
|
||||
const int away = int16_t(g.memory.u16(layout::FriendlyTeams + i * 4 + 2));
|
||||
if (home != own && away != own) continue;
|
||||
if (day > 365 || home < 0 || away < 0 || home >= world_layout().total_teams() || away >= world_layout().total_teams())
|
||||
return failure(request_id, "friendly_plan_unavailable", "Ungültiger Eintrag im Spielplan.", c.state_revision);
|
||||
const std::string date = iso(almanac_date(g.season_start + uint32_t(day), g.display_start_year));
|
||||
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)},
|
||||
{"opponents", std::move(opponents)}, {"bookings", std::move(bookings)}});
|
||||
}
|
||||
if (kind == "calendar") {
|
||||
// the season calendar of the desk's team: days from `from` to `until` (ISO dates, default
|
||||
// the current month) with the day's competitions and the team's league matches (planned
|
||||
|
||||
Reference in new issue
Block a user