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>
93 lines
3.7 KiB
C++
93 lines
3.7 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
|
#pragma once
|
|
// The world of a Modern data set (docs/new_engine, M3): the parts of the OBW tables the
|
|
// Modern season core needs, read once when a world is opened. Identities are the stable
|
|
// OBW ids; runtime team and player indices are assigned by the world loader.
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "import/obw.hpp"
|
|
#include "modern/game/training_camps.hpp"
|
|
|
|
namespace bmh::modern {
|
|
|
|
struct WorldLeague {
|
|
std::string id; // comp:...
|
|
std::string name;
|
|
int index = -1; // league 0-8 (x-legacy.league_index)
|
|
std::vector<std::string> members; // club ids in table order
|
|
std::string generator; // legacy:<n> or round-robin
|
|
std::vector<std::string> dates; // explicit league dates, empty = Classic calendar
|
|
};
|
|
|
|
struct WorldClub {
|
|
std::string id;
|
|
std::string name;
|
|
std::string short_name;
|
|
std::string nation;
|
|
std::string crest;
|
|
std::string competition; // league id for league clubs
|
|
int legacy_index = -1; // Classic team id, -1 for clubs added by the data set
|
|
int kit_selector = -1;
|
|
};
|
|
|
|
struct WorldPlayer {
|
|
std::string id;
|
|
std::string first, last;
|
|
std::string team; // club id, empty = no club
|
|
int squad_order = -1;
|
|
int position = 0; // 0 GK, 1 DEF, 2 MID, 3 FWD
|
|
std::string nation; // first nationality
|
|
int age = -1; // age on the start date
|
|
bool born = false; // the age comes from a birth date (not a placeholder age)
|
|
std::string photo;
|
|
// Attributes of bmh-classic@1.
|
|
int technique = 0, condition = 0, form = 0, bonus = 0;
|
|
int teamplay = 0, speed = 0, shooting = 0, passing = 0, tackling = 0, free_kick = 0, corner = 0;
|
|
// The original database words of an imported player (x-legacy).
|
|
bool legacy = false;
|
|
int legacy_index = -1;
|
|
uint32_t w35c = 0, w368 = 0, w364 = 0;
|
|
};
|
|
|
|
// A referee (staff row with role referee). The Classic property byte holds the perception
|
|
// (bits 0-1: offside calls, fouls let go) and the strictness (bits 3-4: cards).
|
|
struct WorldReferee {
|
|
std::string id, name;
|
|
int strictness = 1, perception = 1; // 0-3 each
|
|
int legacy_index = -1; // Classic referee 0-49, -1 for referees added by the data set
|
|
int property = -1; // the original property byte of an imported referee
|
|
|
|
uint8_t property_byte() const {
|
|
return property >= 0 ? uint8_t(property) : uint8_t(strictness << 3 | perception);
|
|
}
|
|
};
|
|
|
|
struct World {
|
|
std::string id, title, data_revision;
|
|
std::vector<std::string> requires_;
|
|
int start_year = 2026;
|
|
std::string start_date;
|
|
std::vector<WorldLeague> leagues; // by league index 0-8
|
|
std::vector<WorldClub> clubs;
|
|
std::vector<WorldPlayer> players;
|
|
std::vector<WorldReferee> referees; // in table order (data format F9)
|
|
std::map<std::string, int> nationality; // nation id -> Classic nationality code (0 = Germany)
|
|
std::map<std::string, size_t> club_by_id; // club id -> index in clubs
|
|
std::map<std::string, size_t> player_by_id; // player id -> index in players
|
|
// rule:training-camps with maps and camp details (data format F4); empty = built-in catalogue.
|
|
std::optional<CampCatalogue> camps;
|
|
|
|
const WorldClub* club(const std::string& id) const;
|
|
const WorldPlayer* player(const std::string& id) const;
|
|
};
|
|
|
|
// Reads the world tables. Throws FormatError for missing or malformed required fields.
|
|
World read_world(const obw::Documents& documents);
|
|
|
|
} // namespace bmh::modern
|