// SPDX-License-Identifier: GPL-3.0-only // The club's surroundings: three youth teams and three members of staff, six cards in two // rows. Each card carries its monthly budget as a row of stars, its picture and its cost. std::string App::render_environment() { const auto snapshot = engine_mode_ ? Snapshot{input_revision(), world_, Json::object()} : snap(); const std::string unavailable = "
Die Umfeldvorschau ist derzeit nicht verfügbar.
"; if (!snapshot.world) return unavailable; const auto view = engine_mode_ ? engine_environment_projection(engine_data_) : demo_environment_rows(snapshot.state, *snapshot.world); if (!view.value("ok", false)) return unavailable; const auto currency = engine_mode_ ? Json{{"code", "EUR"}, {"minor_units", 2}} : snapshot.world->manifest().value("currency", Json::object()); const auto star = [&](bool active) { const std::string colour = active ? (theme_ == "silver" ? "#b2622d" : theme_ == "matchday" ? "#3f7a3a" : "#e0a25f") : (theme_ == "silver" ? "#c0b6a5" : theme_ == "matchday" ? "#afc09a" : "#525966"); const std::string svg = "" ""; return picture(renderer_.diagram("environment-star-" + theme_ + (active ? "-funded" : "-unfunded"), svg, 96), 46, 46); }; const auto &rows = view.at("rows"); int64_t total = 0; for (const auto &row : rows) total += row.at("cost").get(); page_title_ = "Umfeld – " + money(total, currency) + " pro Monat"; // a card is a third of the page wide; its picture takes the height that is left const double card_width = (2799 - 2 * 31.5) / 3, picture_width = card_width - 2 * 36 - 4, picture_height = 500; std::string out = "
"; for (size_t i = 0; i < rows.size(); ++i) { const auto &row = rows[i]; const auto name = row.at("name").get(), id = row.at("id").get(); const auto level = row.at("level").get(); out += "

" + esc(name) + "

" + (i < 3 ? "Platz " + std::to_string(row.at("rank").get()) + " · " + std::to_string(row.at("league").get()) + ". Liga" : std::string()) + "
"; for (int value = 0; value <= 6; ++value) { const bool selected = value == level; out += btn("environment-level", value ? star(value <= level) : std::string("×"), "env-level " + std::string(value == 0 ? "zero " : "") + (selected ? "selected" : ""), "id=\"environment-level-" + std::to_string(i) + "-" + std::to_string(value) + "\" data-index=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(value) + "\" aria-pressed=\"" + (selected ? "true" : "false") + "\" aria-label=\"" + esc(name + ": " + std::to_string(value) + (value == 1 ? " Stern" : " Sterne")) + "\" " + std::string(engine_mode_ && value > row.at("max").get() ? "disabled " : "") + "title=\"" + (value ? std::to_string(value) + (value == 1 ? " Stern" : " Sterne") : "Budget auf null setzen") + "\""); } out += "
" + img("environment." + row.at("image").get() + "." + std::to_string(row.at("cell").get()), picture_width, picture_height, false, true, 1024) + "
Monatskosten" + esc(money(row.at("cost").get(), currency) + " / Monat") + "
"; } return out + "
"; }