Show attendance and weather before live ticker kickoff (by Codex)

This commit is contained in:
Codex committed 2026-10-27 10:59:45 +01:00
1 parent ef25407484
commit b845bbfcbc
10 files changed
+144 -14

No files matched your search

+22
View File
@@ -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),