Pitch photographs lie behind the match sheet; a managed ground shows how full it is
The stadium pictures give way to nine photographs of the pitch, used unscaled. The live read carries the capacity of a managed home ground. The manager's eleven stays on the team page after the final whistle, and the cards of two to four matches keep their grid. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
13f5b1e4d4
commit
20b8406763
42 files changed
+73
-213
No files matched your search
@@ -320,7 +320,7 @@ Json engine_live_progress(const Json &previous, const Json &state, const Json &b
|
||||
} catch (const std::exception &) {}
|
||||
out["matches"].push_back({{"id", id}, {"home", home}, {"away", away}, {"owners", owners}, {"competition", competition},
|
||||
|
||||
{"attendance", m.value("attendance", Json())}, {"weather", m.value("weather", Json())},
|
||||
{"attendance", m.value("attendance", Json())}, {"weather", m.value("weather", Json())}, {"capacity", m.value("capacity", Json())},
|
||||
{"lineups", m.value("lineups", Json())}});
|
||||
}
|
||||
if (out.at("owners").empty() || out.at("matches").empty()) return failure("live_no_human_match");
|
||||
|
||||
@@ -244,7 +244,7 @@ void App::engine_render() {
|
||||
const auto size = context_->GetDimensions();
|
||||
// behind the match sheet lies a stadium that suits the crowd and the weather
|
||||
const std::string ground = live_backdrop();
|
||||
element("background")->SetInnerRML(img(ground.empty() ? "background" : ground, size.x / scale_, size.y / scale_, false, true, ground.empty() ? 2048 : 2400));
|
||||
element("background")->SetInnerRML(img(ground.empty() ? "background" : ground, size.x / scale_, size.y / scale_, false, true, ground.empty() ? 2048 : 4096));
|
||||
element("background")->SetProperty("filter", !ground.empty() ? "brightness(0.78)" : theme_ == "silver" ? "saturate(0.2) brightness(0.9)" : theme_ == "matchday" ? "saturate(0.13) brightness(0.56)" : "saturate(0.34) brightness(0.70)");
|
||||
if (!contracts_dialog_.empty()) {
|
||||
Rml::ElementList underlay; doc_->QuerySelectorAll(underlay, "#contracts-underlay button,.contracts-actions button,#window-close");
|
||||
|
||||
@@ -37,9 +37,18 @@ bool App::live_open() {
|
||||
refresh(); return true;
|
||||
}
|
||||
bool App::engine_live_open(const Json &recording) {
|
||||
const auto fixture = engine_live_fixture(recording, engine_data_);
|
||||
auto fixture = engine_live_fixture(recording, engine_data_);
|
||||
// after a kickoff that was followed live the ticker stays on the final whistle
|
||||
const bool at_end = engine_live_at_end_ && scene_ == "live";
|
||||
// ... and the manager's eleven stays the one that finished the match, whatever desk the day ends on
|
||||
if (at_end && fixture.value("ok", false) && !engine_live_roster_.empty())
|
||||
for (auto &owner : fixture.at("owners"))
|
||||
if (owner.at("id") == live_.owner() && owner.contains("view") && owner.at("view").is_object()) owner["view"]["rows"] = engine_live_roster_;
|
||||
// ... and each ground keeps the places the running match knew
|
||||
if (at_end && fixture.value("ok", false) && live_.available())
|
||||
for (auto &match : fixture.at("matches"))
|
||||
for (const auto &known : live_.fixture().at("matches"))
|
||||
if (known.at("home").at("id") == match.at("home").at("id") && known.contains("capacity") && !match.contains("capacity")) match["capacity"] = known.at("capacity");
|
||||
engine_live_at_end_ = false;
|
||||
if (!fixture.value("ok", false) || !(at_end ? live_.follow(fixture) : live_.open(fixture, ""))) {
|
||||
engine_notice_ = "Spieltag gespielt · Der Ticker kann diese Aufzeichnung nicht zeigen (" +
|
||||
|
||||
@@ -126,8 +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: a ground of about the crowd's size in about this
|
||||
// weather. Empty when the match is played in a hall or the pictures are not installed.
|
||||
// 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.
|
||||
std::string App::live_backdrop() const {
|
||||
if (scene_ != "live" || !live_.available()) return {};
|
||||
try {
|
||||
@@ -137,35 +138,17 @@ std::string App::live_backdrop() const {
|
||||
const Json *match = &fixture.at("matches").front();
|
||||
if (owner.is_object())
|
||||
for (const auto &row : fixture.at("matches")) if (row.at("id") == owner.at("match_id")) match = &row;
|
||||
const int64_t crowd = match->contains("attendance") && match->at("attendance").is_number_integer() ? match->at("attendance").get<int64_t>() : 20000;
|
||||
const int size = crowd < 8000 ? 0 : crowd < 20000 ? 1 : crowd < 40000 ? 2 : 3;
|
||||
int code = 2;
|
||||
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>();
|
||||
// the eight weather pictures as five kinds of sky: sun, fair, cloud, rain, snow
|
||||
static constexpr std::array<int, 8> kSky{0, 1, 2, 2, 3, 3, 4, 4};
|
||||
const int sky = kSky[size_t(std::clamp(code, 0, 7))];
|
||||
struct Ground { int size, sky; const char *key; };
|
||||
static constexpr std::array<Ground, 24> grounds{{
|
||||
{0, 0, "match.0-sun-a"}, {0, 2, "match.0-cloud-a"}, {0, 3, "match.0-rain-a"},
|
||||
{1, 0, "match.1-sun-a"}, {1, 0, "match.1-sun-b"}, {1, 0, "match.1-sun-c"}, {1, 1, "match.1-fair-a"}, {1, 1, "match.1-fair-b"},
|
||||
{1, 2, "match.1-cloud-a"}, {1, 2, "match.1-cloud-b"}, {1, 3, "match.1-rain-a"}, {1, 4, "match.1-snow-a"}, {1, 4, "match.1-snow-b"},
|
||||
{2, 0, "match.2-sun-a"}, {2, 0, "match.2-sun-b"}, {2, 0, "match.2-sun-c"}, {2, 1, "match.2-fair-a"},
|
||||
{3, 1, "match.3-fair-a"}, {3, 1, "match.3-fair-b"}, {3, 1, "match.3-fair-c"}, {3, 2, "match.3-cloud-a"},
|
||||
{3, 3, "match.3-rain-a"}, {3, 3, "match.3-rain-b"}, {3, 4, "match.3-snow-a"}}};
|
||||
// the nearest in size and sky; among equals the home club keeps its ground
|
||||
int best = 99;
|
||||
std::vector<const char *> nearest;
|
||||
for (const auto &ground : grounds) {
|
||||
if (!gui_.contains(ground.key)) continue;
|
||||
const int cost = std::abs(ground.size - size) + std::abs(ground.sky - sky);
|
||||
if (cost < best) { best = cost; nearest.clear(); }
|
||||
if (cost == best) nearest.push_back(ground.key);
|
||||
}
|
||||
if (nearest.empty()) return {};
|
||||
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 {};
|
||||
size_t hash = 2166136261u;
|
||||
for (const unsigned char c : match->at("home").at("id").get<std::string>()) hash = (hash ^ c) * 16777619u;
|
||||
return nearest[hash % nearest.size()];
|
||||
return fair[hash % fair.size()];
|
||||
} catch (const std::exception &) { return {}; }
|
||||
}
|
||||
// Played in a hall: the fixture says so, or the engine named the competition a hall tournament.
|
||||
@@ -606,8 +589,16 @@ std::string App::live_sheet(const std::string &over) {
|
||||
const Json *match = &fixture.at("matches").front();
|
||||
for (const auto &row : fixture.at("matches")) if (row.at("id") == owner.at("match_id")) match = &row;
|
||||
std::string crowd = live_attendance_text(*match);
|
||||
std::string filling, bar;
|
||||
if (!indoor && match->contains("capacity") && match->at("capacity").is_number_integer() && match->at("capacity").get<int64_t>() > 0 &&
|
||||
match->contains("attendance") && match->at("attendance").is_number_integer()) {
|
||||
const int64_t places = match->at("capacity").get<int64_t>(), seen = std::min(places, match->at("attendance").get<int64_t>());
|
||||
const int percent = int(std::lround(100.0 * seen / places));
|
||||
filling = "von " + number(places) + " Plätzen · " + std::to_string(percent) + " % ausgelastet · ";
|
||||
bar = "<span class=\"mv-capbar\"><div style=\"width:" + std::to_string(percent) + "%;\"></div></span>";
|
||||
}
|
||||
out += "<div class=\"mv-info\"><div class=\"main\"><span class=\"mv-k\">" + esc(pg_upper(indoor ? "Halle" : "Stadion")) + "</span><span class=\"big\">" + esc(crowd) +
|
||||
"</span><span class=\"sub\">" + esc("Heimspiel von " + match->at("home").at("name").get<std::string>()) + "</span></div>";
|
||||
"</span>" + bar + "<span class=\"sub\">" + esc(filling + "Heimspiel von " + match->at("home").at("name").get<std::string>()) + "</span></div>";
|
||||
const auto weather = match->value("weather", Json());
|
||||
if (!indoor && weather.is_object()) {
|
||||
const Json rain = weather.value("rain", Json()), temperature = weather.value("temperature", Json());
|
||||
|
||||
@@ -1279,7 +1279,7 @@ class App final : public Rml::EventListener {
|
||||
// behind the match sheet lies a stadium that suits the crowd and the weather
|
||||
const std::string ground = live_backdrop();
|
||||
const auto background =
|
||||
img(ground.empty() ? "background" : ground, size.x / scale_, size.y / scale_, false, true, ground.empty() ? 2048 : 2400);
|
||||
img(ground.empty() ? "background" : ground, size.x / scale_, size.y / scale_, false, true, ground.empty() ? 2048 : 4096);
|
||||
element("background")->SetInnerRML(background);
|
||||
element("background")
|
||||
->SetProperty("filter", !ground.empty() ? "brightness(0.78)" : scene_ == "main" ? "none"
|
||||
|
||||
Reference in new issue
Block a user