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

+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_);