Modern: national teams play with squads of their nationality (M9)
A Modern layout gives every national team after no_team 24 squad slots. On each national team day, after the German nomination, the strongest fit players of each nationality (quotas 3/5/7/5, the German strength measure) fill its squad and get a computer line-up; a nation without a goalkeeper or with fewer than 14 nominees keeps its drawn rating. The shared match core asks fields_players() instead of 'league club or no_team', which is the same set in Classic. National squads get no cards or injuries, their players develop after the match like Germany's, and the almanac records their line-ups. Diamond data 1.5: 24 of 61 nations play with players. Classic regression (game 1 and two-player) unchanged, Classic-data season identical, save round trip identical, ctest passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
96e88c9579
commit
0f36b507d4
17 files changed
+154
-22
No files matched your search
@@ -4,7 +4,9 @@
|
||||
#include "modern/game/national.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "game/lineup.hpp"
|
||||
#include "game/match_engine.hpp"
|
||||
@@ -21,6 +23,7 @@ constexpr size_t kBoardSlot = 0x58;
|
||||
constexpr uint32_t kDesktops = ::bmh::layout::Desktops; // desktop layouts, 0x360 per manager slot
|
||||
constexpr size_t kDesktop = 0x360;
|
||||
constexpr uint8_t kNominated[4] = {3, 5, 7, 5}; // NationalRuntimeField: keepers, defence, midfield, attack
|
||||
constexpr int kMinNationalSquad = 14; // Modern: fewer nominees keep a national team on its drawn rating
|
||||
|
||||
// the manager's team (record +0x290) as the port caches it
|
||||
void refresh_manager_teams(ModernState& g) {
|
||||
@@ -96,6 +99,54 @@ void new_board_entry(ModernState& g, int manager, int index, int slot, WatcomRan
|
||||
std::memset(e + 0x12, 0, 7);
|
||||
}
|
||||
|
||||
void nominate_national_squads(ModernState& g) {
|
||||
const WorldLayout& w = world_layout();
|
||||
if (w.national_slots == 0) return;
|
||||
// the strongest fit players of each nationality per position, the quotas and the strength of
|
||||
// the German nomination (without its bonus for clubs abroad: every nation plays abroad)
|
||||
const int nations = w.national_teams;
|
||||
struct Picks {
|
||||
int16_t best[4][7] = {}, slot[4][7] = {}; // ascending per position, as for Germany
|
||||
int found[4] = {}; // nominees per position (up to the quota)
|
||||
};
|
||||
std::vector<Picks> picks(static_cast<size_t>(nations));
|
||||
for (size_t s = 0; s < transfer_list_slot(); s++) {
|
||||
const int id = g.squad_slots.at(s) & 0xfff;
|
||||
if (id == 0xfff) continue;
|
||||
const int n = modern::nationality(g, id);
|
||||
if (n < 1 || n >= nations) continue; // 0: Germany, nominated above
|
||||
const Player& p = g.players.at(size_t(id));
|
||||
const bool fit = (p.w35c >> 27) == 0 || ((p.w364 >> 16) & 0x1f) == 0;
|
||||
if (!fit) continue;
|
||||
const int pos = int(p.w364 & 3);
|
||||
int16_t strength = int16_t(p.strength(false));
|
||||
if (pos > 1) strength = int16_t(strength + ((p.w364 >> 2) & 0x3f) + (((p.w368 >> 18) & 0x3f) >> 1));
|
||||
Picks& pick = picks[size_t(n)];
|
||||
int16_t* row = pick.best[pos];
|
||||
int16_t* at = pick.slot[pos];
|
||||
int i = 0;
|
||||
while (i < kNominated[pos] && strength > row[i]) i++;
|
||||
if (i == 0) continue;
|
||||
for (int k = 0; k < i - 1; k++) row[k] = row[k + 1], at[k] = at[k + 1];
|
||||
row[i - 1] = strength;
|
||||
at[i - 1] = int16_t(s);
|
||||
pick.found[pos] = std::min<int>(pick.found[pos] + 1, kNominated[pos]);
|
||||
}
|
||||
for (int n = 1; n < nations; n++) {
|
||||
const int team = no_team() + n;
|
||||
const SquadRange range = squad_range(team);
|
||||
for (size_t s = range.first; s < range.first + range.count; s++) g.squad_slots.at(s) = kEmptySlot;
|
||||
// A nation needs a goalkeeper and 14 players; with fewer it keeps its drawn rating.
|
||||
const int* f = picks[size_t(n)].found;
|
||||
if (f[0] == 0 || f[0] + f[1] + f[2] + f[3] < kMinNationalSquad) continue;
|
||||
size_t next = range.first;
|
||||
for (int pos = 0; pos < 4; pos++)
|
||||
for (int k = kNominated[pos] - f[pos]; k < kNominated[pos]; k++) // the found ones fill the top
|
||||
g.squad_slots.at(next++) = uint16_t(g.squad_slots.at(size_t(picks[size_t(n)].slot[pos][k])) & 0x0fff);
|
||||
auto_lineup(g, team, 100);
|
||||
}
|
||||
}
|
||||
|
||||
bool national_team_day(ModernState& g, WatcomRandom& rand, MinuteReport& report) {
|
||||
StaticMemory& mem = g.memory;
|
||||
const SquadRange national = squad_range(no_team());
|
||||
@@ -146,6 +197,7 @@ bool national_team_day(ModernState& g, WatcomRandom& rand, MinuteReport& report)
|
||||
} catch (const std::exception& ex) {
|
||||
report.fail(std::string("national team line-up: ") + ex.what());
|
||||
}
|
||||
nominate_national_squads(g); // Modern: the other nations' squads (none in a Classic layout)
|
||||
if (coach == 0) modern::swap_manager_slots(g, 4, 0);
|
||||
g.manager_options.at(0) = option;
|
||||
return coach != 0; // (with a Bundestrainer his desk follows: AdvanceTurn's local_28 = 4)
|
||||
|
||||
Reference in new issue
Block a user