Liven up the match day: varied ticker wording, whistles, results of the day, eleven of the day

The ticker picks its sentence from several variants by the event's facts
and names equalisers, leads and late goals; kickoff, half time and the
final whistle are reported, with the same wording while the kickoff runs
live. The ticker's third tab lists the other results of the day. Modern
chooses an eleven of the day per league from the recorded match facts and
the review shows it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 11:34:47 +01:00
1 parent 333bc57526
commit 1732a2477b
11 files changed
+288 -24

No files matched your search

+22 -3
View File
@@ -8730,14 +8730,28 @@ cli::Json ModernSession::read_live(const cli::Json& request) const {
};
cli::Json::Array events;
const auto& log = grp.log;
// the ticker's wording, as the recording will carry it after the final whistle
int goals_home = 0, goals_away = 0;
const auto plain_name = [this](int p) -> std::string {
if (p < 0 || p >= 0x0fff || size_t(p) >= g_.players.size()) return {};
const std::string first = size_t(p) < g_.player_first.size() ? g_.player_first[size_t(p)] : std::string{};
std::string last = size_t(p) < g_.player_last.size() ? g_.player_last[size_t(p)] : std::string{};
if (last.empty()) last = ui::original_to_utf8(g_.player_name(p));
return first.empty() ? last : first + " " + last;
};
for (size_t w = 0; w + 1 < log.size(); w += 2) {
const int code = log[w] >> 12, player = log[w] & 0x0fff;
const int side_team = log[w + 1] >> 7, value = log[w + 1] & 0x7f;
int assistant = 0x0fff;
if ((code == 0 || code == 1) && w + 3 < log.size()) assistant = log[w + 2] & 0x0fff, w += 2;
if ((side_team != home && side_team != away) || code > 6 || code == 2) continue;
const bool away_side = side_team != home;
if (code == 0) ++(away_side ? goals_away : goals_home);
static constexpr int kAlmanacKind[7] = {0, 7, 0, 1, 3, 2, 4}; // log code -> AlmanacEventKind
const auto [headline, body] = modern::ticker_phrase(kAlmanacKind[code], club_label(side_team), plain_name(player),
plain_name(assistant), 0, value, goals_home, goals_away, away_side);
events.push_back(O{{"minute", value}, {"kind", kKinds[code]}, {"side", side_team == home ? "home" : "away"},
{"player", person(player)}, {"other", person(assistant)}});
{"player", person(player)}, {"other", person(assistant)}, {"headline", headline}, {"body", body}});
}
matches.push_back(O{{"events", std::move(events)},
{"home", O{{"id", modern::ui_team_id(g_, home)}, {"name", club_label(home)}}},
@@ -9119,11 +9133,16 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
return cli::Json(O{{"id", id}, {"available", ok}, {"reasonCode", ok ? cli::Json(nullptr) : cli::Json("not_recorded")}});
};
const bool any = !matches.array()->empty();
// Modern chooses its own eleven from the recorded day; the original's Sportschau choice
// (only with its replay option) takes precedence when it exists
cli::Json eleven = !ui_last_awards_.empty() ? cli::Json(ui_last_awards_)
: modern::team_of_the_day(g_, ui_last_advance_->first, ui_last_advance_->second);
const bool has_eleven = eleven.array() && !eleven.array()->empty();
return modern::ui_snapshot(g_, context, request_id,
O{{"kind", "postmatch"}, {"presentationId", "presentation:postmatch-" + std::to_string(ui_last_advance_revision_)},
{"steps", A{step("results", any), step("report", !report.empty()), step("team_of_the_day", !ui_last_awards_.empty()),
{"steps", A{step("results", any), step("report", !report.empty()), step("team_of_the_day", has_eleven),
step("overview", any), step("table", !tables.empty())}},
{"matches", std::move(matches)}, {"reportMatchIds", std::move(report)}, {"teamOfTheDay", ui_last_awards_},
{"matches", std::move(matches)}, {"reportMatchIds", std::move(report)}, {"teamOfTheDay", std::move(eleven)},
{"tables", std::move(tables)}});
}
const int team = g_.manager_teams[size_t(manager)];