Rain and snow show rain photographs behind the match sheet

Five rain photographs replace the wet pitch picture, which showed a branded
ball. Snow uses the one with sleet on the pane. They are listed with the
pitch photographs in the third-party notices.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-17 09:15:15 +01:00
1 parent 23a4121d17
commit 52157159cb
9 files changed
+67 -21

No files matched your search

+15 -9
View File
@@ -126,9 +126,9 @@ std::string App::live_weather_icon(int code, double size) {
else g = cloud("#aeb6ba") + "<g fill='#8fb0c8'><circle cx='14' cy='35' r='1.7'/><circle cx='21' cy='36.5' r='1.7'/><circle cx='28' cy='35' r='1.7'/></g>";
return picture(renderer_.diagram("mv-weather-" + std::to_string(std::clamp(code, 0, 7)), "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'>" + g + "</svg>", 160), size, size);
}
// The picture behind the match sheet: one of the pitch photographs. The home club keeps its
// picture; in rain or snow it is the wet pitch at dusk. Empty when the match is played in a
// hall or the pictures are not installed.
// The picture behind the match sheet. In fair weather it is one of the pitch photographs and
// the home club keeps its picture; in rain it is one of the rain photographs, in snow the one
// with sleet on the pane. Empty when the match is played in a hall or no picture is installed.
std::string App::live_backdrop() const {
if (scene_ != "live" || !live_.available()) return {};
try {
@@ -141,14 +141,20 @@ std::string App::live_backdrop() const {
int code = 0;
if (match->contains("weather") && match->at("weather").is_object() && match->at("weather").value("rain", Json()).is_number_integer())
code = match->at("weather").at("rain").get<int>();
if (code >= 4 && gui_.contains("match.pitch-2")) return "match.pitch-2";
std::vector<std::string> fair;
for (const int number : {1, 3, 4, 5, 6, 7, 8, 9})
if (const std::string key = "match.pitch-" + std::to_string(number); gui_.contains(key)) fair.push_back(key);
if (fair.empty()) return {};
const auto installed = [&](const char *family, std::initializer_list<int> numbers) {
std::vector<std::string> keys;
for (const int number : numbers)
if (const std::string key = std::string(family) + std::to_string(number); gui_.contains(key)) keys.push_back(key);
return keys;
};
std::vector<std::string> pictures;
if (code >= 6) pictures = installed("match.rain-", {4});
if (pictures.empty() && code >= 4) pictures = installed("match.rain-", {1, 2, 3, 4, 5});
if (pictures.empty()) pictures = installed("match.pitch-", {1, 3, 4, 5, 6, 7, 8, 9});
if (pictures.empty()) return {};
size_t hash = 2166136261u;
for (const unsigned char c : match->at("home").at("id").get<std::string>()) hash = (hash ^ c) * 16777619u;
return fair[hash % fair.size()];
return pictures[hash % pictures.size()];
} catch (const std::exception &) { return {}; }
}
// Played in a hall: the fixture says so, or the engine named the competition a hall tournament.