A listed player can be taken off the market again

transfer.submit {action: withdraw, playerId} ends the manager's own list
entry as it ends without a buyer. The transfer market's first button does
it for a listed player.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-17 14:02:17 +01:00
1 parent ce8b871202
commit 1ec8295c84
9 files changed
+85 -4

No files matched your search

+8 -1
View File
@@ -172,7 +172,14 @@ Json engine_transfer_command(const Json &b, const Json &draft,
const auto kind = draft.at("kind").get<std::string>(),
player = draft.at("player").get<std::string>();
Json payload;
if (kind == "sell" || kind == "lend") {
if (kind == "withdraw") {
const auto it =
std::find_if(d.at("squad").begin(), d.at("squad").end(),
[&](const auto &p) { return p.at("playerId") == player; });
check(it != d.at("squad").end() && it->at("listed") == true,
"Der Spieler steht nicht auf der Transferliste.");
payload = {{"action", "withdraw"}, {"playerId", player}};
} else if (kind == "sell" || kind == "lend") {
const auto it =
std::find_if(d.at("squad").begin(), d.at("squad").end(),
[&](const auto &p) { return p.at("playerId") == player; });
+8 -1
View File
@@ -274,8 +274,15 @@ bool App::engine_transfer_action(const std::string &action,
if (own) {
if (std::find(engine_transfer_value_.at("listed").begin(),
engine_transfer_value_.at("listed").end(),
row.at("id")) != engine_transfer_value_.at("listed").end())
row.at("id")) != engine_transfer_value_.at("listed").end()) {
// listed already: the first button takes him off the market again
if (kind == "sell") {
const Json draft = {{"kind", "withdraw"}, {"player", row.at("id")}};
confirmation(row.at("name").get<std::string>() + " vom Markt nehmen? Offene Gebote für ihn verfallen.", [send, draft] { send(draft); });
popup_accept_ = "Vom Markt nehmen";
}
return true;
}
const Json draft = {{"kind", kind}, {"player", row.at("id")}};
confirmation(row.at("name").get<std::string>() +
(kind == "lend" ? " zum Verleih anbieten?"
+1 -1
View File
@@ -326,7 +326,7 @@ std::string App::render_transfer() {
const bool on_list = mine && listed(chosen.at("id"));
out += "</section><div class=\"pg-col\" style=\"" + pg_css("gap:6px;") + "\">" +
pg_button("transfer-offer", on_list ? "Vom Markt nehmen" : mine ? "Verkaufen" : "Kaufen", "primary tm-deal",
"id=\"transfer-offer-buy-sell\" data-kind=\"" + std::string(mine ? "sell" : "buy") + "\" " + std::string(chosen.is_object() && (!engine_mode_ || !mine || !on_list) && (!pending || !pending_loan) ? "" : "disabled")) +
"id=\"transfer-offer-buy-sell\" data-kind=\"" + std::string(mine ? "sell" : "buy") + "\" " + std::string(chosen.is_object() && (!pending || !pending_loan) ? "" : "disabled")) +
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")) +