// SPDX-License-Identifier: GPL-3.0-only // Who plays this career as a human: the page "Spieler" exists only where there is more than one. Json App::bank_players() const { try { if (engine_mode_) return engine_manager_value_.is_object() && engine_manager_value_.contains("people") ? engine_career_context().at("active_managers") : Json::array(); if (source_ && world_) return demo_career_context(snap().state, *snap().world).at("active_managers"); } catch (const std::exception &) { } return Json::array(); } // Finanzen > Bank, Immobilien, Aktien, Sparbuch, Spieler: five pages of one menu. `bank_view_` // says which: "credit" (the bank with what the club owns and its loan), "properties", "stocks", // "savings" or "players". std::string App::render_bank() { const auto projected = engine_mode_ ? engine_bank_projection(engine_data_) : Json(); const auto snapshot = engine_mode_ ? Snapshot{0, world_, projected.at("state")} : snap(); const auto assets = engine_mode_ ? projected.at("assets") : demo_bank_assets(*world_); const auto summary = engine_mode_ ? projected.at("summary") : demo_bank_summary(snapshot.state, *world_); const auto bank_money = [&](int64_t value) { return engine_mode_ ? money(value, {{"code", "EUR"}, {"minor_units", 2}}) : cash(value); }; const int property_count = int(assets.at("properties").size()), stock_count = int(assets.at("stocks").size()); if (!summary.value("ok", false)) return {}; if (bank_view_ != "properties" && bank_view_ != "stocks" && bank_view_ != "savings" && bank_view_ != "players") bank_view_ = "credit"; if (bank_view_ == "players" && bank_players().size() < 2) bank_view_ = "credit"; const auto &finance = snapshot.state.at("finance"); bank_property_ = std::clamp(bank_property_, 0, property_count - 1); bank_stock_ = std::clamp(bank_stock_, 0, stock_count - 1); bank_owned_ = bank_property_; // the board has one chosen property: it is bought and sold const auto calc = [&](const char *label, const char *kind, const std::string &css, bool on = true) { return pg_button("bank-calc", label, css, "id=\"bank-" + std::string(kind) + "\" data-kind=\"" + kind + "\"" + (on ? "" : " disabled=\"disabled\"")); }; const auto kv = [](const std::string &key, const std::string &value, const std::string &css = std::string()) { return "