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:
1 parent
92555b9ba0
commit
3330dfb69c
7 files changed
+120
-1
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user