Search profile engine: closing rule, "Vorschlag" and matching shared with the market news
New game/search_profile.* holds the 18-byte search profile of a human manager (manager record +0x1f6): the dialog's closing rule, the suggestion generated from the squad (original sub_18F06), the position strengths (sub_19A38) and the listing match (sub_190B5). search_profile_news in month.cpp now uses the same matching rule. Compared with the Diamond 3.7 routines in the emulator harness on 10 savegames (306 runs, 406 matched listings, no difference; a deliberately changed profile is detected). Part of #79 (the dialog in the graphical client and the console commands follow) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9ba514a65
commit
ff4ad035a7
6 files changed
+346
-39
No files matched your search
+3
-39
@@ -24,6 +24,7 @@
|
||||
#include "game/messages.hpp"
|
||||
#include "game/prediction.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/search_profile.hpp"
|
||||
#include "game/season.hpp"
|
||||
#include "game/weekly.hpp"
|
||||
#include "game/human_buyer_sale.hpp"
|
||||
@@ -915,46 +916,9 @@ ContractInsuranceResult contract_insurance(GameState& g, int manager, int row, i
|
||||
}
|
||||
|
||||
void search_profile_news(GameState& g, int manager, uint32_t list, int player) {
|
||||
const StaticMemory& mem = g.memory;
|
||||
const size_t rec = size_t(manager) * kRecord;
|
||||
auto b = [&](size_t off) { return int(g.manager_records.at(rec + off)); };
|
||||
const int team = g.manager_teams.at(size_t(manager));
|
||||
// The matching rule is shared with the search dialog (search_profile.cpp, original sub_190B5).
|
||||
player &= 0xFFF;
|
||||
if (team == kNoTeam || (mem.u16(list + 8) & 0x7FFF) == team || (b(0x1f6) & 0x40)) return;
|
||||
const uint32_t w364 = g.players.at(size_t(player)).w364, w35c = g.players.at(size_t(player)).w35c;
|
||||
// position wanted (or none selected) and age within the range
|
||||
if (b(0x1f6 + (w364 & 3)) == 0 && b(0x1f9) + b(0x1f8) + b(0x1f7) + b(0x1f6) != 0) return;
|
||||
const int age = int((w364 >> 21) & 0x1F);
|
||||
if (age < b(0x1fa) || age > b(0x1fb)) return;
|
||||
// strength by the selected attributes (condition, technique, form; none = all three)
|
||||
int8_t selected = int8_t(b(0x200) + b(0x1fe) + b(0x1ff));
|
||||
if (selected == 0) selected = 3;
|
||||
int sum = 0, n = 0, form = 0;
|
||||
if (b(0x1fe) != 0 || selected == 3) sum = int((w35c >> 14) & 0x7F), n = 1;
|
||||
if (b(0x1ff) != 0 || selected == 3) sum = int16_t(sum) + int((w35c >> 7) & 0x7F), n++;
|
||||
if (b(0x200) != 0 || selected == 3) form = int(w35c & 0x7F);
|
||||
int16_t strength;
|
||||
if (n == 0) {
|
||||
strength = int16_t((form - 0x23) * 3 + 10);
|
||||
} else {
|
||||
strength = int16_t(uint32_t(sum) / uint32_t(n));
|
||||
if (form != 0) strength = int16_t(uint32_t(strength * int16_t((int16_t(form) >> 3) + 0x5e)) / 100);
|
||||
}
|
||||
if (strength < b(0x1fc) || strength > b(0x1fd)) return;
|
||||
// left / right foot and wing preferences (w35c bits 21-23 and 24-26)
|
||||
const int lane = int((w35c >> 21) & 7), foot = int((w35c >> 24) & 7);
|
||||
bool low_foot = b(0x201) || b(0x203), high_foot = b(0x202) || b(0x204);
|
||||
if (low_foot && high_foot) low_foot = high_foot = false;
|
||||
bool low_lane = b(0x201) || b(0x202), high_lane = b(0x203) || b(0x204);
|
||||
if (low_lane && high_lane) low_lane = high_lane = false;
|
||||
if ((low_lane && lane >= 3) || (high_lane && lane <= 4) || (low_foot && foot >= 3) || (high_foot && foot <= 4)) return;
|
||||
// the price class (asking price 70..130 %) against the classes wanted
|
||||
int8_t price_class = int8_t((mem.u8(list + 0x54) - 0x46) / 0x14);
|
||||
price_class = std::clamp<int8_t>(price_class, 0, 2);
|
||||
const int8_t classes = int8_t(b(0x207) + b(0x205) + b(0x206));
|
||||
int highest = 2;
|
||||
while (highest >= 0 && b(0x205 + size_t(highest)) == 0) highest--;
|
||||
if (classes == 0 || price_class <= highest)
|
||||
if (search_profile_matches_listing(g, manager, list, player))
|
||||
post_composed(g, manager, message_text(g, ::bmh::layout::Month_SearchProfileNews_TextPointer) + g.player_name(player) + message_text(g, ::bmh::layout::Month_SearchProfileNews_TextPointer2));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user