Search profile: session API and console commands (ShowSearchProfile, SuggestSearchProfile, SetSearchProfile)
CareerSession gets search_profile, suggest_search_profile and dispatch_search_profile (owner and modal-state checks, revision only when the stored profile changed). The console replaces the OpenSearch placeholder with three commands and documents them; with apply the matching listings are reported with the original's "Spieler ... ist interessant!" message. search_profile_valid separates a refused profile from a switched-off one. Part of #79 (the dialog in the graphical client is still open) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff4ad035a7
commit
b2484350d9
8 files changed
+145
-7
No files matched your search
@@ -6026,6 +6026,38 @@ bool CareerSession::apply_desk_setting(int manager, bool price, int index, int v
|
||||
return true;
|
||||
}
|
||||
|
||||
// The stored search profile of a manager slot (all zero for an invalid slot).
|
||||
SearchProfile CareerSession::search_profile(int manager) const { return bmh::search_profile(g_, manager); }
|
||||
|
||||
// The profile "Vorschlag" proposes for the manager's squad; nothing is stored.
|
||||
SearchProfile CareerSession::suggest_search_profile(int manager, bool whole_squad) const {
|
||||
return bmh::suggest_search_profile(g_, manager, whole_squad);
|
||||
}
|
||||
|
||||
// Stores an edited search profile like the closing dialog does and, with `apply`, returns the transfer-list entries
|
||||
// that fit it. Only the active manager of a club with a transfer market may do this, and not while another window
|
||||
// owns the session. The revision rises only when the stored bytes changed.
|
||||
std::optional<CareerSession::SearchProfileDispatch> CareerSession::dispatch_search_profile(int manager,
|
||||
const SearchProfile& profile, bool cancelled, bool apply, uint64_t& revision, std::string& error) {
|
||||
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
|
||||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ ||
|
||||
other_games_dispatch_active_ || transfer_offer_editor_ || market_dispatch_active_ ||
|
||||
pending_offer_dispatch_active_ || calendar_advance_active_) { error = "search_profile_blocked"; return std::nullopt; }
|
||||
if (manager < 0 || size_t(manager) >= g_.manager_teams.size() || g_.manager_teams[size_t(manager)] == kNoTeam ||
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager) != manager ||
|
||||
revision == std::numeric_limits<uint64_t>::max()) { error = "invalid_search_profile_owner"; return std::nullopt; }
|
||||
if (!search_profile_valid(profile)) { error = "invalid_search_profile"; return std::nullopt; }
|
||||
const auto before = bmh::search_profile(g_, manager);
|
||||
SearchProfileDispatch result;
|
||||
result.active = set_search_profile(g_, manager, profile, cancelled);
|
||||
const auto stored = bmh::search_profile(g_, manager);
|
||||
result.profile = stored;
|
||||
if (stored != before) ++revision;
|
||||
if (apply) result.hits = search_profile_hits(g_, manager);
|
||||
error.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Validates the owner and the price range (8-25) and applies the ticket price; revision plus one.
|
||||
bool CareerSession::dispatch_ticket_price(const TicketPriceRequest& request, uint64_t& revision,
|
||||
std::string& error) {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "game/pending_offer.hpp"
|
||||
#include "game/poach.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
#include "game/search_profile.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "ui/flow.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
@@ -178,6 +179,21 @@ public:
|
||||
uint64_t& revision, std::string& error,
|
||||
const std::function<int(const GameState&, const TransferOfferListView&)>& review = {});
|
||||
|
||||
// The search profile of a human manager (transfer market buttons "Suchen" and "Vorschlag", game/search_profile.hpp).
|
||||
// `search_profile` is the stored profile, `suggest_search_profile` the one the squad asks for (nothing is stored).
|
||||
// `dispatch_search_profile` stores an edited profile the way the closing dialog does (`cancelled` = left by right
|
||||
// click, which switches the profile off) and, with `apply`, lists the transfer-list entries that fit it right now.
|
||||
// The revision rises only when the stored profile changed.
|
||||
SearchProfile search_profile(int manager) const;
|
||||
SearchProfile suggest_search_profile(int manager, bool whole_squad) const;
|
||||
struct SearchProfileDispatch {
|
||||
SearchProfile profile{};
|
||||
bool active = false;
|
||||
std::vector<SearchProfileHit> hits;
|
||||
};
|
||||
std::optional<SearchProfileDispatch> dispatch_search_profile(int manager, const SearchProfile& profile, bool cancelled,
|
||||
bool apply, uint64_t& revision, std::string& error);
|
||||
|
||||
struct TransferMarketPreviewDispatch {
|
||||
ui::PreparationState preparation;
|
||||
ui::TransferMarketPreview quote;
|
||||
|
||||
Reference in new issue
Block a user