The seller decides on the bids for a player he listed

At the weekly deadline the original shows the seller the bids for a player
on the transfer list; without that screen every bid for a human seller was
declined, so a listed player could never be sold. session.advance now takes
transferOffers {playerId: {accept: index} | {action: "decline"}}: bids
without an answer take the run back and decision_pending carries them, as a
contract running out does. Only an interface that sends the field is asked,
so a client that does not know the question keeps the run it always had.

The notebook lists the bids with club, fee, salary and term; one is
accepted or all are declined, and the kickoff is sent again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-16 14:54:48 +01:00
1 parent 92555b9ba0
commit 3330dfb69c
7 files changed
+120 -1

No files matched your search

+7
View File
@@ -1047,3 +1047,10 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect
/* line-up: the takers of the set pieces */
.pg-card.lp-piece,.pg-card.lp-piece:hover {flex:1;gap:4dp;padding:18dp 27dp;border-radius:36dp;min-width:0;}
.lp-piece strong {display:block;font-family:Display;font-weight:normal;font-size:38dp;line-height:46dp;}
/* a question that lists bids for a listed player */
.po-offers {display:block;margin:0 0 27dp;}
.po-offer {display:flex;align-items:center;gap:22dp;padding:14dp 0;border-top:2dp #2e2b2526;}
.po-crest {display:block;flex:none;width:72dp;height:72dp;}
.po-text {display:block;flex:1;min-width:0;}
.po-text strong {display:block;font-size:32dp;line-height:40dp;}
.po-text span {display:block;font-size:27dp;line-height:36dp;}
+1
View File
@@ -105,6 +105,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
| `balance.commit` | view future, nichtleere edits wie im Read, acceptWarning bei Bilanzwarnung | übernimmt die mit vorhandenen Core-Funktionen rekonstruierte Zukunftsplanung; keine unmittelbare Cash-Buchung. Fehler invalid_payload, confirmation_required, balance_refused; veraltete Karriere/Manager/Revision wie üblich. |
| `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 |
| `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` |
| `training.commit` | optional `types` (4), `areas` (9), `players [{playerId, intensity}]` | richtet das Training bei Bedarf ein, setzt erst die Senkungen, dann die Erhöhungen (jeder Zwischenstand bleibt in den Grenzen); Fehler `training_unavailable`, `unknown_player` und die Gründe der Engine |
+65
View File
@@ -9595,6 +9595,7 @@ cli::Json ModernSession::finish_live(const std::string& request_id, uint64_t pre
g_ = std::move(run.saved_state);
rand_ = run.saved_rand, game_ = run.saved_game;
g_.contract_screen = run.previous_contract_hook;
g_.transfer_offer_selector = run.previous_offer_selector;
contract_expiry_presenter_installed_ = run.previous_contract_installed;
revision = run.base_revision;
live_.reset();
@@ -9608,6 +9609,7 @@ cli::Json ModernSession::finish_live(const std::string& request_id, uint64_t pre
return refused;
}
g_.contract_screen = run.previous_contract_hook;
g_.transfer_offer_selector = run.previous_offer_selector;
contract_expiry_presenter_installed_ = run.previous_contract_installed;
modern::journal_advance(g_, run.saved_state);
modern::ensure_ui_identities(g_);
@@ -9951,6 +9953,18 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
}
run->answers[id] = x;
}
// the answers to bids for listed players; the rehearsal before this kickoff has asked every question
if (const cli::Json* e = ui_field(*payload, "transferOffers"); e && e->object())
for (const auto& [id, value] : *e->object()) {
const cli::Json* accept = ui_field(value, "accept");
run->offer_answers[id] = accept && accept->integer() && *accept->integer() >= 0 && *accept->integer() < 4 ? int(*accept->integer()) : -1;
}
run->previous_offer_selector = g_.transfer_offer_selector;
if (ui_field(*payload, "transferOffers")) g_.transfer_offer_selector = [answers = run->offer_answers](const GameState& state, const TransferOfferListView& view) -> int {
if (view.offer_count <= 0) return -1;
const auto it = answers.find(modern::ui_player_id(static_cast<const modern::ModernState&>(state), view.player));
return it != answers.end() && it->second >= 0 && view.offers[size_t(it->second)].present ? it->second : -1;
};
run->saved_state = saved_state, run->saved_rand = saved_rand, run->saved_game = saved_game;
run->base_revision = previous, run->from_date = g_.date, run->engine_revision = revision;
run->previous_contract_hook = g_.contract_screen;
@@ -10059,6 +10073,20 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
}
answers[id] = x;
}
// transferOffers {playerId: {accept: bid index 0-3} | {action: "decline"}}: the seller's answer
// to the bids for a player he put on the transfer list (the original's IncomingTransferScreen
// at the weekly deadline). Bids without an answer end the run the same way: it is rolled
// back and decision_pending carries the bids; the interface asks and sends the advance again.
std::map<std::string, int> offer_answers;
if (const cli::Json* e = ui_field(*payload, "transferOffers"); e && e->object())
for (const auto& [id, value] : *e->object()) {
const cli::Json* accept = ui_field(value, "accept");
if (accept && accept->integer() && *accept->integer() >= 0 && *accept->integer() < 4) offer_answers[id] = int(*accept->integer());
else if (ui_text(value, "action") == "decline") offer_answers[id] = -1;
else return refuse("invalid_payload", "transferOffers: accept nennt das Gebot 0-3, oder action ist decline.");
}
std::string pending_offer;
cli::Json::Object pending_offer_args;
std::string pending_player;
std::array<uint32_t, 4> pending_demands{};
// a run that is taken back returns the turn driver and the managers' desks as well
@@ -10113,13 +10141,50 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
awards.push_back(cli::Json::Object{{"competition", ui::original_to_utf8(v.competition_title)}, {"players", std::move(players)}});
if (inner) inner(state, v);
};
// only an interface that sends transferOffers (even an empty one) is asked; a client that does
// not know the question keeps the run it always had
const auto previous_selector = g_.transfer_offer_selector;
if (ui_field(*payload, "transferOffers")) g_.transfer_offer_selector = [&](const GameState& state, const TransferOfferListView& view) -> int {
if (view.offer_count <= 0) return -1; // the final refusal notice; the answer is ignored
const auto& modern_state = static_cast<const modern::ModernState&>(state);
const std::string id = modern::ui_player_id(modern_state, view.player);
if (const auto it = offer_answers.find(id); it != offer_answers.end())
return it->second >= 0 && view.offers[size_t(it->second)].present ? it->second : -1;
if (pending_offer.empty()) { // the first open question is asked; the run is taken back afterwards
pending_offer = id;
cli::Json::Array offers;
for (const auto& o : view.offers) {
if (!o.present) continue;
offers.push_back(cli::Json::Object{{"index", o.bid_index}, {"teamId", modern::ui_team_id(modern_state, o.buyer)},
{"fee", modern::ui_money(int64_t(o.fee))}, {"monthlySalary", modern::ui_money(int64_t(o.monthly_salary))},
{"months", int(o.contract_months)}, {"loan", o.loan}, {"eligible", o.eligible && o.transaction_supported}});
}
pending_offer_args = cli::Json::Object{{"decision", "transfer_offers"}, {"playerId", id},
{"name", ui::original_to_utf8(state.player_name(view.player))},
{"sellerManagerId", view.seller_manager >= 0 ? cli::Json(modern::ui_manager_id(modern_state, view.seller_manager)) : cli::Json(nullptr)},
{"askingFee", modern::ui_money(int64_t(view.asking_fee))}, {"offers", std::move(offers)}};
}
return -1;
};
const TurnAdvanceResult r = dispatch_kickoff(kickoff, revision, error);
g_.transfer_offer_selector = previous_selector;
turn_driver_.sportschau = previous_sportschau;
g_.contract_screen = previous_hook; // the session's own presenter again
contract_expiry_presenter_installed_ = previous_installed;
if (!pending_offer.empty() && pending_player.empty()) {
// bids were declined only because nobody had been asked: the run goes back and the question out
restore_run();
g_.contract_screen = previous_hook;
g_.transfer_offer_selector = previous_selector;
cli::Json pending = refuse("decision_pending", "Für einen Spieler der Transferliste liegen Angebote vor.");
auto& message = std::get<cli::Json::Object>(std::get<cli::Json::Object>(pending.value)["message"].value);
message["args"] = std::move(pending_offer_args);
return pending;
}
if (r.kind == TurnDeskKind::Failed || r.kind == TurnDeskKind::WaitingAtDesk) {
restore_run();
g_.contract_screen = previous_hook;
g_.transfer_offer_selector = previous_selector;
if (!pending_player.empty()) {
cli::Json pending = refuse("decision_pending", "Ein Vertrag läuft aus: Verlängern oder freigeben?");
auto& message = std::get<cli::Json::Object>(std::get<cli::Json::Object>(pending.value)["message"].value);
+3
View File
@@ -1175,6 +1175,9 @@ private:
cli::Json::Array awards;
std::function<int(GameState&, int, int)> previous_contract_hook;
bool previous_contract_installed = false;
// the seller's answers to bids for listed players (player id -> bid index, -1 declines)
std::map<std::string, int> offer_answers;
std::function<int(const GameState&, const TransferOfferListView&)> previous_offer_selector;
SportschauPresentationHooks previous_sportschau;
decltype(TurnDriver::live_minute) previous_live_minute;
~LiveRun() {
+39
View File
@@ -12,6 +12,8 @@ void App::engine_kickoff() {
if (engine_busy_ || !engine_link_) return;
// A rehearsal first: a question of the run (a contract running out) is asked before the
// kickoff, never after a match the manager has watched and steered.
// this interface answers the bids for listed players: the field says so even while it is empty
if (!engine_advance_payload_.contains("transferOffers")) engine_advance_payload_["transferOffers"] = Json::object();
Json rehearsal = engine_advance_payload_, live = engine_advance_payload_;
rehearsal["dryRun"] = true; live["live"] = true;
const auto probe = engine_advance_command(engine_data_, editor::new_id("request:ui-"), rehearsal);
@@ -56,6 +58,34 @@ void App::engine_kickoff() {
}
// A contract runs out on the way to the next desk: the manager extends at the player's
// demand, lets him go, or returns to the desk to deal with it there.
// The bids for a player the manager put on the transfer list: one is accepted or all are declined,
// and the advance is sent again with the answer.
void App::engine_offers_ask(const Json &args) {
const std::string id = args.value("playerId", std::string());
if (id.empty() || !args.contains("offers") || !args.at("offers").is_array()) return;
std::string seller;
try { const auto people = bank_players(); for (const auto &person : people) if (person.value("id", "") == args.value("sellerManagerId", std::string())) seller = person.value("name", ""); } catch (const std::exception &) {}
std::string name = args.value("name", id);
try {
for (const auto &p : engine_data_.at("squad").at("data").at("players"))
if (p.at("player").at("id") == id) name = p.at("player").at("name").get<std::string>();
} catch (const std::exception &) {}
const std::string text = "Für " + name + " liegen Angebote vor" + (seller.empty() ? std::string() : " (Verkäufer: " + seller + ")") + ". Verlangt waren " + engine_price(args.at("askingFee")) + ".";
std::string body = "<div class=\"po-offers\">";
for (const auto &offer : args.at("offers")) {
const auto *club = world_->find("clubs", offer.value("teamId", std::string()));
const std::string buyer = club ? world_->name(*club) : std::string("Ein Verein");
const bool loan = offer.value("loan", false), open = offer.value("eligible", false);
body += "<div class=\"po-offer\"><span class=\"po-crest\">" + (club ? crest(club, 72) : std::string()) + "</span><div class=\"po-text\"><strong>" + esc(buyer) + "</strong><span>" + (loan ? "Leihe, Gebühr " : "Ablöse ") +
esc(engine_price(offer.at("fee"))) + " · Gehalt " + esc(engine_price(offer.at("monthlySalary"))) + " monatlich · " + std::to_string(offer.value("months", 0)) + " Monate" + (open ? "" : " · derzeit nicht annehmbar") + "</span></div>" +
pg_button("engine-offer-accept", "Annehmen", "primary", "id=\"engine-offer-accept-" + std::to_string(offer.value("index", 0)) + "\" data-id=\"" + std::to_string(offer.value("index", 0)) + "\" " + (open ? "" : "disabled=\"disabled\"")) + "</div>";
}
body += "</div>";
engine_offer_player_ = id;
confirmation(text, [this, id] { engine_advance_payload_["transferOffers"][id] = {{"action", "decline"}}; engine_kickoff(); });
popup_accept_ = "Alle ablehnen";
popup_body_ = body;
}
void App::engine_expiry_ask(const Json &args) {
const std::string id = args.value("playerId", std::string());
if (id.empty()) return;
@@ -131,6 +161,8 @@ void App::engine_accept(EngineReply result) {
try { args = engine_response_.at("message").at("args"); } catch (const std::exception &) {}
if (engine_response_.value("code", "") == "decision_pending" && args.is_object() && args.value("decision", "") == "contract_expiry")
engine_expiry_ask(args);
else if (engine_response_.value("code", "") == "decision_pending" && args.is_object() && args.value("decision", "") == "transfer_offers")
engine_offers_ask(args);
}
if (engine_response_.contains("seasonOpening")) {
// a new season began: its draw is shown once the ticker is closed
@@ -427,6 +459,13 @@ void App::engine_event(Rml::Event &event) {
const auto action = node->GetAttribute<Rml::String>("data-action", ""), id = node->GetAttribute<Rml::String>("data-id", "");
if (!popup_.empty()) {
if(action=="balance-discard"){engine_balance_action(action,node);return;}
if (action == "engine-offer-accept") {
const auto player = engine_offer_player_;
const int index = node->GetAttribute<int>("data-id", -1);
popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true;
if (!player.empty() && index >= 0 && index < 4) { engine_advance_payload_["transferOffers"][player] = {{"accept", index}}; engine_kickoff(); }
return;
}
if (action == "engine-expiry-release") {
const auto player = engine_expiry_player_;
popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true;
+2
View File
@@ -36,6 +36,8 @@
Json engine_advance_payload_ = Json::object();
Json engine_postmatch_read_; // the engine's post-match read of the last kickoff
std::string engine_expiry_player_;
std::string engine_offer_player_; // the listed player whose bids are being decided
void engine_offers_ask(const Json &args);
void engine_kickoff();
// A kickoff of the engine that is played minute by minute while the ticker is open.
bool engine_live_running_ = false, engine_live_busy_ = false, engine_live_at_end_ = false;
+3 -1
View File
@@ -563,6 +563,7 @@ class App final : public Rml::EventListener {
std::string popup_, rendered_popup_;
bool rendered_confirm_ = false;
std::string popup_input_, popup_extra_, popup_accept_ = "Bestätigen";
std::string popup_body_; // markup under the question, for a question that lists things
bool popup_has_input_ = false, quit_after_save_ = false;
std::function<void(const std::string &)> text_accept_;
bool context_open_ = false, context_dirty_ = false;
@@ -741,6 +742,7 @@ class App final : public Rml::EventListener {
popup_has_input_ = false;
popup_input_.clear();
popup_extra_.clear();
popup_body_.clear();
popup_accept_ = "Bestätigen";
text_accept_ = {};
rendered_popup_.clear();
@@ -1315,7 +1317,7 @@ class App final : public Rml::EventListener {
element("popup")->SetInnerRML(
"<div class=\"fill popup-backdrop\"></div><div "
"class=\"popup-box\"><h2>" + std::string(confirm_ || text_accept_ ? "Rückfrage" : "Hinweis") + "</h2><p>" +
esc(popup_) + "</p>" +
esc(popup_) + "</p>" + popup_body_ +
(popup_has_input_
? "<input id=\"popup-text\" value=\"" + esc(popup_input_) +
"\" style=\"width:100%;margin-bottom:38dp;\"/>"