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>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-16 15:26:03 +01:00
1 parent a2790751a6
commit 7424b09738
8 files changed
+282 -3

No files matched your search

+1
View File
@@ -106,6 +106,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
| `news.update` | `messageId`, `action` `read`/`unread`/`archive`/`trash`/`restore` | eine Nachricht des eigenen Postfachs: gelesen und Papierkorb sind Markierungen der Oberfläche (im Spielstand, `news_marks` je Manager; die Nachricht bleibt im Postfach des Originals, `restore` holt sie zurück), `archive` ist das „Behalten“ des Originals (eine behaltene Nachricht wird bei vollem Postfach nicht verdrängt), `restore` gibt sie wieder frei. Endgültiges Löschen bietet die Schnittstelle nicht an. Unverändert: `no_change`; Fehler `unknown_message` |
| `lineup.commit` | `order`: Spieler-IDs in der gewünschten Reihenfolge | öffnet die Aufstellung wie am Schreibtisch und tauscht die Zeilen; Fehler `unknown_player`, `lineup_refused` (z. B. Verletzte, Ausländerregel) |
| `session.advance` (Zusatz) | `transferOffers {playerId: {accept: 0–3} \| {action: "decline"}}` | die Antwort des Verkäufers auf die Gebote für einen Spieler, den er auf die Transferliste gesetzt hat (Stichtag der Woche). Gefragt wird nur, wer das Feld sendet (auch leer); ohne das Feld läuft der Anstoß wie bisher und alle Gebote an menschliche Verkäufer verfallen. Ohne Antwort wird der Lauf zurückgenommen und `decision_pending` mit `args {decision: "transfer_offers", playerId, name, sellerManagerId, askingFee, offers [{index, teamId, fee, monthlySalary, months, loan, eligible}]}` gemeldet; die Oberfläche fragt und sendet den Anstoß erneut |
| `transfer.submit` (Abwerben) | `action: "poach"`, `playerId` · `action: "poachOffer"`, `fee`, `monthlySalary`, `years` 1–4 · `action: "poachCancel"` | zweistufig wie im Original: `poach` prüft, fragt den Verein und zählt den Versuch (fünf je Saison); kann geboten werden, bleibt der Angebotseditor offen und die Antwort trägt `outcome: "poach_open"` und `poach {playerId, name, sellerId, askingFee, askingMonthlySalary, fee, monthlySalary, feeRange {min, max}, salaryRange {min, max}, years, attemptsLeft}`, sonst `poach_refused` mit der Begründung. `poachOffer` wird sofort entschieden (`poach_accepted`, `poach_rejected`; ein zu niedriges Gebot lässt den Editor offen: `poach_open`), `poachCancel` schließt ohne Gebot. Solange der Editor offen ist, verweigern andere Befehle; Fehler `poach_open`, `no_poach`, `unknown_player`, `transfer_refused` |
| `lineup.setOrder` | `playerId`, `aspect` 0–3, `value` 2–40 | eine der vier Anweisungen eines aufgestellten Spielers (die vier Pfeile der Originalansicht; der Read `lineup` nennt sie je Feldspieler unter `positions[].orders`); Fehler `invalid_payload`, `unknown_player`, `lineup_refused` |
| `lineup.setPiece` | `piece` `freeKick`/`penalty`/`corner` und `playerId`, oder `auto: true` | trägt einen Schützen ein (aufgestellt oder auf der Bank, einsatzfähig) bzw. gibt alle drei an den Assistenten zurück; der Read `lineup` nennt sie unter `setPieces` (`null` = Assistent); Fehler `invalid_payload`, `unknown_player`, `lineup_refused` |
| `tactics.commit` | `values`: die acht Werte | jede geänderte Einstellung über die Prüfung der Taktiktafel (eine gesetzte Grundausrichtung beendet die Steuerung durch den Assistenten); Fehler `invalid_tactic` |
+112 -1
View File
@@ -10510,6 +10510,7 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
const ui::TransferMarketState m = modern::project_transfer_market(g_, revision);
std::string feedback;
bool bid_pending = false;
const auto saved_poach = poach_;
try {
if (action == "list") {
const std::string id = ui_text(*payload, "playerId");
@@ -10599,11 +10600,121 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
answer = modern::ui_command_result(request_id, previous, revision, {"transfer"}, feedback);
std::get<cli::Json::Object>(answer.value)["outcome"] = "offer_rejected";
}
} else if (action == "poach" || action == "poachOffer" || action == "poachCancel") {
// Poaching, in two steps as the original has it:
// {action: "poach", playerId}: the checks, the club's answer and the special list row
// (start_poach). The attempt counts from here. Where an offer can be made the offer
// editor stays open and the answer carries what is asked under "poach".
// {action: "poachOffer", fee, monthlySalary, years 1-4}: the offer on the open editor,
// decided at once; a low offer keeps the editor open.
// {action: "poachCancel"}: the editor is closed without an offer.
const auto quote_of = [&](const ui::OutgoingTransferEditorState& e) {
return cli::Json::Object{{"playerId", modern::ui_player_id(g_, e.player)}, {"name", ui::original_to_utf8(e.panel.player_name)},
{"sellerId", e.seller >= 0 && e.seller < league_clubs() ? cli::Json(modern::ui_team_id(g_, e.seller)) : cli::Json(nullptr)},
{"askingFee", modern::ui_money(int64_t(e.panel.asking_fee))}, {"askingMonthlySalary", modern::ui_money(int64_t(e.panel.asking_monthly_salary))},
{"fee", modern::ui_money(int64_t(e.fee))}, {"monthlySalary", modern::ui_money(int64_t(e.monthly_salary))},
// the bounds the editor accepts for the two sums
{"feeRange", cli::Json::Object{{"min", modern::ui_money(int64_t(e.money_calculators[0].minimum))}, {"max", modern::ui_money(int64_t(e.money_calculators[0].maximum))}}},
{"salaryRange", cli::Json::Object{{"min", modern::ui_money(int64_t(e.money_calculators[1].minimum))}, {"max", modern::ui_money(int64_t(e.money_calculators[1].maximum))}}},
{"years", int(e.duration_years)}, {"attemptsLeft", modern::poach_attempts_left(g_, manager)}};
};
if (action == "poach") {
if (transfer_offer_editor_ || poach_) return refuse("poach_open", "Ein Abwerbeversuch ist noch offen.");
const std::string id = ui_text(*payload, "playerId");
int slot = -1;
for (int t = 0; t < league_clubs() && slot < 0; ++t) {
if (t == team) continue;
const SquadRange other = squad_range(t);
for (size_t i = 0; i < other.count; ++i) {
const int p = g_.squad_slots[other.first + i] & 0x0fff;
if (p != 0x0fff && modern::ui_player_id(g_, p) == id) { slot = int(other.first + i); break; }
}
}
if (slot < 0) return refuse("unknown_player", "Dieser Spieler spielt bei keinem anderen Verein der Ligen.");
const auto opened = open_poach(manager, slot, revision, error);
if (!opened) { restore(); poach_ = saved_poach; return refuse("transfer_refused", error); }
std::string text;
for (const auto& line : opened->start.messages) text += (text.empty() ? "" : " ") + ui::original_to_utf8(line);
if (opened->editor) {
revision = previous + 1;
transfer_offer_revision_ = revision;
answer = modern::ui_command_result(request_id, previous, revision, {"transfer"}, text.empty() ? "Der Verein nennt seine Forderung." : text);
auto& out = std::get<cli::Json::Object>(answer.value);
out["outcome"] = "poach_open";
out["poach"] = quote_of(opened->editor->editor);
} else {
revision = opened->start.status == PoachStatus::invalid ? previous : previous + 1;
answer = modern::ui_command_result(request_id, previous, revision, {"transfer"}, text.empty() ? "Abwerben ist hier nicht möglich." : text);
auto& out = std::get<cli::Json::Object>(answer.value);
out["outcome"] = "poach_refused";
out["attemptsLeft"] = modern::poach_attempts_left(g_, manager);
}
} else {
if (!transfer_offer_editor_ || !poach_) return refuse("no_poach", "Es ist kein Abwerbeversuch offen.");
transfer_offer_revision_ = revision; // other commands may have counted on since the editor opened
ui::OutgoingTransferEditorState e = transfer_offer_projection(g_, *transfer_offer_editor_, revision,
g_.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
const auto send = [&](ui::OutgoingTransferRequestKind k, ui::OutgoingTransferField field, uint32_t value)
-> std::optional<TransferOfferEditorDispatch> {
ui::OutgoingTransferRequest r;
r.kind = k;
r.identity = {e.manager_slot, e.runtime_club, e.revision, e.list_entry, e.source_slot, e.player, e.seller, e.bid_slot};
r.field = field, r.value = value, r.quote_loan = e.quote_loan;
r.fee = e.fee, r.monthly_salary = e.monthly_salary, r.duration_years = e.duration_years, r.bonuses = e.bonuses;
r.quoted_fee = e.panel.quoted_fee, r.quoted_monthly_salary = e.panel.quoted_monthly_salary, r.quoted_years = e.panel.quoted_years;
auto d = dispatch_transfer_offer(r, hooks, revision, error);
if (d) e = d->editor;
return d;
};
if (action == "poachCancel") {
if (!send(ui::OutgoingTransferRequestKind::cancel, ui::OutgoingTransferField::fee, e.fee)) { restore(); poach_ = saved_poach; return refuse("transfer_refused", error); }
feedback = "Der Abwerbeversuch ist beendet.";
} else {
const auto money_of = [&](const char* key) -> int64_t {
const cli::Json* v = ui_field(*payload, key);
try {
if (!v || ui_text(*v, "currency") != "EUR") return -1;
const auto text = ui_text(*v, "minor"); size_t end = 0; const auto amount = std::stoll(text, &end);
return end == text.size() && amount >= 0 && amount % 100 == 0 && amount / 100 <= std::numeric_limits<int32_t>::max() / 12 * 12 ? amount : -1;
} catch (const std::exception&) { return -1; }
};
const int64_t fee = money_of("fee"), salary = money_of("monthlySalary");
const cli::Json* years = ui_field(*payload, "years");
if (fee < 0 || salary < 0 || salary / 100 > std::numeric_limits<int32_t>::max() / 12 || !years || !years->integer() || *years->integer() < 1 || *years->integer() > 4)
return refuse("invalid_payload", "fee, monthlySalary (Money, ganze Euro) und years 1-4 nötig.");
bool ok = true;
if (ok && e.fee != uint32_t(fee / 100)) { e.fee = uint32_t(fee / 100); ok = bool(send(ui::OutgoingTransferRequestKind::quote_change, ui::OutgoingTransferField::fee, e.fee)); }
if (ok && e.monthly_salary != uint32_t(salary / 100)) {
e.monthly_salary = uint32_t(salary / 100);
ok = bool(send(ui::OutgoingTransferRequestKind::quote_change, ui::OutgoingTransferField::monthly_salary, e.monthly_salary));
}
if (ok && e.duration_years != uint8_t(*years->integer())) {
e.duration_years = uint8_t(*years->integer());
ok = bool(send(ui::OutgoingTransferRequestKind::quote_change, ui::OutgoingTransferField::duration_years, e.duration_years));
}
std::optional<TransferOfferEditorDispatch> sent;
if (ok) sent = send(ui::OutgoingTransferRequestKind::submit, ui::OutgoingTransferField::fee, e.fee);
if (!sent) { restore(); poach_ = saved_poach; return refuse("transfer_refused", error); }
const TransferActionStatus status = sent->action.status;
feedback = status == TransferActionStatus::accepted ? "Angenommen: Der Spieler wechselt zu Ihrem Verein."
: status == TransferActionStatus::offer_too_low ? "Das Angebot ist zu niedrig."
: status == TransferActionStatus::pending ? "Das Angebot ist abgegeben."
: notices.empty() ? "Das Angebot wurde abgelehnt." : "";
for (const auto& n : notices) feedback += " " + n;
revision = previous + 1;
if (!e.closed) transfer_offer_revision_ = revision; // the editor waits for a better offer
answer = modern::ui_command_result(request_id, previous, revision, {"transfer", "squad", "desktop"}, feedback);
auto& out = std::get<cli::Json::Object>(answer.value);
out["outcome"] = status == TransferActionStatus::accepted ? "poach_accepted" : !e.closed ? "poach_open" : status == TransferActionStatus::pending ? "offer_pending" : "poach_rejected";
if (!e.closed) out["poach"] = quote_of(e);
}
}
} else {
return refuse("invalid_payload", "action ist list oder bid.");
return refuse("invalid_payload", "action ist list, bid, poach, poachOffer oder poachCancel.");
}
} catch (const std::exception& ex) {
restore();
poach_ = saved_poach;
if (question) return refuse("decision_pending", "Ein menschlicher Verkäufer müsste gefragt werden (noch nicht unterstützt).");
return refuse("transfer_refused", ex.what());
}
+1
View File
@@ -22,6 +22,7 @@ Json engine_training_command(const Json &bundle, const Json &draft,
Json engine_bank_projection(const Json &bundle);
Json engine_bank_command(const Json &bundle, const Json &payload, const std::string &request_id);
Json engine_order_command(const Json &bundle, const std::string &player, int aspect, int value, const std::string &request_id);
Json engine_poach_command(const Json &bundle, const Json &payload, const std::string &request_id);
Json engine_set_piece_command(const Json &bundle, const Json &payload, const std::string &request_id);
Json engine_credit_projection(const Json &bundle, const Json &read);
Json engine_credit_command(const Json &bundle, const Json &read, const Json &edits, const std::string &request_id);
+7
View File
@@ -213,6 +213,13 @@ void App::engine_poll() {
}
refresh(); return;
}
if (result.response.value("messageType", "") == "poach_squad") {
// the squad of the club a manager wants to poach from
const auto &read = result.response.at("read");
if (read.value("messageType", "") == "error" || !read.contains("data")) { engine_notice_ = "Der Kader ist nicht verfügbar."; engine_poach_squad_ = Json(); }
else { engine_poach_squad_ = read.at("data"); if (menu_ == "transfer" && transfer_dialog_ == "poach-clubs") { transfer_dialog_ = "poach-roster"; transfer_view_["poach_top"] = 0; focus_after_render_ = "transfer-poach-back"; } }
refresh(); return;
}
if (result.response.value("messageType", "") == "credit_preview") {
const auto &read = result.response.at("read");
const auto lender = result.response.value("lender", std::string("bank"));
+5
View File
@@ -190,6 +190,11 @@ Json engine_order_command(const Json &bundle, const std::string &player, int asp
require(projection.at("orders").contains(player) && aspect >= 0 && aspect <= 3 && value >= 2 && value <= 40, "Ungültige Anweisung.");
return sports_command(bundle, "lineup.setOrder", {{"playerId", player}, {"aspect", aspect}, {"value", value}}, request_id);
}
Json engine_poach_command(const Json &bundle, const Json &payload, const std::string &request_id) {
const auto action = payload.at("action").get<std::string>();
require(action == "poach" || action == "poachOffer" || action == "poachCancel", "Ungültiger Abwerbeauftrag.");
return sports_command(bundle, "transfer.submit", payload, request_id);
}
Json engine_set_piece_command(const Json &bundle, const Json &payload, const std::string &request_id) {
const auto projection = engine_lineup_projection(bundle);
require(projection.at("set_pieces").is_object(), "Schützen sind in diesem Kontext nicht verfügbar.");
+4
View File
@@ -134,6 +134,10 @@
Json engine_transfer_context_,engine_transfer_value_,engine_transfer_filters_=engine_transfer_filters();
bool engine_transfer_submitting_=false;
// poaching: the squad of the club looked at, what the club asks while an attempt is open
// (with the offer being written), and whether an answer of the game is awaited
Json engine_poach_squad_, engine_poach_quote_;
bool engine_poach_waiting_ = false;
void engine_transfer_sync();
Json transfer_data() const;
std::string transfer_money(const Json &) const;
+108
View File
@@ -36,6 +36,33 @@ void App::engine_transfer_sync() {
engine_transfer_projection(engine_data_, engine_transfer_filters_);
} catch (const std::exception &) {
}
if (engine_poach_waiting_) {
// the game's answer to a step of poaching
engine_poach_waiting_ = false;
const bool refused = engine_response_.value("messageType", "") != "command_result";
const auto outcome = engine_response_.value("outcome", std::string());
if (outcome == "poach_open" && engine_response_.contains("poach")) {
const bool again = engine_poach_quote_.is_object();
Json quote = engine_response_.at("poach");
// the game names him in its short form; the squad just read has his full name
try { for (const auto &row : engine_poach_squad_.at("players")) if (row.at("player").at("id") == quote.at("playerId")) quote["name"] = engine_text(row.at("player").at("name")); } catch (const std::exception &) {}
// the offer starts at what is asked; a second try keeps what was offered
quote["offer_fee"] = again ? engine_poach_quote_.at("offer_fee") : Json(engine_money_minor(quote.at("askingFee")) / 100);
quote["offer_salary"] = again ? engine_poach_quote_.at("offer_salary") : Json(engine_money_minor(quote.at("askingMonthlySalary")) / 100);
quote["offer_years"] = again ? engine_poach_quote_.at("offer_years") : Json(std::clamp(quote.value("years", 2), 1, 4));
quote["note"] = again ? engine_notice_ : std::string();
engine_poach_quote_ = quote;
transfer_dialog_ = "poach-offer"; focus_after_render_ = "transfer-poach-fee";
} else if (refused && engine_poach_quote_.is_object()) {
engine_poach_quote_["note"] = engine_notice_; // the attempt is still open
transfer_dialog_ = "poach-offer";
} else {
const bool cancelled = engine_poach_quote_.is_object() && outcome.empty() && !refused;
engine_poach_quote_ = Json(); engine_poach_squad_ = Json();
if (cancelled) transfer_dialog_.clear();
else { transfer_dialog_ = "booked"; transfer_notice_ = engine_notice_; focus_after_render_ = "transfer-close"; }
}
}
if (engine_transfer_submitting_) {
engine_transfer_submitting_ = false;
transfer_dialog_ = "booked";
@@ -82,10 +109,91 @@ bool App::engine_transfer_action(const std::string &action,
},
true);
};
const auto poach_send = [this](const Json &payload, const char *label) {
if (!engine_fresh_ || engine_busy_) return;
try {
const auto request = engine_poach_command(engine_data_, payload, editor::new_id("request:ui-"));
engine_poach_waiting_ = true;
auto link = engine_link_;
engine_start(label, [link, request] {
const auto reply = link->command(request);
return EngineReply{link, link->snapshot(), reply, nullptr};
}, true);
} catch (const std::exception &e) { message(e.what()); }
};
if (action == "transfer-close") {
// an open attempt is ended in the game as well
if (engine_poach_quote_.is_object()) { poach_send({{"action", "poachCancel"}}, "Abwerbeversuch wird beendet …"); return true; }
close_transfer();
return true;
}
if (action == "transfer-poach") {
const auto own = engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>();
const auto *c = world_->find("clubs", own);
transfer_dialog_ = "poach-clubs";
transfer_poach_league_ = c ? c->value("competition", "") : "";
transfer_poach_club_.clear(); engine_poach_squad_ = Json(); engine_poach_quote_ = Json();
transfer_view_["poach_top"] = 0;
transfer_return_focus_ = target ? target->GetId() : "transfer-poach";
focus_after_render_ = "transfer-poach-country";
refresh();
return true;
}
if (action == "transfer-poach-club" && target) {
const auto club = target->GetAttribute<Rml::String>("data-club", "");
if (!world_->find("clubs", club)) return true;
transfer_poach_club_ = club;
auto link = engine_link_;
engine_start("Kader wird gelesen …", [link, club] {
auto response = link->read({{"kind", "squad"}, {"teamId", club}});
return EngineReply{link, link->snapshot(), {{"messageType", "poach_squad"}, {"read", response}}, nullptr};
});
return true;
}
if (action == "transfer-poach-back") {
transfer_dialog_ = "poach-clubs"; engine_poach_squad_ = Json();
focus_after_render_ = "transfer-poach-club-" + transfer_poach_club_;
refresh();
return true;
}
if (action == "transfer-poach-player") {
if (transfer_dialog_ != "poach-roster" || id.empty()) return true;
std::string name = id;
try { for (const auto &row : engine_poach_squad_.at("players")) if (row.at("player").at("id") == id) name = engine_text(row.at("player").at("name")); } catch (const std::exception &) {}
confirmation("Bei " + name + " anfragen? Schon die Anfrage zählt als einer der fünf Abwerbeversuche dieser Saison, und jeden Spieler kann man nur einmal je Saison fragen.",
[this, poach_send, id] { poach_send({{"action", "poach"}, {"playerId", id}}, "Der Verein wird gefragt …"); });
popup_accept_ = "Anfragen";
return true;
}
if (action == "transfer-poach-amount" && target && engine_poach_quote_.is_object()) {
const std::string field = target->GetAttribute<Rml::String>("data-id", "");
if (field != "offer_fee" && field != "offer_salary") return true;
AmountRequest a;
a.title = field == "offer_fee" ? "Ablöse" : "Monatsgehalt"; a.unit = "€"; a.return_focus = target->GetId();
a.min = 0; a.max = field == "offer_fee" ? 99999999 : 9999999; a.step = 1; a.review = false;
// what the game's editor accepts
try {
const auto &range = engine_poach_quote_.at(field == "offer_fee" ? "feeRange" : "salaryRange");
a.min = engine_money_minor(range.at("min")) / 100; a.max = std::max<int64_t>(a.min, engine_money_minor(range.at("max")) / 100);
} catch (const std::exception &) {}
a.value = std::clamp<int64_t>(engine_poach_quote_.at(field).get<int64_t>(), a.min, a.max);
a.suggestion_step = field == "offer_fee" ? 100000 : 1000;
a.accept = [this, field](int64_t value) { if (!engine_poach_quote_.is_object()) return false; engine_poach_quote_[field] = value; refresh(); return true; };
open_amount(std::move(a));
return true;
}
if (action == "transfer-poach-years" && target && engine_poach_quote_.is_object()) {
const int years = target->GetAttribute<int>("data-id", 0);
if (years >= 1 && years <= 4) engine_poach_quote_["offer_years"] = years;
focus_after_render_ = target->GetId(); refresh();
return true;
}
if (action == "transfer-poach-submit" && engine_poach_quote_.is_object()) {
const auto cash = [](int64_t euros) { return Json{{"currency", "EUR"}, {"minorUnits", 2}, {"minor", std::to_string(euros * 100)}}; };
poach_send({{"action", "poachOffer"}, {"fee", cash(engine_poach_quote_.at("offer_fee").get<int64_t>())}, {"monthlySalary", cash(engine_poach_quote_.at("offer_salary").get<int64_t>())},
{"years", engine_poach_quote_.at("offer_years")}}, "Das Angebot wird geprüft …");
return true;
}
if (action == "transfer-offer-back") {
transfer_dialog_ = "offer";
focus_after_render_ = "transfer-fee";
+44 -2
View File
@@ -330,7 +330,7 @@ std::string App::render_transfer() {
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\" " + std::string(engine_mode_ ? "disabled title=\"Noch nicht angebunden\"" : "")) + "</div></div>";
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);
@@ -463,7 +463,7 @@ std::string App::render_transfer_dialog() {
} else if (transfer_dialog_ == "poach-clubs") {
width = 900;
title = "Spieler abwerben";
sub = "Verein wählen, danach einen Spieler aus dessen Beispielkader.";
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_);
@@ -483,6 +483,48 @@ std::string App::render_transfer_dialog() {
"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_);