The interested clubs show the squad's age and the last league matches
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
101273f777
commit
112b8492d9
4 files changed
+65
-2
No files matched your search
@@ -8953,6 +8953,33 @@ cli::Json assembly_data(const modern::ModernState& g, const LeImage& exe, int ma
|
||||
}
|
||||
return out;
|
||||
};
|
||||
// the mean age of the squad in tenths of a year
|
||||
const auto age = [&](int t) {
|
||||
const SquadRange range = squad_range(t);
|
||||
int sum = 0, count = 0;
|
||||
for (size_t i = 0; i < range.count && range.first + i < g.squad_slots.size(); ++i) {
|
||||
const size_t player = g.squad_slots[range.first + i] & 0x0fff;
|
||||
if (player == 0x0fff || player >= g.players.size()) continue;
|
||||
sum += g.players[player].age(), ++count;
|
||||
}
|
||||
return count ? cli::Json(sum * 10 / count) : cli::Json(nullptr);
|
||||
};
|
||||
// the club's last six league matches of the season, the latest last
|
||||
const auto results = [&](int t) {
|
||||
A out;
|
||||
const std::string id = size_t(t) < g.world_club_id.size() && !g.world_club_id[size_t(t)].empty() ? g.world_club_id[size_t(t)] : "team:" + std::to_string(t);
|
||||
const auto& season = g.almanac.current;
|
||||
for (auto m = season.matches.rbegin(); m != season.matches.rend() && out.size() < 6; ++m) {
|
||||
if (m->type != 0 || m->home >= season.clubs.size() || m->away >= season.clubs.size()) continue;
|
||||
const bool home = season.clubs[m->home].id == id;
|
||||
if (!home && season.clubs[m->away].id != id) continue;
|
||||
const int scored = home ? m->home_goals : m->away_goals, conceded = home ? m->away_goals : m->home_goals;
|
||||
out.insert(out.begin(), O{{"home", home}, {"goalsFor", scored}, {"goalsAgainst", conceded},
|
||||
{"opponent", season.clubs[home ? m->away : m->home].name},
|
||||
{"outcome", scored > conceded ? "win" : scored < conceded ? "loss" : "draw"}});
|
||||
}
|
||||
return out;
|
||||
};
|
||||
// the ground a manager gets with a club of this league (build_stadium): eight stands of equal size
|
||||
const auto capacity = [&](int league) {
|
||||
const uint32_t at = ::bmh::layout::Career_BuildStadium_RuntimeField4 + uint32_t(league > 2 ? league - 1 : league);
|
||||
@@ -8964,7 +8991,7 @@ cli::Json assembly_data(const modern::ModernState& g, const LeImage& exe, int ma
|
||||
{"name", size_t(t) < g.world_club_name.size() ? g.world_club_name[size_t(t)] : std::string()},
|
||||
{"league", league >= 0 && size_t(league) < g.world_league_name.size() ? g.world_league_name[size_t(league)] : std::string()},
|
||||
{"leagueIndex", league}, {"leagueSize", league_table_teams(league)}, {"strength", team_average(g, t, eleven).value},
|
||||
{"lines", lines(t)}, {"positions", places(t)}, {"squad", modern::squad_count(g, t, 2)}, {"stadiumCapacity", capacity(league)},
|
||||
{"lines", lines(t)}, {"positions", places(t)}, {"squad", modern::squad_count(g, t, 2)}, {"averageAge", age(t)}, {"results", results(t)}, {"stadiumCapacity", capacity(league)},
|
||||
{"position", modern::table_position(g, t) < 0 ? cli::Json(nullptr) : cli::Json(modern::table_position(g, t) + 1)}};
|
||||
};
|
||||
A offers;
|
||||
|
||||
Reference in new issue
Block a user