Show attendance and weather before live ticker kickoff (by Codex)
This commit is contained in:
1 parent
ef25407484
commit
b845bbfcbc
10 files changed
+144
-14
No files matched your search
@@ -23,7 +23,7 @@ body.matchday {--live-bg:#242426;--live-surface:#302f34ec;--live-wash:#efc7ce0a;
|
||||
.live-coverage button {height:72dp;padding:0 26dp;font-size:32dp;}
|
||||
.live-clock {display:block;margin-left:auto;color:var(--live-accent);font-size:44dp;flex-shrink:0;}
|
||||
.live-cards {padding:24dp;display:flex;flex-wrap:wrap;gap:20dp;}
|
||||
.live-stage .live-game {width:48%;flex-grow:1;flex-shrink:0;height:178dp;min-width:0;display:block;border:2dp var(--live-line);border-radius:22dp;background-color:var(--live-wash);padding:12dp 22dp;}
|
||||
.live-stage .live-game {width:48%;flex-grow:1;flex-shrink:0;height:218dp;min-width:0;display:block;border:2dp var(--live-line);border-radius:22dp;background-color:var(--live-wash);padding:12dp 22dp;}
|
||||
.live-coverage .live-match-arrow {width:70dp;padding:0;}
|
||||
.live-cards.single .live-game {width:100%;}
|
||||
.live-game.active {border-color:var(--live-accent);}
|
||||
@@ -34,6 +34,7 @@ body.matchday {--live-bg:#242426;--live-surface:#302f34ec;--live-wash:#efc7ce0a;
|
||||
.live-team-name.away {text-align:left;}
|
||||
.live-score {display:block;font-size:64dp;font-weight:normal;flex-shrink:0;text-align:center;min-width:134dp;white-space:nowrap;}
|
||||
.live-card-caption {display:block;font-size:22dp;color:var(--live-muted);text-align:center;margin-top:8dp;}
|
||||
.live-match-info {display:block;font-size:25dp;line-height:1.3;color:var(--live-muted);text-align:center;margin-top:8dp;white-space:nowrap;}
|
||||
.live-badge {display:flex;align-items:center;justify-content:center;flex-shrink:0;}
|
||||
.live-ticker {display:flex;flex-direction:column;flex:1;min-height:0;}
|
||||
.live-panel-heading {height:108dp;padding:24dp 42dp;display:flex;align-items:center;justify-content:space-between;gap:24dp;border-bottom:2dp var(--live-line);flex-shrink:0;}
|
||||
|
||||
@@ -175,3 +175,27 @@ Der Treiber erfindet keine Livezustände: Klick, Taste, Mausrad und Wartezeit
|
||||
laufen durch die normalen RmlUI-/SDL-Pfade. Die JSON-/DOM-/Geometrieproben und
|
||||
PNG-Ausgaben bleiben am angegebenen Ziel. Für den eigenen Xvfb werden ein
|
||||
installiertes `Xvfb` oder alternativ `--display` benötigt.
|
||||
|
||||
|
||||
## Zuschauer und Wetter vor dem Start
|
||||
|
||||
Jede eindeutige Partie zeigt bereits bei Sequenz 0 ihre Zuschauerzahl und das
|
||||
Wetter. Die Zeile bleibt während der Wiedergabe sichtbar; die Halle zeigt „Halle“
|
||||
statt Außenwetter. Zwei gegnerische menschliche Manager teilen dieselbe Partie
|
||||
und damit dieselben Bedingungen. Die Werte werden auch in den Nachspielbericht
|
||||
übernommen; eine Übersicht zählt jede Partie nur einmal.
|
||||
|
||||
Die optionalen Felder auf jedem `openbmh-live-fixture@1.matches[]`-Eintrag sind:
|
||||
|
||||
```json
|
||||
{"attendance": 26400, "weather": {"temperature": 18, "rain": 0}}
|
||||
```
|
||||
|
||||
`attendance` ist eine nichtnegative Ganzzahl (bis INT32_MAX), `temperature`
|
||||
eine vorzeichenbehaftete Celsius-Ganzzahl (-128…127). `rain` ist der originale
|
||||
Wetterbild-Code 0…7, kein Prozentwert: sonnig, heiter, wolkig, bedeckt, Regen,
|
||||
Regen, Schnee, Schnee. Es werden keine Wetterwerte aus der Temperatur abgeleitet.
|
||||
Fehlende oder `null`-Werte bleiben unbekannt; 0 Zuschauer und 0 °C bleiben
|
||||
sichtbar. Alte Aufnahmen ohne diese Felder sind weiterhin gültig. Die mitgelieferte
|
||||
UI-Demo enthält explizite Beispieldaten, ohne RNG, Uhr, Revision oder Karriere zu
|
||||
verändern. Ein autoritativer Anbieter liefert die tatsächlichen Bedingungen.
|
||||
@@ -196,6 +196,14 @@ Json make_demo_live(const Catalog &world, const Json &state, uint64_t revision)
|
||||
}
|
||||
const auto identity = Json{{"world", world.manifest().value("id", "")}, {"date", state.at("date")},
|
||||
{"role", role}, {"surface", surface}, {"matches", matches}};
|
||||
// Explicit presentation examples, separate from the authored event tape.
|
||||
// Add after identity construction so existing fixture/match/event IDs stay
|
||||
// compatible. Real providers supply their own recorded conditions.
|
||||
for (size_t i = 0; i < matches.size(); ++i) {
|
||||
matches[i]["attendance"] = indoor ? 2200 + int(i) * 350 : 26400 + int(i) * 4750;
|
||||
matches[i]["weather"] = indoor ? Json() : Json{{"temperature", 18 + int(i)},
|
||||
{"rain", std::array<int,4>{0,2,4,1}[i]}};
|
||||
}
|
||||
return {{"ok", true}, {"schema", "openbmh-live-fixture@1"}, {"source", "ui-demo-fixture"},
|
||||
{"fixture_id", "ui-live:" + fingerprint(identity.dump())}, {"source_revision", revision},
|
||||
{"world", world.manifest().value("id", "")}, {"date", state.at("date")},
|
||||
@@ -243,6 +251,20 @@ bool valid_live_fixture(const Json &v) {
|
||||
}
|
||||
}
|
||||
for (const auto &match : v.at("matches")) {
|
||||
if (match.contains("attendance") && !match.at("attendance").is_null() &&
|
||||
!uint_value(match.at("attendance"), INT32_MAX)) return false;
|
||||
if (match.contains("weather") && !match.at("weather").is_null()) {
|
||||
const auto &weather = match.at("weather");
|
||||
if (!weather.is_object()) return false;
|
||||
if (weather.contains("temperature") && !weather.at("temperature").is_null() &&
|
||||
(!weather.at("temperature").is_number_integer() ||
|
||||
(weather.at("temperature").is_number_unsigned() &&
|
||||
weather.at("temperature").get<uint64_t>() > 127) ||
|
||||
weather.at("temperature").get<int64_t>() < -128 ||
|
||||
weather.at("temperature").get<int64_t>() > 127)) return false;
|
||||
if (weather.contains("rain") && !weather.at("rain").is_null() &&
|
||||
!uint_value(weather.at("rain"), 7)) return false;
|
||||
}
|
||||
if (!string_value(match.at("id")) || !match_ids.insert(match.at("id")).second ||
|
||||
!match.at("owners").is_array() || match.at("owners").empty()) return false;
|
||||
for (auto side : {"home", "away"})
|
||||
|
||||
@@ -121,8 +121,9 @@ Json report(const Json &fixture, const Json &match, int minute) {
|
||||
// no player actor, assist or exact playing-time/ratings, so none is inferred.
|
||||
out["events"] = match_events(frame->at("events"), match.at("id"));
|
||||
out["timeline"] = match_events(frames.back().at("events"), match.at("id"));
|
||||
out["attendance"] = nullptr;
|
||||
out["attendance_reason"] = "not_recorded";
|
||||
out["attendance"] = match.value("attendance", Json());
|
||||
out["attendance_reason"] = out["attendance"].is_null() ? "not_recorded" : "recorded";
|
||||
out["weather"] = match.value("weather", Json());
|
||||
out["actor"] = nullptr; out["assists"] = nullptr; out["ratings"] = nullptr;
|
||||
out["playing_minutes"] = nullptr;
|
||||
return out;
|
||||
@@ -145,14 +146,19 @@ Json make_demo_post_match(const Json &fixture, size_t completed_sequence, const
|
||||
out["matches"] = Json::array(); out["tables"] = Json::array();
|
||||
Json totals = {{"games", fixture.at("matches").size()}, {"goals", 0},
|
||||
{"yellow", 0}, {"red", 0}, {"chances", 0},
|
||||
{"attendance", nullptr}, {"attendance_reason", "not_recorded"},
|
||||
{"attendance", int64_t(0)}, {"attendance_reason", "recorded"},
|
||||
{"scope", "recorded_human_matches"}};
|
||||
bool crowds_known = true;
|
||||
for (const auto &match : fixture.at("matches")) {
|
||||
const auto &final = match_snapshot(last, match.at("id"));
|
||||
auto row = match;
|
||||
row["final"] = final;
|
||||
row["events"] = match_events(last.at("events"), match.at("id"));
|
||||
row["attendance"] = nullptr; row["attendance_reason"] = "not_recorded";
|
||||
row["attendance"] = match.value("attendance", Json());
|
||||
row["attendance_reason"] = row["attendance"].is_null() ? "not_recorded" : "recorded";
|
||||
row["weather"] = match.value("weather", Json());
|
||||
if (row["attendance"].is_null()) crowds_known = false;
|
||||
else totals["attendance"] = totals.at("attendance").get<int64_t>() + row.at("attendance").get<int64_t>();
|
||||
out["matches"].push_back(std::move(row));
|
||||
for (auto key : {"yellow", "red", "chances"})
|
||||
totals[key] = totals.at(key).get<int>() + final.at(key)[0].get<int>() + final.at(key)[1].get<int>();
|
||||
@@ -170,9 +176,14 @@ Json make_demo_post_match(const Json &fixture, size_t completed_sequence, const
|
||||
{"wins", nullptr}, {"draws", nullptr}, {"losses", nullptr}});
|
||||
}
|
||||
}
|
||||
if (!crowds_known) {
|
||||
totals["attendance"] = nullptr;
|
||||
totals["attendance_reason"] = "not_recorded";
|
||||
}
|
||||
out["overview"] = std::move(totals);
|
||||
out["eleven"] = {{"available", false}, {"reason", "not_recorded"}, {"rows", Json::array()}};
|
||||
out["unknown_fields"] = Json::array({"attendance", "actor", "assists", "ratings", "playing_minutes", "eleven", "wins", "draws", "losses"});
|
||||
out["unknown_fields"] = Json::array({"actor", "assists", "ratings", "playing_minutes", "eleven", "wins", "draws", "losses"});
|
||||
if (!crowds_known) out["unknown_fields"].push_back("attendance");
|
||||
if (const auto *error = attach_records(out, fixture, records)) return failure(error);
|
||||
return out;
|
||||
} catch (const std::exception &) { return failure("invalid_post_match_fixture"); }
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/catalog.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// The rain code selects the original eight weather pictograms. It is not a
|
||||
// precipitation percentage or a temperature-based forecast.
|
||||
inline std::string live_weather_label(int code) {
|
||||
static constexpr std::array<const char *, 8> labels{
|
||||
"sonnig", "heiter", "wolkig", "bedeckt", "Regen", "Regen", "Schnee", "Schnee"};
|
||||
return code >= 0 && code < int(labels.size()) ? labels[size_t(code)] : "Wetter —";
|
||||
}
|
||||
inline std::string live_attendance_text(const Json &match) {
|
||||
if (!match.contains("attendance") || !match.at("attendance").is_number_integer())
|
||||
return "Zuschauer —";
|
||||
const auto count = match.at("attendance").get<int64_t>();
|
||||
if (count < 0) return "Zuschauer —";
|
||||
auto text = std::to_string(count);
|
||||
for (int at = int(text.size()) - 3; at > 0; at -= 3) text.insert(size_t(at), ".");
|
||||
return text + " Zuschauer";
|
||||
}
|
||||
inline std::string live_match_info_text(const Json &match, bool indoor) {
|
||||
auto text = live_attendance_text(match);
|
||||
if (indoor) return text + " · Halle";
|
||||
const auto weather = match.value("weather", Json());
|
||||
if (!weather.is_object()) return text + " · Wetter —";
|
||||
if (weather.contains("temperature") && weather.at("temperature").is_number_integer())
|
||||
text += " · " + std::to_string(weather.at("temperature").get<int>()) + " °C";
|
||||
const auto rain = weather.value("rain", Json());
|
||||
return text + " · " + (rain.is_number_integer() ? live_weather_label(rain.get<int>()) : "Wetter —");
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -162,7 +162,7 @@ std::string App::render_live() {
|
||||
if (live_coverage_ == "single" && match.at("id") != live_selected_match_) continue;
|
||||
std::string names;
|
||||
for (const auto &id : match.at("owners")) for (const auto &person : fixture.at("owners")) if (person.at("id") == id) { if (!names.empty()) names += " · "; names += person.at("name").get<std::string>(); }
|
||||
out += "<button data-action=\"live-match\" class=\"live-game " + std::string(match.at("id") == live_selected_match_ ? "active" : "") + "\" data-live-match=\"" + esc(match.at("id").get<std::string>()) + "\" data-id=\"" + esc(match.at("id").get<std::string>()) + "\">" + live_text(names, "live-owners") + scoreline(match) + live_text(std::to_string(minute) + "′ · " + (match.at("owners").size() > 1 ? "Zwei menschliche Manager" : "Eine menschliche Mannschaft"), "live-card-caption") + "</button>";
|
||||
out += "<button data-action=\"live-match\" class=\"live-game " + std::string(match.at("id") == live_selected_match_ ? "active" : "") + "\" data-live-match=\"" + esc(match.at("id").get<std::string>()) + "\" data-id=\"" + esc(match.at("id").get<std::string>()) + "\">" + live_text(names, "live-owners") + scoreline(match) + live_text(std::to_string(minute) + "′ · " + (match.at("owners").size() > 1 ? "Zwei menschliche Manager" : "Eine menschliche Mannschaft"), "live-card-caption") + live_text(live_match_info_text(match, fixture.at("surface") == "indoor"), "live-match-info") + "</button>";
|
||||
}
|
||||
out += "</div></section><section class=\"live-panel live-ticker\"><header class=\"live-panel-heading\"><h2>" + live_text("Gemeinsamer Live-Ticker") + "</h2>" + live_text(live_coverage_ == "single" ? "Gewählte Partie" : "Alle Manager", "live-small") + "</header><nav class=\"live-filters\">";
|
||||
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 4>{{{"all", "Alles"}, {"highlights", "Highlights"}, {"goal", "Tore"}, {"yellow", "Karten"}}}) out += btn("live-filter", label, live_filter_ == id ? "selected" : "", "id=\"live-filter-" + std::string(id) + "\" data-id=\"" + id + "\"");
|
||||
|
||||
@@ -175,8 +175,8 @@ std::string App::postmatch_report_markup(const Json &report) {
|
||||
"<strong>" + live_text(report.at("away").at("name")) +
|
||||
"</strong></div></header>";
|
||||
out += "<p class=\"postmatch-report-meta\">" +
|
||||
live_text("Spielort und Zuschauer nicht aufgezeichnet · "
|
||||
"Spielerzuordnung nicht aufgezeichnet") +
|
||||
live_text(live_match_info_text(report, postmatch_data_.at("surface") == "indoor") +
|
||||
" · Spielort und Spielerzuordnung nicht aufgezeichnet") +
|
||||
"</p><div id=\"postmatch-events\" class=\"postmatch-event-columns\">" +
|
||||
postmatch_events(report, "home") + postmatch_events(report, "away") +
|
||||
"</div><section class=\"postmatch-timeline\"><div "
|
||||
@@ -347,6 +347,11 @@ std::string App::render_postmatch() {
|
||||
} else if (postmatch_tab_ == "overview") {
|
||||
auto total = postmatch_data_.at("overview");
|
||||
total["games"] = matches.size();
|
||||
total["attendance"] = int64_t(0);
|
||||
for (const auto &m : matches) {
|
||||
if (m.at("attendance").is_null()) { total["attendance"] = nullptr; break; }
|
||||
total["attendance"] = total.at("attendance").get<int64_t>() + m.at("attendance").get<int64_t>();
|
||||
}
|
||||
for (const auto *key : {"goals", "yellow", "red"})
|
||||
total[key] = 0;
|
||||
for (const auto &m : matches)
|
||||
@@ -375,7 +380,9 @@ std::string App::render_postmatch() {
|
||||
: "—") +
|
||||
" Tore pro Partie") +
|
||||
"</p><p class=\"postmatch-scope-note\">" +
|
||||
live_text("Zuschauer nicht aufgezeichnet · keine Ligagesamtwertung") +
|
||||
live_text(total.at("attendance").is_null()
|
||||
? "Zuschauer nicht aufgezeichnet · keine Ligagesamtwertung"
|
||||
: "Aufgezeichnete menschliche Partien · keine Ligagesamtwertung") +
|
||||
"</p></section>";
|
||||
} else {
|
||||
const Json *table = nullptr;
|
||||
@@ -471,7 +478,7 @@ std::string App::render_postmatch() {
|
||||
detail += "<div><dt>" + live_text(label) + "</dt><dd>" +
|
||||
live_text(postmatch_count(final.at(key)[side])) +
|
||||
"</dd></div>";
|
||||
detail += "<div><dt>Zuschauer</dt><dd>—</dd></div></dl>";
|
||||
detail += "<div><dt>Zuschauer</dt><dd>" + live_text(postmatch_count(match->at("attendance"))) + "</dd></div></dl>";
|
||||
} else
|
||||
detail += "<p>" +
|
||||
live_text("Keine Partie dieses Teams in der gehaltenen "
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "launch/rml_path.hpp"
|
||||
#include "launch/rml_video.hpp"
|
||||
#include "modern/ui/controls.hpp"
|
||||
#include "modern/ui/live_match_info.hpp"
|
||||
#include "modern/ui/script_locator.hpp"
|
||||
#include "modern/ui/select_menu.hpp"
|
||||
#include "modern/ui/demo_calendar.hpp"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_live.hpp"
|
||||
#include "modern/ui/live_match_info.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
@@ -111,6 +112,27 @@ int main(int argc, char **argv) {
|
||||
Json{{"fixture_id", "wrong"}}}))
|
||||
require(!query_demo_live(*f.world, initial.state, initial.revision, query).at("ok"), "unsupported/stale request rejected");
|
||||
|
||||
require(live_match_info_text(live.at("matches")[0], false) == "26.400 Zuschauer · 18 °C · sonnig",
|
||||
"pre-match metadata is available before revealing any event");
|
||||
auto old_recording = live;
|
||||
for (auto &match : old_recording["matches"]) { match.erase("attendance"); match.erase("weather"); }
|
||||
require(valid_live_fixture(old_recording) && live_match_info_text(old_recording.at("matches")[0], false) ==
|
||||
"Zuschauer — · Wetter —", "old recordings remain valid without invented metadata");
|
||||
const Json zero = {{"attendance", 0}, {"weather", {{"temperature", 0}, {"rain", 4}}}};
|
||||
require(live_match_info_text(zero, false) == "0 Zuschauer · 0 °C · Regen", "known zero crowd and temperature are not missing");
|
||||
require(live_match_info_text({{"attendance", 1200}, {"weather", {{"temperature", -3}, {"rain", 6}}}}, false) ==
|
||||
"1.200 Zuschauer · -3 °C · Schnee", "signed temperature and original weather pictogram codes");
|
||||
require(live_match_info_text(zero, true) == "0 Zuschauer · Halle", "indoor ignores outdoor weather");
|
||||
for (const auto &bad : Json::array({Json{{"attendance", -1}}, Json{{"attendance", "1000"}},
|
||||
Json{{"weather", "sun"}}, Json{{"weather", {{"rain", 8}}}},
|
||||
Json{{"weather", {{"temperature", 128}}}},
|
||||
Json{{"weather", {{"temperature", UINT64_MAX}}}}})) {
|
||||
auto malformed = live; malformed["matches"][0].update(bad);
|
||||
require(!valid_live_fixture(malformed), "malformed optional metadata rejects without changing playback");
|
||||
}
|
||||
require(source.snapshot().state == initial.state && source.snapshot().revision == initial.revision &&
|
||||
source.dirty() == dirty, "formatting pre-match information is read-only");
|
||||
|
||||
LivePlayback playback;
|
||||
require(playback.open(live, "manager:0"), "recording opens paused");
|
||||
require(playback.sequence() == 0 && playback.speed() == 0 && !playback.elapse(100000),
|
||||
|
||||
@@ -93,19 +93,28 @@ int main(int argc, char **argv) {
|
||||
review.at("overview").at("chances") == 28 &&
|
||||
review.at("overview").at("scope") == "recorded_human_matches",
|
||||
"overview aggregates final recorded matches once, not once per human or whole league");
|
||||
require(review.at("overview").at("attendance").is_null() &&
|
||||
require(review.at("overview").at("attendance") == 57550 &&
|
||||
!review.at("eleven").at("available").get<bool>() && review.at("eleven").at("reason") == "not_recorded" &&
|
||||
review.at("eleven").at("rows").empty(), "unrecorded crowd and nominations stay unknown");
|
||||
review.at("eleven").at("rows").empty(), "crowds counted once per match while unrecorded nominations stay unknown");
|
||||
require(review.at("tables").size() == 1 && review.at("tables")[0].at("match_ids").size() == 2 &&
|
||||
review.at("tables")[0].at("rows") == recording.at("frames").back().at("matches")[0].at("standings") &&
|
||||
review.at("tables")[0].at("wins").is_null(), "shared final table is copied verbatim without season formula");
|
||||
for (size_t i = 0; i < review.at("matches").size(); ++i) {
|
||||
const auto &row = review.at("matches")[i];
|
||||
require(row.at("final") == recording.at("frames").back().at("matches")[i] &&
|
||||
row.at("id") == recording.at("matches")[i].at("id") && row.at("attendance").is_null(),
|
||||
row.at("id") == recording.at("matches")[i].at("id") &&
|
||||
row.at("attendance") == recording.at("matches")[i].at("attendance") &&
|
||||
row.at("weather") == recording.at("matches")[i].at("weather"),
|
||||
"result fields and identities equal exact final snapshot");
|
||||
for (const auto &event : row.at("events")) require(event.at("match_id") == row.at("id"), "events cannot leak from another match");
|
||||
}
|
||||
auto old_recording = recording;
|
||||
for (auto &match : old_recording["matches"]) { match.erase("attendance"); match.erase("weather"); }
|
||||
const auto old_review = make_demo_post_match(old_recording, 8);
|
||||
require(old_review.at("overview").at("attendance").is_null() &&
|
||||
old_review.at("matches")[0].at("attendance").is_null() &&
|
||||
old_review.at("matches")[0].at("weather").is_null(),
|
||||
"old recordings still keep unrecorded crowds and weather unknown");
|
||||
require(source.read_post_match(request(recording)) == review, "DemoSource read hook gives pure final review");
|
||||
Json supplied = {{"schema", "openbmh-post-match-records@1"},
|
||||
{"fixture_id", recording.at("fixture_id")},
|
||||
|
||||
Reference in new issue
Block a user