Bind the transfer market to world-relative Modern data (by Codex)
This commit is contained in:
1 parent
e559e84a69
commit
1e88304019
23 files changed
+1230
-76
No files matched your search
@@ -110,9 +110,9 @@ void App::transfer_restore_scroll() {
|
||||
}
|
||||
std::string App::render_transfer() {
|
||||
transfer_remember_scroll();
|
||||
const auto snapshot = snap();
|
||||
const auto own = transfer_ui_club(snapshot);
|
||||
const auto data = demo_transfer_view(snapshot.state, *world_, own);
|
||||
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"))
|
||||
@@ -159,7 +159,7 @@ std::string App::render_transfer() {
|
||||
if (preview.is_null())
|
||||
preview = chosen;
|
||||
const auto listed = [&](const std::string &id) {
|
||||
const auto &ls = snapshot.state.at("transfer").at("listed");
|
||||
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) {
|
||||
@@ -204,8 +204,8 @@ std::string App::render_transfer() {
|
||||
"<section class=\"transfer-overview " +
|
||||
std::string(complete ? "transfer-complete" : "") +
|
||||
"\"><header class=\"transfer-heading\"><h2>Kader und "
|
||||
"Transfermarkt</h2><div><span>Verfügbares Kapital</span><strong>" +
|
||||
esc(cash(snapshot.state.at("cash").get<int64_t>())) +
|
||||
"Transfermarkt</h2>" + (engine_mode_?"<p id=\"transfer-engine-feedback\" style=\"position:absolute;left:0;right:650dp;bottom:0;font-size:23dp;line-height:27dp;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;\">"+esc(engine_busy_?engine_operation_:engine_notice_)+"</p>":"") + "<div><span>Verfügbares Kapital</span><strong class=\"" + money_classes(engine_mode_?engine_transfer_value_.at("cash").get<int64_t>():snapshot.state.at("cash").get<int64_t>()) + "\">" +
|
||||
esc(transfer_money((engine_mode_ ? engine_transfer_value_.at("cash").get<int64_t>() : snapshot.state.at("cash").get<int64_t>()))) +
|
||||
"</strong></div></header><div class=\"transfer-columns\"><section "
|
||||
"class=\"transfer-roster\"><header><h2>Dein Kader</h2><span>" +
|
||||
std::to_string(ours.size()) + " Spieler · Daten " + (b ? "B" : "A") +
|
||||
@@ -368,18 +368,18 @@ std::string App::render_transfer() {
|
||||
"</div><section id=\"transfer-preview\" class=\"transfer-preview\">";
|
||||
if (preview.is_object()) {
|
||||
const auto *source = world_->find("clubs", preview.at("club"));
|
||||
const auto fee = preview.at("fee").get<int64_t>();
|
||||
const auto remaining = snapshot.state.at("cash").get<int64_t>() +
|
||||
const auto fee = preview.at("fee").is_number_integer() ? preview.at("fee").get<int64_t>() : 0;
|
||||
const auto remaining = (engine_mode_ ? engine_transfer_value_.at("cash").get<int64_t>() : snapshot.state.at("cash").get<int64_t>()) +
|
||||
(preview.at("own") == true ? fee : -fee);
|
||||
out += "<p>" + label(source, 32) + "</p><div><section><span>" +
|
||||
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(cash(fee)) +
|
||||
"</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=\"" +
|
||||
std::string(remaining < 0 ? "transfer-negative" : "") + "\">" +
|
||||
esc(cash(remaining)) + "</strong></section></div>";
|
||||
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>";
|
||||
out += "</section><nav class=\"transfer-filters\">";
|
||||
@@ -397,7 +397,7 @@ std::string App::render_transfer() {
|
||||
: "false") +
|
||||
"\"");
|
||||
out += "</nav>";
|
||||
const auto strengths = demo_transfer_strengths(
|
||||
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 +=
|
||||
@@ -428,17 +428,19 @@ std::string App::render_transfer() {
|
||||
: "Kein Marktspieler ausgewählt") +
|
||||
"</p><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);
|
||||
out +=
|
||||
btn("transfer-offer",
|
||||
mine && listed(chosen.at("id")) ? "Vom Markt nehmen" : "Ver-kaufen",
|
||||
"",
|
||||
"id=\"transfer-offer-buy-sell\" data-kind=\"" +
|
||||
std::string(mine ? "sell" : "buy") + "\" " +
|
||||
std::string(chosen.is_object() ? "" : "disabled")) +
|
||||
std::string(chosen.is_object() && (!engine_mode_ || !mine || !listed(chosen.at("id"))) && (!pending || !pending_loan) ? "" : "disabled")) +
|
||||
btn("transfer-offer", "Ver-leihen", "",
|
||||
"id=\"transfer-offer-loan-lend\" data-kind=\"" +
|
||||
std::string(mine ? "lend" : "loan") + "\" " +
|
||||
std::string(chosen.is_object() ? "" : "disabled")) +
|
||||
std::string(chosen.is_object() && (!engine_mode_ || !mine || !listed(chosen.at("id"))) && (!pending || pending_loan) && (!engine_mode_ || mine || chosen.value("loan_allowed",false)) ? "" : "disabled")) +
|
||||
"</div></div></div></section>";
|
||||
}
|
||||
out += "</div><nav class=\"transfer-actions\">" +
|
||||
@@ -451,7 +453,7 @@ std::string App::render_transfer() {
|
||||
out += btn("transfer-criteria", "Spieler suchen", "",
|
||||
"id=\"transfer-criteria\"") +
|
||||
btn("transfer-suggest", "Vorschlag", "", "id=\"transfer-suggest\"") +
|
||||
btn("transfer-poach", "Abwerben", "", "id=\"transfer-poach\"") +
|
||||
btn("transfer-poach", "Abwerben", "", "id=\"transfer-poach\" " + std::string(engine_mode_?"disabled title=\"Noch nicht angebunden\"":"")) +
|
||||
btn("transfer-orders",
|
||||
"Aufträge (" + std::to_string(data.at("orders").size()) + ")",
|
||||
"", "id=\"transfer-orders\"");
|
||||
@@ -462,8 +464,8 @@ std::string App::render_transfer() {
|
||||
std::string App::render_transfer_dialog() {
|
||||
if (transfer_dialog_.empty())
|
||||
return {};
|
||||
const auto snapshot = snap();
|
||||
const auto actor = transfer_ui_club(snapshot);
|
||||
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, body, actions;
|
||||
double height = 500;
|
||||
const auto button = [&](const char *action, const std::string &caption,
|
||||
@@ -500,15 +502,15 @@ std::string App::render_transfer_dialog() {
|
||||
transfer_ui_number(r.at("age")) + " Jahre · Stärke " +
|
||||
transfer_ui_number(r.at("strength")) +
|
||||
"</span></div><div class=\"transfer-offer-club\">" +
|
||||
label(world_->find("clubs", r.at("club")), 58) +
|
||||
(world_->find("clubs",r.at("club"))?label(world_->find("clubs",r.at("club")),58):esc(r.value("club_name",std::string("—")))) +
|
||||
"</div></header><div class=\"transfer-demands\"><section><span>" +
|
||||
std::string(loan ? "Fiktive Leihgebühr" : "Ungefährer Marktwert") +
|
||||
"</span><strong>" + esc(cash(d.at("demand_fee").get<int64_t>())) +
|
||||
std::string(engine_mode_ ? "Ablöseforderung" : loan ? "Fiktive Leihgebühr" : "Ungefährer Marktwert") +
|
||||
"</span><strong>" + esc(transfer_money(d.at("demand_fee").get<int64_t>())) +
|
||||
"</strong></section><section><span>" +
|
||||
std::string(mine ? "Aktuelles Monatsgehalt" : "Gehaltswunsch") +
|
||||
std::string(engine_mode_ ? "Gehaltsreferenz / Monat" : mine ? "Aktuelles Monatsgehalt" : "Gehaltswunsch") +
|
||||
"</span><strong>" +
|
||||
(d.at("demand_salary").is_number_integer()
|
||||
? esc(cash(d.at("demand_salary").get<int64_t>()))
|
||||
? esc(transfer_money(d.at("demand_salary").get<int64_t>()))
|
||||
: "—") +
|
||||
"</strong></section></div><h3 class=\"transfer-offer-your\">Dein "
|
||||
"Angebot</h3><div class=\"transfer-offer-inputs\">";
|
||||
@@ -544,13 +546,13 @@ std::string App::render_transfer_dialog() {
|
||||
"<div class=\"transfer-premium-row\" style=\"" +
|
||||
rect((i % 2) * 1063, 48 + (i / 2) * 82, 1029, 82) + "\"><span>" +
|
||||
std::string(transfer_ui_bonuses[size_t(i)]) + "</span>" +
|
||||
btn("transfer-bonus", transfer_ui_number(d.at("bonuses")[size_t(i)]),
|
||||
btn("transfer-bonus", transfer_ui_number(engine_mode_&&i>=3?Json(d.at("bonuses")[size_t(i)].get<int>()*5):d.at("bonuses")[size_t(i)]),
|
||||
"amount-trigger",
|
||||
"id=\"transfer-bonus-" + std::to_string(i) + "\" data-index=\"" +
|
||||
std::to_string(i) + "\"") +
|
||||
"</div>";
|
||||
body += "</div></section><p class=\"transfer-offer-note\">" +
|
||||
std::string(mine ? "Der Spieler wird zum " +
|
||||
std::string(engine_mode_ ? "Die Engine entscheidet nach Bestätigung über dieses Angebot. 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 "
|
||||
@@ -594,7 +596,7 @@ std::string App::render_transfer_dialog() {
|
||||
"</span><input type=\"range\" id=\"transfer-range-" + key +
|
||||
"\" data-criterion=\"" + key + "\" min=\"" +
|
||||
std::to_string(i < 2 ? 16 : 0) + "\" max=\"" +
|
||||
std::to_string(i < 2 ? 40 : 100) + "\" step=\"1\" value=\"" +
|
||||
std::to_string(i < 2 ? (engine_mode_?47:40) : 100) + "\" step=\"1\" value=\"" +
|
||||
transfer_ui_number(d.at(key)) +
|
||||
"\"/><output id=\"transfer-range-value-" + key + "\">" +
|
||||
transfer_ui_number(d.at(key)) + "</output></div>";
|
||||
@@ -652,7 +654,7 @@ std::string App::render_transfer_dialog() {
|
||||
"class=\"transfer-info-photo\">" +
|
||||
(r.at("photo").is_string()
|
||||
? img(r.at("photo"), 440, 550, true, true, 650)
|
||||
: "<span>—</span>") +
|
||||
: engine_mode_ ? img("asset:player/generic/photo",440,550,true,false,650) : "<span>—</span>") +
|
||||
"</div><div class=\"transfer-info-facts\">";
|
||||
const std::vector<std::pair<std::string, std::string>> facts{
|
||||
{"Verein", r.at("club_name")},
|
||||
@@ -683,7 +685,7 @@ std::string App::render_transfer_dialog() {
|
||||
} else if (transfer_dialog_ == "team-info") {
|
||||
height = 800;
|
||||
title = "Team-Info";
|
||||
const auto values = demo_transfer_strengths(
|
||||
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=\"transfer-team-info\"><h3>" +
|
||||
label(world_->find("clubs", actor), 58) +
|
||||
@@ -766,7 +768,7 @@ std::string App::render_transfer_dialog() {
|
||||
"<span>" + transfer_ui_role(r.at("position")) + "</span><span>" +
|
||||
transfer_ui_number(r.at("age")) + "</span><span>" +
|
||||
transfer_ui_number(r.at("strength")) + "</span><span>" +
|
||||
esc(cash((r.at("fee").get<int64_t>() * 3 + 1) / 2)) +
|
||||
esc(transfer_money((r.at("fee").get<int64_t>() * 3 + 1) / 2)) +
|
||||
"</span></div>";
|
||||
body += "</div>";
|
||||
actions = button("transfer-poach-back", "Zurück zu Vereinen",
|
||||
@@ -775,7 +777,7 @@ std::string App::render_transfer_dialog() {
|
||||
} else if (transfer_dialog_ == "orders") {
|
||||
title = "Vorgemerkte Transferaufträge";
|
||||
const auto rows =
|
||||
demo_transfer_view(snapshot.state, *world_, actor).at("orders");
|
||||
transfer_data().at("orders");
|
||||
height = rows.empty() ? 430 : std::min(1450., 352. + rows.size() * 74.);
|
||||
body = "<div id=\"transfer-orders-scroll\" class=\"transfer-order-list\">";
|
||||
if (rows.empty())
|
||||
@@ -793,21 +795,21 @@ std::string App::render_transfer_dialog() {
|
||||
body +=
|
||||
"<div class=\"transfer-order-row\"><span>" +
|
||||
esc(o.at("name").get<std::string>()) + "</span><span>" +
|
||||
esc(o.at("poached") == true ? "Abwerben" : kinds.at(o.at("kind"))) +
|
||||
"</span><span>" + esc(cash(o.at("fee").get<int64_t>())) +
|
||||
esc(engine_mode_ ? "Gebot" : o.at("poached") == true ? "Abwerben" : kinds.at(o.at("kind"))) +
|
||||
"</span><span>" + esc(transfer_money(o.at("fee").get<int64_t>())) +
|
||||
"</span><span>" + std::to_string(o.at("months").get<int>()) +
|
||||
" Monate</span>" +
|
||||
btn("transfer-order-delete", "×", "",
|
||||
"id=\"transfer-order-delete-" + std::to_string(i) +
|
||||
"\" data-index=\"" + std::to_string(i) +
|
||||
"\" aria-label=\"Auftrag zurücknehmen\"") +
|
||||
"\" aria-label=\"Auftrag zurücknehmen\" " + std::string(engine_mode_?"disabled title=\"Noch nicht angebunden\"":"")) +
|
||||
"</div>";
|
||||
}
|
||||
}
|
||||
body += "</div>";
|
||||
actions = close("Zurück");
|
||||
} else {
|
||||
title = transfer_dialog_ == "booked" ? "Auftrag vorgemerkt"
|
||||
title = transfer_dialog_ == "booked" ? (engine_mode_ ? "Transferauftrag" : "Auftrag vorgemerkt")
|
||||
: "Transferliste voll";
|
||||
body = "<p class=\"transfer-notice\">" + esc(transfer_notice_) + "</p>";
|
||||
actions = close("Verstanden");
|
||||
|
||||
Reference in new issue
Block a user