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
@@ -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"})