Files
Dreierpack-Manager/src/modern/ui/transfer_screens.inc
T
MichaelandClaude Fable 5.2 7424b09738 Poaching in two steps: the club is asked and names its price, then the offer is made
transfer.submit takes three more actions. poach runs the original's checks
and start_poach on a player of another club; where an offer can be made the
offer editor stays open and the answer carries what the club asks and the
bounds the editor accepts. poachOffer is decided at once, poachCancel
closes the editor. The attempt counts from the first step, as in the original.

The transfer market's Abwerben opens the clubs of a league, reads the
chosen club's squad, asks before the attempt is spent and then shows the
club's demand with the offer to be written.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 15:26:03 +01:00

570 lines
47 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
namespace {
const Json &transfer_ui_field(const Json &v, const char *key) {
static const Json empty;
if (v.is_object()) {
auto i = v.find(key);
if (i != v.end())
return *i;
}
return empty;
}
std::string transfer_ui_text(const Json &v, const std::string &fallback = "—") {
return v.is_string() && !v.get_ref<const std::string &>().empty()
? v.get<std::string>()
: fallback;
}
std::string transfer_ui_number(const Json &v) {
if (v.is_number_integer())
return number(v.get<int64_t>());
if (!v.is_number())
return "—";
std::ostringstream s;
s.imbue(std::locale::classic());
s << std::setprecision(4) << v.get<double>();
auto out = s.str();
std::replace(out.begin(), out.end(), '.', ',');
return out;
}
std::string transfer_ui_role(const Json &v) {
const auto p = transfer_ui_text(v, "");
return p == "gk" ? "TW"
: p == "def" ? "ABW"
: p == "mid" ? "MIT"
: p == "fwd" ? "STU"
: "—";
}
std::string transfer_ui_club(const Snapshot &s) {
return demo_career_manager(s.state).value("club", "");
}
Json transfer_ui_find(const Json &rows, const std::string &id) {
if (rows.is_array())
for (const auto &r : rows)
if (r.at("id") == id)
return r;
return nullptr;
}
const std::array<const char *, 7> transfer_ui_bonuses{
"Torprämie", "Punktprämie", "Auflaufprämie", "Meisterprämie",
"Prämie Pl. 2–5", "Prämie Pl. 6–10", "Nichtabstiegsprämie"};
} // namespace
void App::transfer_remember_scroll() {
if (!transfer_view_.is_object())
return;
for (const auto &[id, key] :
std::array<std::pair<const char *, const char *>, 4>{
{{"transfer-roster-scroll", "roster_top"},
{"transfer-market-scroll", "market_top"},
{"transfer-poach-scroll", "poach_top"},
{"transfer-orders-scroll", "orders_top"}}})
if (auto *node = element(id)) {
transfer_view_[key] = node->GetScrollTop();
if (std::string(id) == "transfer-roster-scroll")
transfer_view_["roster_left"] = node->GetScrollLeft();
}
if (auto *node = element("transfer-poach-scroll")) {
const auto key = node->GetAttribute<Rml::String>("data-scope", "");
if (!key.empty())
transfer_view_["poach_scrolls"][key] = node->GetScrollTop();
}
if (auto *node = element("transfer-dialog-scroll")) {
const auto kind = node->GetAttribute<Rml::String>("data-dialog", "");
if (!kind.empty())
transfer_view_["dialog_scrolls"][kind] = node->GetScrollTop();
}
}
void App::transfer_restore_scroll() {
if (menu_ != "transfer" || !transfer_view_.is_object() ||
!transfer_view_.value("restore_scroll", false))
return;
transfer_view_["restore_scroll"] = false;
for (const auto &[id, key] :
std::array<std::pair<const char *, const char *>, 4>{
{{"transfer-roster-scroll", "roster_top"},
{"transfer-market-scroll", "market_top"},
{"transfer-poach-scroll", "poach_top"},
{"transfer-orders-scroll", "orders_top"}}})
if (auto *node = element(id)) {
const auto &v = transfer_ui_field(transfer_view_, key);
if (v.is_number())
node->SetScrollTop(v.get<float>());
if (std::string(id) == "transfer-roster-scroll" &&
transfer_view_.contains("roster_left"))
node->SetScrollLeft(transfer_view_.at("roster_left").get<float>());
}
if (auto *node = element("transfer-poach-scroll")) {
const auto key = node->GetAttribute<Rml::String>("data-scope", "");
const auto &v = transfer_ui_field(
transfer_ui_field(transfer_view_, "poach_scrolls"), key.c_str());
if (v.is_number())
node->SetScrollTop(v.get<float>());
}
if (auto *node = element("transfer-dialog-scroll")) {
const auto kind = node->GetAttribute<Rml::String>("data-dialog", "");
const auto &v = transfer_ui_field(
transfer_ui_field(transfer_view_, "dialog_scrolls"), kind.c_str());
if (v.is_number())
node->SetScrollTop(v.get<float>());
}
}
std::string App::render_transfer() {
transfer_remember_scroll();
const auto snapshot = engine_mode_ ? Snapshot{} : snap();
const auto own = engine_mode_ ? engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>() : transfer_ui_club(snapshot);
const auto data = transfer_data();
if (!data.value("ok", false))
return {};
if (!transfer_view_.is_object() || !transfer_view_.contains("tab"))
transfer_view_ = {{"tab", 0},
{"complete", false},
{"scope", "active"},
{"page", 0},
{"side", "market"},
{"own", ""},
{"market", ""},
{"hover", ""},
{"query", data.at("query")},
{"dialog_scrolls", Json::object()}};
if (transfer_view_.value("applied_query", std::string()) !=
data.at("query").get<std::string>()) {
transfer_view_["query"] = data.at("query");
transfer_view_["applied_query"] = data.at("query");
}
const auto &ours = data.at("own"), &pool = data.at("market");
if (transfer_ui_find(ours, transfer_view_.value("own", std::string()))
.is_null())
transfer_view_["own"] = ours.empty() ? Json("") : ours[0].at("id");
if (transfer_ui_find(pool, transfer_view_.value("market", std::string()))
.is_null()) {
transfer_view_["market"] = "";
for (const auto &r : pool)
if (r.at("own") == false) {
transfer_view_["market"] = r.at("id");
break;
}
}
const bool complete = transfer_view_.value("complete", false),
b = transfer_view_.value("tab", 0) == 1;
const int pages = std::max(1, int((pool.size() + 5) / 6)),
page = std::clamp(transfer_view_.value("page", 0), 0, pages - 1);
transfer_view_["page"] = page;
Json chosen =
transfer_view_.value("side", std::string("market")) == "own"
? transfer_ui_find(ours, transfer_view_.value("own", std::string()))
: transfer_ui_find(pool,
transfer_view_.value("market", std::string()));
const auto hovered = transfer_view_.value("hover", std::string());
auto preview = transfer_ui_find(pool, hovered);
if (preview.is_null())
preview = chosen;
const auto listed = [&](const std::string &id) {
const auto &ls = engine_mode_ ? engine_transfer_value_.at("listed") : snapshot.state.at("transfer").at("listed");
return std::find(ls.begin(), ls.end(), id) != ls.end();
};
const auto trait = [&](const Json &v, bool foot) {
if (!v.is_number_integer())
return std::string("<span class=\"transfer-trait\">—</span>");
const int n = v.get<int>();
const std::array<const char *, 4> fl{"", "Links", "Beidfüßig", "Rechts"},
ty{"", "Defensiv", "Ausgeglichen", "Offensiv"};
const std::string path = n == 2 ? "M16 4L28 16L16 28L4 16Z"
: foot
? (n == 1 ? "M28 16H4M4 16L14 6M4 16L14 26"
: "M4 16H28M28 16L18 6M28 16L18 26")
: (n == 1 ? "M16 4V28M16 28L6 18M16 28L26 18"
: "M16 28V4M16 4L6 14M16 4L26 14");
const auto svg =
"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" "
"height=\"32\"><path d=\"" +
path + "\" stroke=\"" + std::string(theme_ == "midnight" ? "#d2d6dc" : "#474238") + "\" fill=\"none\" stroke-width=\"2.4\"/></svg>";
return "<span class=\"transfer-trait\" title=\"" +
std::string(foot ? fl[size_t(n)] : ty[size_t(n)]) + "\">" +
picture(renderer_.diagram("transfer-trait-" + theme_ + "-" +
std::to_string(int(foot)) + "-" +
std::to_string(n),
svg, 64),
32, 32) +
"</span>";
};
const auto nation = [&](const Json &r) {
const auto code = transfer_ui_text(r.at("nation"), "");
const auto svg = ui_nation_flag_svg(code);
return "<span class=\"transfer-nation\" title=\"" +
esc(transfer_ui_text(transfer_ui_field(r, "nation_name"))) + "\">" +
(svg.empty() ? std::string("—")
: picture(renderer_.diagram(
"transfer-flag-" +
content::sha256(svg).substr(0, 12),
svg, 120),
36, 24)) +
"</span>";
};
// --- the page: the own squad, the offers as cards, what a deal would mean, the squad's strength ---
const auto side_now = transfer_view_.value("side", std::string());
const int64_t cash_now = engine_mode_ ? engine_transfer_value_.at("cash").get<int64_t>() : snapshot.state.at("cash").get<int64_t>();
const auto toggle = [&](const char *action, const char *id, const std::string &first, const std::string &second, bool second_on) {
std::string seg = "<div class=\"pg-seg\">";
for (int i = 0; i < 2; ++i) {
const bool on = (i == 1) == second_on;
seg += btn(action, "<span>" + (i ? second : first) + "</span>", std::string(i ? "" : "first ") + (on ? "on" : ""), on ? std::string("style=\"pointer-events:none;\" aria-pressed=\"true\"") : "id=\"" + std::string(id) + "\" aria-pressed=\"false\"");
}
return seg + "</div>";
};
std::string out = "<section class=\"pg-page tm-overview\"><header class=\"pg-row\"><h2 class=\"pg-h pg-grow\" style=\"font-size:" + pg(22) + ";line-height:" + pg(28) + ";\">Kader und Transfermarkt</h2><span class=\"pg-status\" id=\"transfer-engine-feedback\">" +
esc(engine_mode_ && engine_busy_ ? engine_operation_ : engine_mode_ && !engine_notice_.empty() ? engine_notice_
: chosen.is_object() ? std::string(chosen.at("own") == true ? "Eigener Spieler: " : "Marktspieler: ") + chosen.at("name").get<std::string>() : std::string("Wähle einen angebotenen Spieler.")) +
"</span><div style=\"display:flex;flex:none;min-width:" + pg(210) + ";\">" + pg_stat("Verfügbares Kapital", "<span class=\"" + money_classes(cash_now) + "\">" + esc(transfer_money(cash_now)) + "</span>") + "</div></header><div class=\"pg-body\">";
std::vector<std::string> headers = b ? std::vector<std::string>{"Spieler", "Alter", "Eck.", "Frei.", "Zwei.", "Pass", complete ? "Schuss" : "Sch.", complete ? "Schnell" : "Schn.", "Team"}
: std::vector<std::string>{"Spieler", "Pos.", "Fuß", "Typ", complete ? "Kond." : "Ko", complete ? "Tech." : "Te", complete ? "Form" : "Fo", complete ? "Stärke" : "St."};
if (complete) {
const std::vector<std::string> extras = b ? std::vector<std::string>{"Liga", "Pokal", "Europa", "Tore", "Vorlagen"} : std::vector<std::string>{"Alter", "Land", "Spiele", "Tore", "Vorlagen"};
headers.insert(headers.end(), extras.begin(), extras.end());
}
const double roster_width = complete ? 1244 : 470, cell = (roster_width - 24 - (complete ? 280 : 150)) / double(headers.size() - 1);
out += "<section class=\"pg-panel pg-col" + std::string(complete ? " pg-grow" : "") + "\" style=\"" + pg_css("gap:0px;padding:8px 10px;") + (complete ? std::string() : "width:" + pg(470) + ";") +
"\"><div class=\"pg-row\" style=\"justify-content:space-between;padding:0 " + pg(6) + ";\"><strong class=\"pg-h\">Dein Kader</strong><span class=\"pg-mut\">" + std::to_string(ours.size()) + " Spieler</span></div><div class=\"pg-t\" role=\"table\"><div class=\"pg-thead\">";
for (size_t i = 0; i < headers.size(); ++i) out += pg_th(headers[i], i ? cell : 0, i ? "c" : "");
out += "</div><div id=\"transfer-roster-scroll\" class=\"pg-tbody\">";
for (size_t i = 0; i < ours.size(); ++i) {
const auto &r = ours[i];
const auto id = r.at("id").get<std::string>();
std::vector<std::string> values;
if (b) {
values.push_back(transfer_ui_number(r.at("age")));
for (const auto &v : r.at("skills")) values.push_back(transfer_ui_number(v));
} else
values = {pg_pos(transfer_ui_role(r.at("position"))), trait(r.at("foot"), true), trait(r.at("type"), false), transfer_ui_number(r.at("condition")), transfer_ui_number(r.at("technique")), transfer_ui_number(r.at("form")),
"<strong>" + transfer_ui_number(r.at("strength")) + "</strong>"};
if (complete) {
if (b) { for (auto *key : {"league_games", "cup_games", "europe_games", "goals", "assists"}) values.push_back(transfer_ui_number(r.at(key))); }
else {
values.push_back(transfer_ui_number(r.at("age")));
values.push_back(nation(r));
for (auto *key : {"games", "goals", "assists"}) values.push_back(transfer_ui_number(r.at(key)));
}
}
const bool selected = side_now == "own" && transfer_view_.at("own") == id;
out += "<div class=\"pg-tr " + std::string(selected ? "sel" : "") + "\">" +
pg_td(btn("transfer-own", std::string(listed(id) ? "<span class=\"tm-listed\" title=\"Auf dem Markt\"></span>" : "") + "<span>" + esc(r.at("name").get<std::string>()) + "</span>", std::string("pg-link") + (listed(id) ? " transfer-listed" : ""),
"id=\"transfer-own-" + esc(id) + "\" data-player=\"" + esc(id) + "\" aria-pressed=\"" + (selected ? "true" : "false") + "\""), 0, "", true);
for (const auto &v : values) out += pg_td(v.find('<') == std::string::npos ? "<span>" + v + "</span>" : v, cell, "c", true);
out += "</div>";
}
if (ours.empty()) out += "<div class=\"pg-empty\">Keine Kaderspieler vorhanden.</div>";
out += "</div></div></section>";
if (!complete) {
// the offers
out += "<section id=\"transfer-market-scroll\" class=\"pg-col pg-grow\"><div class=\"pg-row\"><strong class=\"pg-h\" style=\"flex:none;\">Angebote</strong><input id=\"transfer-search\" class=\"tm-search\" maxlength=\"40\" value=\"" +
esc(transfer_view_.value("query", data.at("query").get<std::string>())) + "\" aria-label=\"Spielername suchen\" placeholder=\"Spielername\"/>" + pg_button("transfer-search", "Finden", "", "id=\"transfer-find\"") +
"</div><div id=\"transfer-offers\" class=\"tm-offers\">";
for (size_t i = size_t(page) * 6; i < std::min(pool.size(), size_t(page + 1) * 6); ++i) {
const auto &r = pool[i];
const auto id = r.at("id").get<std::string>();
const bool mine = r.at("own");
const bool selected = (mine ? transfer_view_.at("own") : transfer_view_.at("market")) == id && side_now == (mine ? "own" : "market");
// a card: who he is, his four values, what he costs and who sells
const auto name = r.at("name").get<std::string>();
std::string initials;
for (size_t at = 0; at < name.size() && initials.size() < 4; at = name.find(' ', at) == std::string::npos ? name.size() : name.find(' ', at) + 1) {
const unsigned char lead = static_cast<unsigned char>(name[at]);
initials += name.substr(at, lead >= 0xC0 ? (lead >= 0xE0 ? 3 : 2) : 1);
if (name.find(' ', at) == std::string::npos) break;
}
const auto photo = r.contains("photo") && r.at("photo").is_string() && !r.at("photo").get<std::string>().empty()
? "<span class=\"pg-photo\" style=\"width:132dp;height:132dp;border-radius:66dp;\">" + img(r.at("photo").get<std::string>(), 132, 132, true, true, 256) + "</span>"
: "<span class=\"tm-initials\">" + esc(initials) + "</span>";
const auto *seller = world_->find("clubs", r.value("club", std::string()));
const auto seller_name = seller ? world_->name(*seller) : r.value("seller_name", std::string("—"));
std::string chips;
for (const auto &[label, key] : std::array<std::pair<const char *, const char *>, 4>{{{"Ko", "condition"}, {"Te", "technique"}, {"Fo", "form"}, {"Stärke", "strength"}}})
chips += "<div class=\"tm-chip" + std::string(std::string(key) == "strength" ? " strong" : "") + "\"><small>" + label + "</small><strong>" + transfer_ui_number(r.at(key)) + "</strong></div>";
out += btn(mine ? "transfer-own" : "transfer-market",
"<div class=\"pg-row\" style=\"" + pg_css("gap:10px;") + "\">" + photo + "<div class=\"tm-card-text\"><strong class=\"pg-nowrap\">" + esc(name) + "</strong><div class=\"pg-row pg-mut\" style=\"" + pg_css("gap:6px;font-size:12.5px;") + "\">" +
pg_pos(transfer_ui_role(r.at("position"))) + nation(r) + "<span>" + transfer_ui_number(r.at("age")) + " Jahre</span>" + (r.at("foot").is_number_integer() ? trait(r.at("foot"), true) : std::string()) + (r.at("type").is_number_integer() ? trait(r.at("type"), false) : std::string()) + "</div><div class=\"tm-seller pg-nowrap\">" + esc(mine ? std::string("Dein Spieler · auf dem Markt") : seller_name) +
"</div></div></div><div class=\"pg-row tm-chips\">" + chips + "</div><div class=\"pg-row\" style=\"justify-content:space-between;\"><span class=\"pg-k\">" +
esc(pg_upper(mine ? "Marktwert" : "Ablöse")) + "</span><strong class=\"tm-fee\">" + esc(r.at("fee").is_number_integer() ? transfer_money(r.at("fee").get<int64_t>()) : std::string("—")) + "</strong></div>",
"pg-card tm-card " + std::string(mine ? "transfer-own-listing " : "") + (selected ? "sel" : ""),
"id=\"transfer-market-" + esc(id) + "\" data-player=\"" + esc(id) + "\" data-preview=\"" + esc(id) + "\" aria-pressed=\"" + (((mine ? transfer_view_.at("own") : transfer_view_.at("market")) == id) ? "true" : "false") + "\"");
}
if (pool.empty()) out += "<div class=\"pg-panel pg-empty\" style=\"width:100%;height:" + pg(200) + ";\">Keine Spieler für diese Auswahl. Name, Positionen oder Suchprofil ändern.</div>";
out += "</div><div class=\"pg-row\" style=\"justify-content:space-between;\"><span class=\"pg-mut\">" +
(pool.empty() ? std::string("Keine Angebote") : std::to_string(page * 6 + 1) + "–" + std::to_string(std::min(pool.size(), size_t(page + 1) * 6)) + " von " + std::to_string(pool.size())) + "</span><span class=\"pg-row\" style=\"" + pg_css("gap:6px;") + "\">" +
pg_button("transfer-page", "‹", "round", "id=\"transfer-page-previous\" data-step=\"-1\" aria-label=\"Vorige Angebote\" " + std::string(page == 0 ? "disabled" : "")) +
pg_button("transfer-page", "›", "round", "id=\"transfer-page-next\" data-step=\"1\" aria-label=\"Weitere Angebote\" " + std::string(page + 1 >= pages ? "disabled" : "")) + "</span></div><span class=\"pg-sp\"></span><div class=\"pg-row\"><nav class=\"pg-seg\">";
const std::array<const char *, 5> filters{"Alle", "Tor", "ABW", "MIT", "STU"};
for (int i = 0; i < 5; ++i) {
const bool on = i == 0 ? data.at("positions") == 15 : data.at("positions") != 15 && bool(data.at("positions").get<int>() & (1 << (i - 1)));
out += btn("transfer-filter", "<span>" + std::string(filters[size_t(i)]) + "</span>", std::string(i ? "" : "first ") + (on ? "on" : ""),
"id=\"transfer-filter-" + std::to_string(i) + "\" data-index=\"" + std::to_string(i) + "\" aria-pressed=\"" + (on ? "true" : "false") + "\"");
}
out += "</nav><span class=\"pg-mut\" style=\"font-size:" + pg(12) + ";\">Filter sind kombinierbar</span></div></section>";
// what the deal would mean, the squad's strength, the deal itself
out += "<div class=\"pg-col\" style=\"width:" + pg(270) + ";\"><section id=\"transfer-preview\" class=\"pg-panel tm-preview\">";
if (preview.is_object()) {
const auto *source = world_->find("clubs", preview.at("club"));
const auto fee = preview.at("fee").is_number_integer() ? preview.at("fee").get<int64_t>() : 0;
const auto remaining = cash_now + (preview.at("own") == true ? fee : -fee);
out += "<p>" + (source ? label(source, 32) : esc(preview.value("seller_name", std::string("—")))) + "</p><div><section><span>" + std::string(preview.at("own") == true ? "Marktwert" : "Geforderte Ablöse") + "</span><strong>" +
esc(preview.at("fee").is_null() ? std::string("—") : transfer_money(fee)) + "</strong></section><section><span>Restkapital nach " + std::string(preview.at("own") == true ? "Verkauf" : "Kauf") + "</span><strong class=\"" + money_classes(remaining) + "\">" +
esc(preview.at("fee").is_null() ? std::string("—") : transfer_money(remaining)) + "</strong></section></div>";
} else out += "<p>Wähle einen angebotenen Spieler.</p>";
const auto strengths = engine_mode_ ? engine_transfer_value_.at("strengths") : demo_transfer_strengths(snapshot.state, *world_, own, demo_lineup_active(snapshot.state));
const auto scope = transfer_view_.value("scope", std::string("active"));
out += "</section><section class=\"pg-panel pg-col\" style=\"" + pg_css("gap:6px;") + "\"><div class=\"pg-row\" style=\"justify-content:space-between;\">" + pg_kicker("Stärke") + "<nav class=\"pg-seg\">" +
btn("transfer-scope", "<span>Aktive</span>", std::string("first ") + (scope == "active" ? "on" : ""), "id=\"transfer-scope-active\" data-scope=\"active\" aria-pressed=\"" + std::string(scope == "active" ? "true" : "false") + "\"") +
btn("transfer-scope", "<span>Team</span>", scope == "team" ? "on" : "", "id=\"transfer-scope-team\" data-scope=\"team\" aria-pressed=\"" + std::string(scope == "team" ? "true" : "false") + "\"") +
"</nav></div><div class=\"pg-row\" style=\"justify-content:space-between;\"><span>Durchschnitt</span><strong class=\"pg-big\">" + transfer_ui_number(strengths.at(scope == "team" ? "team_average" : "active_average")) + "</strong></div>";
for (int i = 0; i < 4; ++i) {
const auto &value = strengths.at(scope)[size_t(i)];
out += "<div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "\"><span style=\"display:block;flex:none;width:" + pg(80) + ";\">" + std::string(std::array<const char *, 4>{"Tor", "Abwehr", "Mittelfeld", "Sturm"}[size_t(i)]) + "</span>" +
pg_bar(value.is_number() ? (value.get<double>() - 50) / 40 * 100 : 0) + "<strong style=\"display:block;flex:none;width:" + pg(26) + ";text-align:right;\">" + transfer_ui_number(value) + "</strong></div>";
}
const bool mine = chosen.is_object() && chosen.at("own") == true;
const bool pending = engine_mode_ && !mine && chosen.is_object() && chosen.value("bid", Json()).is_object();
const bool pending_loan = pending && chosen.at("bid").value("loan", false);
const bool on_list = mine && listed(chosen.at("id"));
out += "</section><div class=\"pg-col\" style=\"" + pg_css("gap:6px;") + "\">" +
pg_button("transfer-offer", on_list ? "Vom Markt nehmen" : mine ? "Verkaufen" : "Kaufen", "primary tm-deal",
"id=\"transfer-offer-buy-sell\" data-kind=\"" + std::string(mine ? "sell" : "buy") + "\" " + std::string(chosen.is_object() && (!engine_mode_ || !mine || !on_list) && (!pending || !pending_loan) ? "" : "disabled")) +
pg_button("transfer-offer", mine ? "Verleihen" : "Ausleihen", "tm-deal",
"id=\"transfer-offer-loan-lend\" data-kind=\"" + std::string(mine ? "lend" : "loan") + "\" " +
std::string(chosen.is_object() && (!engine_mode_ || !mine || !on_list) && (!pending || pending_loan) && (!engine_mode_ || mine || chosen.value("loan_allowed", false)) ? "" : "disabled")) +
pg_button("transfer-poach", "Abwerben", "tm-deal", "id=\"transfer-poach\"") + "</div></div>";
}
out += "</div><nav class=\"pg-foot\">" + (complete ? std::string() : toggle("transfer-data", "transfer-data", "Daten A", "Daten B", b)) + toggle("transfer-all", "transfer-all", "Komplett", "Angebote", !complete);
if (complete) out += toggle("transfer-data", "transfer-data", "Daten A", "Daten B", b);
else
out += pg_button("transfer-criteria", "Spieler suchen", "", "id=\"transfer-criteria\"") + pg_button("transfer-suggest", "Vorschlag", "", "id=\"transfer-suggest\"") +
pg_button("transfer-orders", "Aufträge (" + std::to_string(data.at("orders").size()) + ")", "", "id=\"transfer-orders\"");
transfer_view_["restore_scroll"] = true;
return out + "</nav></section>" + render_transfer_dialog();
}
// The dialogs of the transfer market: notes on the dimmed book. The ids of the fields and
// buttons are what the controls look up.
std::string App::render_transfer_dialog() {
if (transfer_dialog_.empty())
return {};
const auto snapshot = engine_mode_ ? Snapshot{} : snap();
const auto actor = engine_mode_ ? engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>() : transfer_ui_club(snapshot);
std::string title, sub, body, actions;
double width = 460;
const auto button = [&](const char *action, const std::string &caption, const std::string &attrs = "", bool primary = false) {
return pg_button(action, esc(caption), primary ? "primary" : "", attrs);
};
const auto close = [&](const std::string &caption = "Abbruch", bool primary = false) { return button("transfer-close", caption, "id=\"transfer-close\"", primary); };
const auto portrait = [&](const Json &r, double size) {
return r.contains("photo") && r.at("photo").is_string() && !r.at("photo").get<std::string>().empty()
? "<span class=\"pg-photo\" style=\"width:" + scalar(size) + "dp;height:" + scalar(size) + "dp;border-radius:" + scalar(size * .18) + "dp;\">" + img(r.at("photo").get<std::string>(), size, size, true, true, 400) + "</span>"
: engine_mode_ ? "<span class=\"pg-photo\" style=\"width:" + scalar(size) + "dp;height:" + scalar(size) + "dp;border-radius:" + scalar(size * .18) + "dp;\">" + img("asset:player/generic/photo", size, size, true, true, 400) + "</span>" : std::string();
};
const auto fact = [](const std::string &label, const std::string &value) { return "<div class=\"pg-kv\"><span>" + esc(label) + "</span><strong>" + value + "</strong></div>"; };
if (transfer_dialog_ == "offer") {
width = 600;
const auto &d = transfer_draft_;
const auto &r = d.at("row");
const auto kind = d.at("kind").get<std::string>();
const bool loan = kind == "loan" || kind == "lend", mine = r.at("own");
const std::map<std::string, std::string> kinds{{"buy", "Kaufen"}, {"loan", "Ausleihen"}, {"sell", "Verkaufen"}, {"lend", "Verleihen"}};
title = (d.at("poached") == true ? std::string("Abwerben") : kinds.at(kind)) + " · " + r.at("name").get<std::string>();
const auto *club = world_->find("clubs", r.at("club"));
const auto flag = ui_nation_flag_svg(transfer_ui_text(r.at("nation"), ""));
body = "<div class=\"pg-row\" style=\"" + pg_css("gap:14px;") + "align-items:flex-start;\">" + portrait(r, 162) + "<div class=\"pg-col pg-grow\" style=\"gap:0dp;\">" +
fact("Verein", club ? esc(world_->name(*club)) : esc(r.value("club_name", std::string("—")))) +
fact("Position · Alter · Stärke", "<span class=\"tm-inline\">" + pg_pos(transfer_ui_role(r.at("position"))) + (flag.empty() ? std::string() : picture(renderer_.diagram("transfer-offer-flag", flag, 180), 45, 30)) + "<span>" + transfer_ui_number(r.at("age")) + " Jahre · " + transfer_ui_number(r.at("strength")) + "</span></span>") +
fact(engine_mode_ ? "Ablöseforderung" : loan ? "Fiktive Leihgebühr" : "Ungefährer Marktwert", esc(transfer_money(d.at("demand_fee").get<int64_t>()))) +
fact(engine_mode_ ? "Gehaltsreferenz / Monat" : mine ? "Aktuelles Monatsgehalt" : "Gehaltswunsch", d.at("demand_salary").is_number_integer() ? esc(transfer_money(d.at("demand_salary").get<int64_t>())) : std::string("—")) +
"</div></div><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:9px;") + "\">" + pg_kicker("Dein Angebot");
for (int i = 0; i < 3; ++i) {
const auto field = i == 0 ? "fee" : i == 1 ? "salary" : "months";
const std::string caption = i == 0 ? (loan ? "Leihgebühr" : "Ablöse") : i == 1 ? "Monatsgehalt" : "Vertragsdauer";
body += "<div class=\"pg-row\" style=\"justify-content:space-between;\"><span>" + caption + "</span>";
if (i < 2)
body += pg_button("transfer-amount", "<span>" + esc(number(d.at(field).get<int64_t>())) + " €</span>", "amount-trigger", "id=\"transfer-" + std::string(field) + "\" data-field=\"" + field + "\" aria-label=\"" + caption + "\"");
else {
body += "<select id=\"transfer-months\" class=\"tm-select\" aria-label=\"Vertragsdauer in Monaten\">";
for (int months : {12, 24, 36, 48})
if (!loan || months <= 24) body += "<option value=\"" + std::to_string(months) + "\" " + std::string(d.at("months") == months ? "selected" : "") + ">" + std::to_string(months) + " Monate</option>";
body += "</select>";
}
body += "</div>";
}
body += "</div><div class=\"pg-panel\">" + pg_kicker("Mannschaftsprämien für diesen Vertrag") + "<div class=\"tm-premiums\">";
for (int i = 0; i < 7; ++i)
body += "<div class=\"pg-row tm-premium\"><span class=\"pg-grow\">" + std::string(transfer_ui_bonuses[size_t(i)]) + "</span>" +
btn("transfer-bonus", "<span>" + transfer_ui_number(engine_mode_ && i >= 3 ? Json(d.at("bonuses")[size_t(i)].get<int>() * 5) : d.at("bonuses")[size_t(i)]) + "</span>", "pg-btn tm-small amount-trigger",
"id=\"transfer-bonus-" + std::to_string(i) + "\" data-index=\"" + std::to_string(i) + "\"") + "</div>";
body += "</div></div><span class=\"pg-mut\" style=\"display:block;font-size:" + pg(12.5) + ";\">" +
std::string(engine_mode_ ? "Über das Angebot wird nach deiner Bestätigung entschieden. Die Konditionen werden erst beim Absenden verbindlich."
: mine ? "Der Spieler wird zum " + std::string(loan ? "Verleihen" : "Verkauf") + " auf dem Markt vorgemerkt." : "Das Angebot wird vorgemerkt; die Entscheidung des Spielers folgt später.") + "</span>";
actions = button("transfer-team-info", "Team-Info", "id=\"transfer-team-info\"") + button("transfer-player-info", "Spieler-Info", "id=\"transfer-player-info\"") + "<span class=\"pg-sp\"></span>" + close() +
button("transfer-submit", "Angebot", "id=\"transfer-submit\" " + std::string(d.value("can_submit", true) ? "" : "disabled"), true);
} else if (transfer_dialog_ == "search") {
width = 520;
title = "Spieler suchen";
const auto &d = transfer_search_draft_;
body = "<div class=\"pg-row\" style=\"justify-content:space-between;\">" + pg_kicker("Art") + "<nav class=\"pg-seg\">";
for (int i = 0; i < 4; ++i) {
const bool on = d.at("positions").get<int>() & (1 << i);
body += btn("transfer-search-position", "<span>" + std::string(std::array<const char *, 4>{"Tor", "ABW", "MIT", "STU"}[size_t(i)]) + "</span>", std::string(i ? "" : "first ") + (on ? "on" : ""),
"id=\"transfer-search-position-" + std::to_string(i) + "\" data-index=\"" + std::to_string(i) + "\" aria-pressed=\"" + (on ? "true" : "false") + "\"");
}
body += "</nav></div><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:9px;") + "\">";
const std::array<std::pair<const char *, const char *>, 4> ranges{{{"age_min", "Alter von"}, {"age_max", "Alter bis"}, {"strength_min", "Stärke von"}, {"strength_max", "Stärke bis"}}};
for (int i = 0; i < 4; ++i) {
const auto [key, caption] = ranges[size_t(i)];
body += "<div class=\"pg-row\" style=\"" + pg_css("gap:10px;") + "\"><span style=\"display:block;flex:none;width:" + pg(110) + ";\">" + caption + "</span><input class=\"tm-range\" type=\"range\" id=\"transfer-range-" + key + "\" data-criterion=\"" + key + "\" min=\"" +
std::to_string(i < 2 ? 16 : 0) + "\" max=\"" + std::to_string(i < 2 ? (engine_mode_ ? 47 : 40) : 100) + "\" step=\"1\" value=\"" + transfer_ui_number(d.at(key)) + "\"/><strong class=\"pg-r\" style=\"display:block;flex:none;width:" + pg(40) +
";\" id=\"transfer-range-value-" + key + "\">" + transfer_ui_number(d.at(key)) + "</strong></div>";
}
body += "<div class=\"pg-row\" style=\"justify-content:space-between;\"><span>Preisvorstellung bis</span>" +
pg_button("transfer-search-budget", "<span>" + esc(number(d.at("price_max").get<int64_t>())) + " €</span>", "amount-trigger", "id=\"transfer-search-budget\" aria-label=\"Maximale Ablösesumme\"") +
"</div></div><div class=\"pg-row\" style=\"justify-content:space-between;\">" + pg_kicker("Typ · darauf achten") + "<nav class=\"pg-seg\">";
for (int i = 0; i < 3; ++i) {
const bool on = d.at("traits").get<int>() & (1 << i);
body += btn("transfer-search-trait", "<span>" + std::string(std::array<const char *, 3>{"Kondition", "Technik", "Form"}[size_t(i)]) + "</span>", std::string(i ? "" : "first ") + (on ? "on" : ""),
"id=\"transfer-search-trait-" + std::to_string(i) + "\" data-index=\"" + std::to_string(i) + "\" aria-pressed=\"" + (on ? "true" : "false") + "\"");
}
body += "</nav></div><div class=\"pg-row\" style=\"" + pg_css("gap:12px;") + "\">";
for (int i = 0; i < 2; ++i) {
const auto field = i ? "foot" : "type";
const std::array<const char *, 4> names = i ? std::array<const char *, 4>{"Beliebig", "Links", "Beidfüßig", "Rechts"} : std::array<const char *, 4>{"Beliebig", "Defensiv", "Ausgeglichen", "Offensiv"};
body += "<div class=\"pg-col pg-grow\" style=\"" + pg_css("gap:3px;") + "\">" + pg_kicker(i ? "Spielseite" : "Spielweise") + "<select id=\"transfer-criterion-" + field + "\" class=\"tm-select wide\" data-criterion=\"" + field + "\" aria-label=\"" +
std::string(i ? "Spielseite" : "Spielweise") + "\">";
for (int n = 0; n < 4; ++n) body += "<option value=\"" + std::to_string(n) + "\" " + std::string(d.at(field) == n ? "selected" : "") + ">" + names[size_t(n)] + "</option>";
body += "</select></div>";
}
body += "</div>";
actions = close() + button("transfer-search-reset", "Zurücksetzen", "id=\"transfer-search-reset\"") + button("transfer-search-apply", "Suchen", "id=\"transfer-search-apply\"", true);
} else if (transfer_dialog_ == "player-info") {
width = 620;
const auto &r = transfer_draft_.at("row");
title = r.at("name").get<std::string>();
sub = esc(r.at("club_name").get<std::string>());
const auto foot = r.at("foot").is_number_integer() ? std::array<const char *, 4>{"—", "Links", "Beidfüßig", "Rechts"}[size_t(r.at("foot").get<int>())] : "—";
const auto type = r.at("type").is_number_integer() ? std::array<const char *, 4>{"—", "Defensiv", "Ausgeglichen", "Offensiv"}[size_t(r.at("type").get<int>())] : "—";
body = "<div class=\"pg-row\" style=\"" + pg_css("gap:18px;") + "align-items:flex-start;\">" + portrait(r, 300) + "<div class=\"pg-col pg-grow\" style=\"" + pg_css("gap:8px;") + "\"><div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "align-items:stretch;\">" +
pg_stat("Alter", transfer_ui_number(r.at("age"))) + pg_stat("Stärke", transfer_ui_number(r.at("strength"))) + "</div><div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "align-items:stretch;\">" + pg_stat("Kondition", transfer_ui_number(r.at("condition"))) +
pg_stat("Technik", transfer_ui_number(r.at("technique"))) + pg_stat("Form", transfer_ui_number(r.at("form"))) + "</div><div class=\"pg-panel\">" + fact("Position", "<span class=\"tm-inline\">" + pg_pos(transfer_ui_role(r.at("position"))) + "</span>") + fact("Fuß", foot) + fact("Typ", type) +
"</div></div></div>";
actions = button("transfer-offer-back", "Zurück zum Angebot", "id=\"transfer-offer-back\"", true);
} else if (transfer_dialog_ == "team-info") {
width = 420;
title = "Team-Info";
const auto values = engine_mode_ ? engine_transfer_value_.at("strengths") : demo_transfer_strengths(snapshot.state, *world_, actor, demo_lineup_active(snapshot.state));
body = "<div class=\"pg-row\">" + label(world_->find("clubs", actor), 58) + "</div><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:0px;padding:6px 12px;") + "\"><div class=\"pg-t\"><div class=\"pg-thead\">" + pg_th("Mannschaftsteil", 0) + pg_th("Aktive", 90, "r") +
pg_th("Team", 90, "r") + "</div><div class=\"pg-tbody\">";
for (int i = 0; i < 4; ++i)
body += "<div class=\"pg-tr\">" + pg_td(std::array<const char *, 4>{"Tor", "Abwehr", "Mittelfeld", "Sturm"}[size_t(i)], 0) + pg_td("<strong>" + transfer_ui_number(values.at("active")[size_t(i)]) + "</strong>", 90, "r") +
pg_td(transfer_ui_number(values.at("team")[size_t(i)]), 90, "r") + "</div>";
body += "</div></div></div>";
actions = button("transfer-offer-back", "Zurück zum Angebot", "id=\"transfer-offer-back\"", true);
} else if (transfer_dialog_ == "poach-clubs") {
width = 900;
title = "Spieler abwerben";
sub = engine_mode_ ? "Verein wählen, danach einen Spieler aus dessen Kader. Fünf Versuche je Saison." : "Verein wählen, danach einen Spieler aus dessen Beispielkader.";
const auto leagues = world_->leagues();
if (transfer_poach_league_.empty() && !leagues.empty()) transfer_poach_league_ = leagues[0]->at("id").get<std::string>();
const auto *league = world_->find("competitions", transfer_poach_league_);
const auto country = league ? league->value("nation", "") : "";
body = "<nav class=\"pg-row\" style=\"" + pg_css("gap:12px;") + "\"><select id=\"transfer-poach-country\" class=\"tm-select wide\" aria-label=\"Land\">";
for (const auto &nation : world_->rows("nations")) {
const auto id = nation.at("id").get<std::string>();
if (world_->leagues(id).empty()) continue;
body += "<option value=\"" + esc(id) + "\" " + std::string(country == id ? "selected" : "") + ">" + esc(world_->name(nation)) + "</option>";
}
body += "</select><select id=\"transfer-poach-league\" class=\"tm-select wide\" aria-label=\"Liga\">";
for (const auto *l : world_->leagues(country))
body += "<option value=\"" + esc(l->at("id").get<std::string>()) + "\" " + std::string(l->at("id") == transfer_poach_league_ ? "selected" : "") + ">" + esc(world_->name(*l)) + "</option>";
body += "</select></nav><div id=\"transfer-poach-scroll\" data-scope=\"clubs-" + esc(transfer_poach_league_) + "\" class=\"tm-poach-clubs\">";
for (const auto *club : world_->clubs(transfer_poach_league_))
body += btn("transfer-poach-club", crest(club, 64) + "<span>" + esc(world_->name(*club)) + "</span>", "pg-card tm-poach-club",
"id=\"transfer-poach-club-" + esc(club->at("id").get<std::string>()) + "\" data-club=\"" + esc(club->at("id").get<std::string>()) + "\" " + std::string(club->at("id") == actor ? "disabled" : ""));
body += "</div>";
actions = close();
} else if (transfer_dialog_ == "poach-roster" && engine_mode_) {
const auto engine_text = [](const Json &v) { return v.is_string() ? v.get<std::string>() : v.is_object() ? v.value("text", std::string()) : std::string("—"); };
// the squad of the chosen club as the game states it
width = 720;
const auto *club = world_->find("clubs", transfer_poach_club_);
title = "Abwerben · " + std::string(club ? world_->name(*club) : "—");
sub = "Ein Klick auf den Namen fragt beim Verein an.";
body = "<div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:0px;padding:6px 12px;") + "\"><div class=\"pg-t\"><div class=\"pg-thead\">" + pg_th("Spieler", 0) + pg_th("Pos.", 70) + pg_th("Alter", 70, "r") + pg_th("Stärke", 80, "r") +
"</div><div id=\"transfer-poach-scroll\" data-scope=\"roster-" + esc(transfer_poach_club_) + "\" class=\"pg-tbody\">";
if (engine_poach_squad_.is_object() && engine_poach_squad_.contains("players"))
for (const auto &r : engine_poach_squad_.at("players")) {
const auto &person = r.at("player");
const auto id = person.at("id").get<std::string>();
Json strength;
try { const auto &m = r.at("metrics").at("strength"); if (m.is_object() && m.value("value", Json()).is_number_integer()) strength = m.at("value"); } catch (const std::exception &) {}
const auto position = person.contains("positions") && person.at("positions").is_array() && !person.at("positions").empty() ? person.at("positions")[0] : Json();
body += "<div class=\"pg-tr\">" + pg_td(btn("transfer-poach-player", "<span>" + esc(engine_text(person.at("name"))) + "</span>", "pg-link", "id=\"transfer-poach-player-" + esc(id) + "\" data-player=\"" + esc(id) + "\""), 0, "", true) +
pg_td(pg_pos(transfer_ui_role(position)), 70, "", true) + pg_td(transfer_ui_number(r.value("age", Json())), 70, "r") + pg_td("<strong>" + transfer_ui_number(strength) + "</strong>", 80, "r") + "</div>";
}
body += "</div></div></div>";
actions = button("transfer-poach-back", "Zurück zu Vereinen", "id=\"transfer-poach-back\"") + close();
} else if (transfer_dialog_ == "poach-offer" && engine_poach_quote_.is_object()) {
// the club has named its price: the offer is written, sent, or the attempt given up
width = 600;
const auto &q = engine_poach_quote_;
const auto *club = q.at("sellerId").is_string() ? world_->find("clubs", q.at("sellerId").get<std::string>()) : nullptr;
title = "Abwerben · " + q.value("name", std::string());
sub = (club ? world_->name(*club) + " · " : std::string()) + "noch " + std::to_string(q.value("attemptsLeft", 0)) + (q.value("attemptsLeft", 0) == 1 ? " Versuch" : " Versuche") + " in dieser Saison";
const auto euros = [](int64_t value) { return money(value * 100, {{"code", "EUR"}, {"minor_units", 2}}); };
const auto engine_price = [](const Json &v) { return money(engine_money_minor(v), {{"code", "EUR"}, {"minor_units", 2}}); };
body = "<div class=\"pg-panel pg-row\" style=\"" + pg_css("gap:14px;padding:10px 16px;") + "\">" + (club ? "<span style=\"display:block;flex:none;\">" + crest(club, 120) + "</span>" : std::string()) + "<div class=\"pg-grow\">" +
pg_kicker("Der Verein verlangt") + fact("Ablöse", esc(engine_price(q.at("askingFee")))) + fact("Gehalt des Spielers", esc(engine_price(q.at("askingMonthlySalary"))) + " monatlich") + "</div></div><div class=\"pg-panel pg-col\" style=\"" +
pg_css("gap:6px;padding:10px 16px;") + "\">" + pg_kicker("Dein Angebot") + "<div class=\"pg-kv\"><span>Ablöse</span>" +
pg_button("transfer-poach-amount", esc(euros(q.at("offer_fee").get<int64_t>())), "amount-trigger", "id=\"transfer-poach-fee\" data-id=\"offer_fee\"") + "</div><div class=\"pg-kv\"><span>Monatsgehalt</span>" +
pg_button("transfer-poach-amount", esc(euros(q.at("offer_salary").get<int64_t>())), "amount-trigger", "id=\"transfer-poach-salary\" data-id=\"offer_salary\"") + "</div><div class=\"pg-kv\"><span>Vertragsdauer</span><div class=\"pg-seg\">";
for (int years = 1; years <= 4; ++years)
body += btn("transfer-poach-years", "<span>" + std::to_string(years) + (years == 1 ? " Jahr" : " Jahre") + "</span>", std::string(years == 1 ? "first " : "") + (q.at("offer_years") == years ? "on" : ""),
"id=\"transfer-poach-years-" + std::to_string(years) + "\" data-id=\"" + std::to_string(years) + "\" aria-pressed=\"" + (q.at("offer_years") == years ? "true" : "false") + "\"");
body += "</div></div></div>";
if (!q.value("note", std::string()).empty()) body += "<span class=\"pg-status\" style=\"display:block;max-width:100%;\">" + esc(q.at("note").get<std::string>()) + "</span>";
body += "<span class=\"pg-mut\" style=\"display:block;\">Der Verein entscheidet sofort. Der Versuch ist gezählt, auch wenn du abbrichst.</span>";
actions = close("Versuch abbrechen") + button("transfer-poach-submit", "Bieten", "id=\"transfer-poach-submit\"", true);
} else if (transfer_dialog_ == "poach-roster") {
width = 720;
const auto *club = world_->find("clubs", transfer_poach_club_);
title = "Abwerben · " + std::string(club ? world_->name(*club) : "—");
const auto rows = demo_transfer_roster(snapshot.state, *world_, actor, transfer_poach_club_);
body = "<div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:0px;padding:6px 12px;") + "\"><div class=\"pg-t\"><div class=\"pg-thead\">" + pg_th("Spieler", 0) + pg_th("Pos.", 70) + pg_th("Alter", 70, "r") + pg_th("Stärke", 80, "r") + pg_th("Marktwert", 170, "r") +
"</div><div id=\"transfer-poach-scroll\" data-scope=\"roster-" + esc(transfer_poach_club_) + "\" class=\"pg-tbody\">";
if (rows.value("ok", false))
for (const auto &r : rows.at("rows"))
body += "<div class=\"pg-tr\">" + pg_td(btn("transfer-poach-player", "<span>" + esc(r.at("name").get<std::string>()) + "</span>", "pg-link", "id=\"transfer-poach-player-" + esc(r.at("id").get<std::string>()) + "\" data-player=\"" +
esc(r.at("id").get<std::string>()) + "\""), 0, "", true) + pg_td(pg_pos(transfer_ui_role(r.at("position"))), 70, "", true) + pg_td(transfer_ui_number(r.at("age")), 70, "r") + pg_td("<strong>" + transfer_ui_number(r.at("strength")) + "</strong>", 80, "r") +
pg_td(esc(transfer_money((r.at("fee").get<int64_t>() * 3 + 1) / 2)), 170, "r") + "</div>";
body += "</div></div></div>";
actions = button("transfer-poach-back", "Zurück zu Vereinen", "id=\"transfer-poach-back\"") + close();
} else if (transfer_dialog_ == "orders") {
width = 680;
title = "Vorgemerkte Transferaufträge";
const auto rows = transfer_data().at("orders");
if (rows.empty()) body = "<div class=\"pg-panel pg-empty\" id=\"transfer-orders-scroll\">Noch keine Transferaufträge vorgemerkt.</div>";
else {
body = "<div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:0px;padding:6px 12px;") + "\"><div class=\"pg-t\"><div class=\"pg-thead\">" + pg_th("Spieler", 0) + pg_th("Art", 110) + pg_th("Betrag", 170, "r") + pg_th("Laufzeit", 120, "r") + pg_th("", 60) +
"</div><div id=\"transfer-orders-scroll\" class=\"pg-tbody\">";
const std::map<std::string, std::string> kinds{{"buy", "Kaufen"}, {"loan", "Ausleihen"}, {"sell", "Verkaufen"}, {"lend", "Verleihen"}};
for (size_t i = 0; i < rows.size(); ++i) {
const auto &o = rows[i];
body += "<div class=\"pg-tr\">" + pg_td("<strong>" + esc(o.at("name").get<std::string>()) + "</strong>", 0) + pg_td(esc(engine_mode_ ? "Gebot" : o.at("poached") == true ? "Abwerben" : kinds.at(o.at("kind"))), 110) +
pg_td(esc(transfer_money(o.at("fee").get<int64_t>())), 170, "r") + pg_td(std::to_string(o.at("months").get<int>()) + " Monate", 120, "r") +
pg_td(btn("transfer-order-delete", "×", "pg-btn round tm-small", "id=\"transfer-order-delete-" + std::to_string(i) + "\" data-index=\"" + std::to_string(i) + "\" aria-label=\"Auftrag zurücknehmen\" " +
std::string(engine_mode_ ? "disabled title=\"Noch nicht angebunden\"" : "")), 60, "r", true) + "</div>";
}
body += "</div></div></div>";
}
actions = close("Schließen", true);
} else {
title = transfer_dialog_ == "booked" ? (engine_mode_ ? "Transferauftrag" : "Auftrag vorgemerkt") : "Transferliste voll";
body = "<p>" + esc(transfer_notice_) + "</p>";
actions = close("Verstanden", true);
}
return "<div id=\"transfer-layer\" class=\"pg-ov\"><section id=\"transfer-dialog\" class=\"pg-dlg " + esc(transfer_dialog_) + "\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"transfer-dialog-title\" style=\"width:" + pg(width) +
";\"><div><h2 id=\"transfer-dialog-title\">" + esc(title) + "</h2>" + (sub.empty() ? std::string() : "<span class=\"pg-dlg-sub\">" + sub + "</span>") + "</div><div id=\"transfer-dialog-scroll\" class=\"tm-dialog-body\" data-dialog=\"" +
esc(transfer_dialog_) + "\">" + body + "</div><nav class=\"pg-dlg-act\">" + actions + "</nav></section></div>";
}