Bind player rankings and fair play to recorded season events (by Codex)
This commit is contained in:
1 parent
6b4aa9772d
commit
738ecc7a09
27 files changed
+436
-36
No files matched your search
@@ -53,21 +53,21 @@ void App::rankings_restore_scroll() {
|
||||
}
|
||||
std::string App::render_scorers() {
|
||||
rankings_remember_scroll();
|
||||
const auto snapshot = snap();
|
||||
const auto club = manager(snapshot).value("club", "");
|
||||
const auto snapshot = engine_mode_?Snapshot{}:snap();
|
||||
const auto club = engine_mode_?engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>():manager(snapshot).value("club", "");
|
||||
if (!rankings_view_.is_object()) rankings_view_ = Json::object();
|
||||
if (!rankings_view_.contains("league")) rankings_view_["league"] = rankings_league(*world_, snapshot.state, club);
|
||||
const auto league_id = rankings_view_.value("league", std::string());
|
||||
const int scope = std::clamp(rankings_view_.value("scope", 0), 0, 1),
|
||||
if (!engine_mode_ && !rankings_view_.contains("league")) rankings_view_["league"] = rankings_league(*world_, snapshot.state, club);
|
||||
const auto league_id = engine_mode_?engine_rankings_value_.at("leagueId").get<std::string>():rankings_view_.value("league", std::string());
|
||||
const int scope = engine_mode_?engine_rankings_state_.at("scope").get<int>():std::clamp(rankings_view_.value("scope", 0), 0, 1),
|
||||
kind = std::clamp(rankings_view_.value("tab", 0), 0, 3);
|
||||
rankings_view_["scope"] = scope; rankings_view_["tab"] = kind;
|
||||
const auto *league = world_->find("competitions", league_id),
|
||||
*own = world_->find("clubs", club);
|
||||
const auto title = scope ? (own ? world_->name(*own) : "—")
|
||||
const auto title = engine_mode_?(scope?engine_rankings_value_.at("team").at("name").get<std::string>():engine_rankings_value_.at("league").at("name").get<std::string>()):scope ? (own ? world_->name(*own) : "—")
|
||||
: (league ? world_->name(*league) : "—");
|
||||
const auto nation = scope ? (own ? own->value("nation", "") : "")
|
||||
: (league ? league->value("nation", "") : "");
|
||||
const auto rows = demo_scorer_rows(*world_, league_id, club, scope, kind);
|
||||
const auto rows = engine_mode_?engine_rankings_value_.at("categories").at(size_t(kind)):demo_scorer_rows(*world_, league_id, club, scope, kind);
|
||||
const auto key = "scorers:" + league_id + ":" + std::to_string(scope) + ":" + std::to_string(kind);
|
||||
const auto player_button = [&](const Json &r, bool leader) {
|
||||
const auto id = r.at("player").get<std::string>();
|
||||
@@ -80,12 +80,12 @@ std::string App::render_scorers() {
|
||||
};
|
||||
const auto club_button = [&](const Json &r, bool leader) {
|
||||
const auto id = r.at("club").get<std::string>();
|
||||
return btn("club-detail", label(world_->find("clubs", id), leader ? 34 : 42), "rankings-club-button " + std::string(id == club ? "current" : ""),
|
||||
return btn("club-detail", engine_mode_?"<span class=\"club-label\">"+crest(world_->find("clubs",id),leader?34:42)+"<span>"+esc(r.at("club_name").get<std::string>())+"</span></span>":label(world_->find("clubs", id), leader ? 34 : 42), "rankings-club-button " + std::string(id == club ? "current" : ""),
|
||||
"id=\"rankings-club-" + esc(r.at("player").get<std::string>()) + "\" data-id=\"" + esc(id) + "\"");
|
||||
};
|
||||
std::string out = "<section class=\"rankings-scorers kind-" + std::to_string(kind) + "\"><header class=\"rankings-heading\"><div><h2>" + esc(title) +
|
||||
"</h2><span>" + esc(world_->nation_name(nation)) + " · Saison " + esc(rankings_season(snapshot.state, *world_)) +
|
||||
"</span></div><p>Spielwerte fiktiv</p></header><nav class=\"rankings-tabs\" role=\"tablist\" aria-label=\"Spielerstatistik auswählen\">";
|
||||
"</h2><span>" + esc(world_->nation_name(nation)) + " · Saison " + esc(engine_mode_?engine_rankings_value_.at("season").get<std::string>():rankings_season(snapshot.state, *world_)) +
|
||||
"</span></div>"+(engine_mode_?"":"<p>Spielwerte fiktiv</p>")+"</header><nav class=\"rankings-tabs\" role=\"tablist\" aria-label=\"Spielerstatistik auswählen\">";
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const auto icon = i < 2 ? picture(renderer_.diagram("rankings-icon-" + std::to_string(i) + "-" + theme_, rankings_icon(i, theme_ == "silver" ? "#233443" : theme_ == "matchday" ? "#efeded" : "#b9cddd"), 102), 34, 34)
|
||||
: "<span class=\"rankings-card-icon " + std::string(i == 2 ? "yellow" : "red") + "\"></span>";
|
||||
@@ -103,7 +103,7 @@ std::string App::render_scorers() {
|
||||
const auto &r = rows[i];
|
||||
out += "<div class=\"rankings-row " + std::string(i % 2 ? "striped" : "") + "\" role=\"row\" data-rank=\"" + r.at("rank").dump() + "\" data-value=\"" + r.at("value").dump() + "\"><div class=\"rankings-rest-player\"><span class=\"rankings-rank\">" + r.at("rank").dump() + ".</span>" + player_button(r, false) + "</div><div>" + club_button(r, false) + "</div><div>" + rankings_cell_text(r.at("value").dump()) + "</div></div>";
|
||||
}
|
||||
if (rows.empty()) out += "<p class=\"rankings-empty\">" + rankings_cell_text("Keine Spieler mit Einträgen in dieser Kategorie.") + "</p>";
|
||||
if (rows.empty()) out += "<div class=\"rankings-row\" role=\"row\"><div>"+rankings_cell_text("Keine Einträge in dieser Kategorie.")+"</div><div></div><div></div></div>";
|
||||
out += "</div></div></div><nav class=\"report-footer rankings-footer\">";
|
||||
if (!scope) out += report_picker("country", 0, 854.666667) + report_picker("league", 878.666667, 854.666667);
|
||||
else out += "<span class=\"rankings-own-club\">" + label(own, 42) + "</span>";
|
||||
@@ -114,7 +114,7 @@ std::string App::render_scorers() {
|
||||
|
||||
std::string App::render_fairplay() {
|
||||
rankings_remember_scroll();
|
||||
const auto rows = demo_fairplay_rows(*world_);
|
||||
const auto rows = engine_mode_?engine_fairplay_value_.at("rows"):demo_fairplay_rows(*world_);
|
||||
std::string out = "<section class=\"rankings-fairplay\"><header class=\"rankings-fair-heading\"><p>Strafpunkte · weniger ist besser</p><div><span class=\"rankings-yellow\">Gelb · 1 Punkt</span><span class=\"rankings-red\">Rot · 4 Punkte</span></div></header><div id=\"rankings-list\" class=\"rankings-fair-list\" data-scroll-key=\"fairplay\"><div class=\"rankings-table\" role=\"table\"><div class=\"rankings-fair-row rankings-head\" role=\"row\"><div>" + rankings_cell_text("Pl. / Verein") + "</div><div>" + rankings_cell_text("Gelb") + "</div><div>" + rankings_cell_text("Rot") + "</div><div>" + rankings_cell_text("Punkte") + "</div></div>";
|
||||
for (size_t i = 0; i < rows.size(); ++i) {
|
||||
const auto &r = rows[i];
|
||||
|
||||
Reference in new issue
Block a user