// SPDX-License-Identifier: GPL-3.0-only std::string App::render_advertising() { const auto snapshot = engine_mode_ ? Snapshot{input_revision(), world_, Json::object()} : snap(); const auto view = engine_mode_ ? engine_advertising_projection(engine_data_) : demo_advertising_view(snapshot.state, *world_); const auto ad_cash = [&](int64_t value) { return engine_mode_ ? money(value, {{"code", "EUR"}, {"minor_units", 2}}) : cash(value); }; if (!view.value("ok", false)) return {}; const auto brand = [&](const Json &c) { if (c.at("sponsor") == -1) return std::string(); return "() % 5) + "\">" + esc(c.at("name").get()) + ""; }; std::string out = "
"; for (int i = 0; i < 14; ++i) { const auto &c = view.at("slots")[size_t(i)]; out += btn("ad-contract", (c.at("active") == true ? brand(c) : "Platz frei") + "Bande " + std::to_string(i + 1) + "", "advertising-board " + std::string(advertising_selected_ == i ? "selected" : ""), "id=\"ad-contract-" + std::to_string(i) + "\" data-ad-contract=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\" aria-pressed=\"" + (advertising_selected_ == i ? "true" : "false") + "\" aria-label=\"Bande " + std::to_string(i + 1) + ", " + esc(c.at("name").get()) + "\" style=\"" + rect(16 + (i % 7) * (354.285714 + 16), 16 + (i / 7) * 145, 354.285714, 129) + "\""); } out += "
"; const std::array headings{"Trikotwerbung", "Fanartikel", "Öffentlichkeitsarbeit", "Fanbetreuung"}; for (int i = 0; i < 4; ++i) { std::string body = "" + std::string(headings[size_t(i)]) + "
" + img("advertising.panel." + std::to_string(i), 510, 510, false, false, 1000) + "
"; if (i == 0) body += brand(view.at("slots")[14]); else body += "" + esc(ad_cash(view.at("spending")[size_t(i - 1)].at("amount").get())) + ""; out += btn(i == 0 ? "ad-contract" : "ad-spending", body, "advertising-card advertising-panel " + std::string(i == 0 ? "advertising-shirt " : "") + (i == 0 && advertising_selected_ == 14 ? "selected" : ""), "id=\"" + std::string(i == 0 ? "ad-contract-14" : "ad-spending-" + std::to_string(i - 1)) + "\" data-id=\"" + std::to_string(i == 0 ? 14 : i - 1) + "\" " + (i == 0 ? "data-ad-contract=\"14\" aria-pressed=\"" + std::string(advertising_selected_ == 14 ? "true" : "false") + "\" " : "data-ad-spending=\"" + std::to_string(i - 1) + "\" ") + "style=\"" + rect(i * 658.5, 346, 636.5, 650) + "\""); } out += btn("ad-contract", "TV-Rechte
" + img("art.advertising-tv-v1.png", 540, 540, false, false, 1000) + "
" + brand(view.at("slots")[15]), "advertising-card advertising-tv " + std::string(advertising_selected_ == 15 ? "selected" : ""), "id=\"ad-contract-15\" data-ad-contract=\"15\" data-id=\"15\" aria-pressed=\"" + std::string(advertising_selected_ == 15 ? "true" : "false") + "\""); out += "
"; if (advertising_selected_ < 0 || advertising_selected_ > 15) { out += "

Werbung und Vereinsausgaben

" "

Bande, Trikot oder TV-Rechte auswählen.

Die drei Ausgabenbilder öffnen die Zahleneingabe.

"; } else { const auto &choices = engine_mode_ ? view.at("slots")[size_t(advertising_selected_)].at("choices") : Json::array(); if (engine_mode_) advertising_offer_ = std::clamp(advertising_offer_, 0, int(choices.size()) - 1); const auto quote = engine_mode_ ? engine_advertising_quote(engine_data_, advertising_selected_, advertising_offer_) : demo_advertising_quote(snapshot.state, advertising_selected_, advertising_offer_, *world_); const bool active = quote.at("active"); const bool cycle = engine_mode_ ? quote.at("can_cycle").get() : !active; const bool accept = engine_mode_ ? quote.at("can_accept").get() : !active; out += "
" + brand(quote) + "
" + btn("ad-offer", "‹", "ad-offer-arrow", "id=\"ad-offer-previous\" data-step=\"-1\" aria-label=\"Vorheriges Angebot\" " + std::string(cycle ? "" : "disabled")) + btn("ad-offer", "›", "ad-offer-arrow", "id=\"ad-offer-next\" data-step=\"1\" aria-label=\"Nächstes Angebot\" " + std::string(cycle ? "" : "disabled")) + "
" + esc(quote.at("label").get()) + "" + esc(quote.at("name").get()) + "
Dauer" + std::to_string(quote.at("months").get()) + " Monate" + (engine_mode_ && quote.at("boards") > 1 ? " · " + std::to_string(quote.at("boards").get()) + " Banden" : std::string()) + "
" + (active ? "Vertrag" : "Angebot") + "" + esc(ad_cash(quote.at("amount").get())) + " / Monat
"; } if (engine_mode_) out += "Vereinsprognose / Monat"; out += "
"; for (const auto &[label, key] : std::array, 3>{{{"Einnahmen", "income"}, {"Ausgaben", "expenses"}, {"Saldo", "balance"}}}) out += "
" + std::string(label) + "" + esc(ad_cash(view.at(key).get())) + "
"; return out + "
"; }