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
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;\"/>"
|
||||
|
||||
Reference in new issue
Block a user