TeamRef carries the world's nation and crest asset key, squad rows the player's photo key. The manager's employments come from the almanac (clubs and national team side by side), the desk's allowed commands follow the desk kind. modern_world_info reports the asset coverage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
3.1 KiB
C++
62 lines
3.1 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
|
// modern_world_info <world.obw> - opens a Modern world package and prints its leagues, clubs
|
|
// and players (docs/new_engine, M3). Exit code 0 when the package opens, 1 otherwise.
|
|
#include <cstdio>
|
|
#include <exception>
|
|
#include <map>
|
|
|
|
#include "modern/content/world_package.hpp"
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc != 2) {
|
|
std::fprintf(stderr, "usage: modern_world_info WORLD.obw\n");
|
|
return 2;
|
|
}
|
|
try {
|
|
const auto package = bmh::modern::open_world_package(argv[1]);
|
|
const auto& w = *package.world;
|
|
std::printf("world %s, revision %s, start %s, content %s\n", w.id.c_str(),
|
|
w.data_revision.empty() ? "-" : w.data_revision.c_str(), w.start_date.c_str(),
|
|
package.classic->content_id.c_str());
|
|
int league_clubs = 0;
|
|
for (const auto& l : w.leagues) {
|
|
int added = 0;
|
|
for (const auto& m : l.members)
|
|
if (const auto* c = w.club(m); c && c->legacy_index < 0) ++added;
|
|
std::printf("league %d %-28s %2zu clubs (%d added), %s, %zu dates\n", l.index, l.name.c_str(),
|
|
l.members.size(), added, l.generator.c_str(), l.dates.size());
|
|
league_clubs += int(l.members.size());
|
|
}
|
|
int legacy = 0, without_team = 0, coded = 0;
|
|
std::map<std::string, int> squads;
|
|
for (const auto& p : w.players) {
|
|
legacy += p.legacy;
|
|
if (p.team.empty()) ++without_team;
|
|
else ++squads[p.team];
|
|
coded += w.nationality.count(p.nation) && w.nationality.at(p.nation) < 32;
|
|
}
|
|
int largest = 0, smallest = 99;
|
|
for (const auto& l : w.leagues)
|
|
for (const auto& m : l.members) {
|
|
const int n = squads.count(m) ? squads.at(m) : 0;
|
|
largest = std::max(largest, n);
|
|
smallest = std::min(smallest, n);
|
|
}
|
|
std::printf("%d league clubs, %zu clubs in all; %zu players (%d original, %d without club, "
|
|
"%d with a Classic nationality code); league squads %d-%d\n",
|
|
league_clubs, w.clubs.size(), w.players.size(), legacy, without_team, coded, smallest, largest);
|
|
// asset keys and nations as the interface passes them on (TeamRef, squad rows)
|
|
int crests = 0, nations = 0, photos = 0;
|
|
for (const auto& c : w.clubs) crests += !c.crest.empty(), nations += !c.nation.empty();
|
|
for (const auto& p : w.players) photos += !p.photo.empty();
|
|
std::printf("clubs with crest %d, with nation %d; players with photo %d\n", crests, nations, photos);
|
|
if (!w.clubs.empty()) std::printf("e.g. club %s: nation %s, crest %s\n", w.clubs[0].id.c_str(), w.clubs[0].nation.c_str(), w.clubs[0].crest.c_str());
|
|
for (const auto& p : w.players)
|
|
if (!p.photo.empty()) { std::printf("e.g. player %s: photo %s\n", p.id.c_str(), p.photo.c_str()); break; }
|
|
return 0;
|
|
} catch (const std::exception& e) {
|
|
std::fprintf(stderr, "cannot open world: %s\n", e.what());
|
|
return 1;
|
|
}
|
|
}
|