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:
1 parent
ce8b871202
commit
1ec8295c84
9 files changed
+85
-4
No files matched your search
@@ -40,6 +40,7 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [src/modern/app/modern_session.cpp](../src/modern/app/modern_session.cpp): in Modern a new manager's assistant adapts the attitude to the score (as the computer clubs do) until the manager sets it himself; Classic starts at the most defensive attitude for whole matches.
|
||||
- [src/modern/game/career.cpp](../src/modern/game/career.cpp): retains an existing Modern club's league slot when a human joins, preserving its played results.
|
||||
- [src/modern/game/career.hpp](../src/modern/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
- [src/modern/game/desk_actions.cpp](../src/modern/game/desk_actions.cpp): in Modern a manager can take a player he listed off the transfer list again.
|
||||
- [src/modern/game/desk_actions.cpp](../src/modern/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
|
||||
- [src/modern/game/desk_actions.cpp](../src/modern/game/desk_actions.cpp): Modern training camps have grades up to six stars with a capped step, a higher limit and recovery extras.
|
||||
- [src/modern/game/desk_actions.cpp](../src/modern/game/desk_actions.cpp): the Modern Toto takes up to six columns (one in the original), each at the stake plus a 10 % fee per extra column, 400,000 at most in all.
|
||||
|
||||
@@ -88,6 +88,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
|
||||
| `budget.commit` | `budgetId` (`budget:merchandise`, `budget:press`, `budget:fans`), `amount` (`Money`) | setzt ein Budget; Fehler `unknown_budget`, `invalid_amount`, `advertising_refused` (z. B. Lieferung läuft, zu wenig Geld) |
|
||||
| `ticket.commit` | `price` (`Money`, 8–25 €) | der Eintrittspreis; Fehler `invalid_amount`, `ticket_refused` |
|
||||
| `transfer.submit` | `action: list`, `playerId`, optional `loan`; oder `action: bid`, `listingId`, `fee`, `monthlySalary` (`Money`), `years` 1–4 (Leihe 1–2), optional `loan`, optional `bonuses` (sieben gespeicherte Stufen: zuerst 0–20, dann 0–200) | setzt einen eigenen Spieler auf die Liste (bzw. bietet ihn zum Verleih an) oder gibt über den Angebotseditor des Originals ein Gebot ab (öffnen, Felder setzen, abschicken). `outcome`: `applied` (sofort angenommen), `offer_pending` (Antwort mit der nächsten Woche), `offer_rejected` (zu niedrig/abgelehnt). Fragt die Engine einen menschlichen Verkäufer (Abwerben), wird zurückgerollt: `decision_pending` (noch nicht unterstützt). Abgelehnte Listung: `listing_refused`, vollständige Rücknahme. Geldfelder verlangen EUR/2 und ganze Euro ohne Überlauf. Fehler `unknown_player`, `already_listed`, `unknown_listing`, `own_player`, `no_bid_slot`, `transfer_refused` |
|
||||
| `transfer.submit` (Zusatz) | `action: "withdraw"`, `playerId` | nimmt einen eigenen Spieler wieder von der Transferliste (neu in Modern). Der Listenplatz endet wie ohne Käufer: Gebote verfallen, der Platz wird frei; keine Zufallszahl. Fehler: `unknown_player`, `not_listed`, `bid_waiting` (ein Mitspieler hat geboten) |
|
||||
| `friendly.book` | `opponentId`, optional `home`, `date`, `acceptCost`, bei menschlichem Gegner `opponentConsent` | am Schreibtisch des Bundestrainers das Länderspiel (Rückmeldung mit Bonus, wenn das Original ihn gewährt); vereinbart das Freundschaftsspiel; Fehler `declined` (Kosten nicht bestätigt), `opponent_declined`, `insufficient_funds`, `date_unavailable`, `plan_full` u. a. |
|
||||
| `fixture.reschedule` | `matchId`, `date`; oder `action: undo`, `date` | verlegt eine eigene Ligapartie bzw. nimmt die Verlegung zurück; Fehler `invalid_day`, `day_full`, `team_clash`, `no_free_slot`, `no_moved_match` |
|
||||
| `environment.commit` | `itemId`, `level` 0–6 | setzt ein Monatsbudget des Umfelds (keine Sofortbuchung, kein Zufall); unverändert: `outcome: no_change`; Fehler `environment_refused` |
|
||||
|
||||
@@ -10710,6 +10710,16 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
if (!listed_result) { restore(); return refuse("transfer_refused", error); }
|
||||
if(listed_result->status!=TransferActionStatus::accepted) {restore();return refuse("listing_refused","Der Spieler konnte nicht auf die Transferliste gesetzt werden.");}
|
||||
feedback = loan ? "Der Spieler wird zum Verleih angeboten." : "Der Spieler steht auf der Transferliste.";
|
||||
} else if (action == "withdraw") {
|
||||
// {action: "withdraw", playerId}: a listed player of the manager's club leaves the list again
|
||||
const std::string id = ui_text(*payload, "playerId");
|
||||
const auto item = std::find_if(m.squad.begin(), m.squad.end(), [&](const auto& s) { return modern::ui_player_id(g_, s.player) == id; });
|
||||
if (item == m.squad.end()) return refuse("unknown_player", "Spieler nicht im Kader: " + id);
|
||||
if (transfer_offer_editor_) return refuse("decision_pending", "Bitte das offene Angebot zuerst abschließen.");
|
||||
const auto status = modern::withdraw_manager_player(g_, manager, item->player).status;
|
||||
if (status == TransferActionStatus::rejected) return refuse("bid_waiting", "Ein Mitspieler hat für diesen Spieler geboten.");
|
||||
if (status != TransferActionStatus::accepted) return refuse("not_listed", "Der Spieler steht nicht auf der Transferliste.");
|
||||
feedback = "Der Spieler ist vom Markt genommen.";
|
||||
} else if (action == "bid") {
|
||||
int entry = -1;
|
||||
if (std::sscanf(ui_text(*payload, "listingId").c_str(), "listing:%d", &entry) != 1) return refuse("unknown_listing", "listingId fehlt.");
|
||||
@@ -10893,7 +10903,7 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return refuse("invalid_payload", "action ist list, bid, poach, poachOffer oder poachCancel.");
|
||||
return refuse("invalid_payload", "action ist list, withdraw, bid, poach, poachOffer oder poachCancel.");
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
restore();
|
||||
|
||||
@@ -543,6 +543,38 @@ bool set_training_camp_focus(ModernState& g, int manager, const std::array<uint8
|
||||
return true;
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: in Modern a manager can take a player he listed off the transfer list again.
|
||||
TransferActionResult withdraw_manager_player(ModernState& g, int manager, int player) {
|
||||
TransferActionResult out;
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) {
|
||||
out.status = TransferActionStatus::invalid_manager;
|
||||
return out;
|
||||
}
|
||||
out.status = TransferActionStatus::invalid_player;
|
||||
const int team = g.manager_teams[size_t(manager)];
|
||||
if (team < 0 || team >= league_clubs() || player < 0 || player >= 0xfff) return out;
|
||||
const SquadRange range = squad_range(team);
|
||||
bool own = false;
|
||||
for (size_t i = 0; i < range.count && !own; ++i) own = (g.squad_slots.at(range.first + i) & 0xfff) == player;
|
||||
if (!own) return out;
|
||||
for (int entry = 0; entry < 40; ++entry) {
|
||||
const size_t slot = modern::transfer_list_slot() + size_t(entry);
|
||||
const uint32_t row = ::bmh::layout::EditorList + uint32_t(entry) * 0x58;
|
||||
if ((g.squad_slots.at(slot) & 0xfff) != player || !g.memory.has(row + 9) || (g.memory.u16(row + 8) & 0x7fff) != uint16_t(team)) continue;
|
||||
for (uint32_t b = 0; b < 4; ++b) {
|
||||
const int bidder = g.memory.u16(row + b * 2);
|
||||
if (bidder == 0xffff) continue;
|
||||
for (const int human : g.manager_teams)
|
||||
if (human == bidder) { out.status = TransferActionStatus::rejected; return out; }
|
||||
}
|
||||
for (uint32_t b = 0; b < 4; ++b) g.memory.set16(row + b * 2, 0xffff);
|
||||
g.squad_slots.at(slot) = 0x0fff;
|
||||
out.status = TransferActionStatus::accepted, out.player = player, out.list_entry = entry;
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
TransferActionResult list_manager_player(ModernState& g, int manager, int squad_row, WatcomRandom& rand,
|
||||
MinuteReport& report) {
|
||||
TransferActionResult out;
|
||||
|
||||
@@ -128,6 +128,12 @@ TransferActionResult submit_transfer_bid_source_human_buyer(ModernState& g,
|
||||
const TransferBidRequest& request, WatcomRandom& rand,
|
||||
const HumanBuyerSaleHooks& hooks, MinuteReport& report);
|
||||
|
||||
// A Modern rule: the manager takes one of his players off the transfer list again. The list
|
||||
// entry ends as it does when nobody wants the player: its bids are cleared and its place is
|
||||
// free. Draws no random number. accepted; invalid_player when he is not a listed player of the
|
||||
// manager's club; rejected while another human manager's bid waits on the entry.
|
||||
TransferActionResult withdraw_manager_player(ModernState& g, int manager, int player);
|
||||
|
||||
// Put one of the manager's squad rows on the list. The request consumes the original
|
||||
// listing-price RNG and returns the new stable entry index through the result.
|
||||
TransferActionResult list_manager_player(ModernState& g, int manager, int squad_row,
|
||||
|
||||
@@ -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; });
|
||||
|
||||
@@ -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?"
|
||||
|
||||
@@ -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")) +
|
||||
|
||||
@@ -381,6 +381,23 @@ int main(int argc, char** argv) {
|
||||
const J listed = session.ui_command(cmd("request:t9", "transfer.submit", O{{"action", "list"}, {"playerId", seller}}), rev);
|
||||
if (s(at(listed, "messageType")) != "command_result") std::fprintf(stderr, "list: %s\n", cli::dump_json(listed).c_str());
|
||||
check(s(at(listed, "messageType")) == "command_result" && rev == before + 1, "own player listed");
|
||||
// a second player goes on the list and is taken off the market again
|
||||
const std::string second = s(at((*squad)[squad->size() - 2], "playerId"));
|
||||
const auto listed_now = [&](const std::string& id) {
|
||||
const J now = session.ui_read(O{{"kind", "transfer"}}, rev);
|
||||
const auto* rows = at(at(now, "data"), "squad").array();
|
||||
if (rows) for (const auto& row : *rows) if (s(at(row, "playerId")) == id) return truth(at(row, "listed"));
|
||||
return false;
|
||||
};
|
||||
check(s(at(session.ui_command(cmd("request:t9b", "transfer.submit", O{{"action", "withdraw"}, {"playerId", second}}), rev), "code")) == "not_listed",
|
||||
"a player who is not listed cannot be withdrawn");
|
||||
session.ui_command(cmd("request:t9c", "transfer.submit", O{{"action", "list"}, {"playerId", second}}), rev);
|
||||
check(listed_now(second), "second player listed");
|
||||
const uint64_t listed_rev = rev;
|
||||
const J withdrawn = session.ui_command(cmd("request:t9d", "transfer.submit", O{{"action", "withdraw"}, {"playerId", second}}), rev);
|
||||
if (s(at(withdrawn, "messageType")) != "command_result") std::fprintf(stderr, "withdraw: %s\n", cli::dump_json(withdrawn).c_str());
|
||||
check(s(at(withdrawn, "messageType")) == "command_result" && rev == listed_rev + 1 && !listed_now(second) && listed_now(seller),
|
||||
"the player is off the market, the other listing stays");
|
||||
}
|
||||
std::string listing;
|
||||
J fee, salary;
|
||||
|
||||
Reference in new issue
Block a user