Read the referee pool from the world (M5, data format F9)
Referees are staff rows with role referee. Imported ones keep their original property byte; added ones (attributes strictness and the new perception, 0-3 each) follow the 49 originals in table order, up to 255. The matchday draw uses the pool size; a second match per day remains the fallback when the pool runs out. The season sim gains MODERN_EXTRA_REFEREES=N for testing before data revision 1.4 exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28b59d9890
commit
57d75ab2f5
8 files changed
+100
-12
No files matched your search
@@ -20,7 +20,7 @@ Status: *geplant* (noch nicht in der Engine), *umgesetzt* (Engine liest/prüft e
|
||||
| F6 | Kader | bis 24 Plätze je Verein, Mindestgröße | M3 | Engine: 24 Plätze je Ligaverein; mehr als 24 Spieler werden abgelehnt |
|
||||
| F7 | Finanzen | Finanzangaben für Vereine ohne Classic-Startregel | M5 | geplant |
|
||||
| F8 | Spielstand | `save_profile: modern-career-v1` | M6 | Engine erledigt: Spielstand nennt seine Welt (ID, Revision), enthält nur die Karriere |
|
||||
| F9 | Schiedsrichter | eigener Schiedsrichter-Pool der Welt, mehr als 49 | M5 | geplant (Engine nutzt bis dahin 49 und lässt Doppeleinsätze zu) |
|
||||
| F9 | Schiedsrichter | eigener Schiedsrichter-Pool der Welt, mehr als 49 | M5 | Engine erledigt (Pool aus `staff`, neu: `perception`); Daten folgen mit 1.4 |
|
||||
|
||||
## F1 · Manifest
|
||||
|
||||
@@ -113,10 +113,19 @@ Die bestehende Regel `rule:training-camps` (Typ `training_camps`) bleibt und wir
|
||||
## F9 · Schiedsrichter
|
||||
|
||||
- Heute kommen die 49 Schiedsrichter (plus Platzhalter 0) aus der Original-Datenbank: Namen im Namenspool, je ein Eigenschaftsbyte (`RefereeProperties`). Pro Spieltag erhält jedes Spiel einen noch freien Schiedsrichter. Mit den vergrößerten internationalen Ligen gibt es Tage mit bis zu 84 Ligaspielen; die Engine lässt deshalb vorübergehend Doppeleinsätze zu.
|
||||
- Geplant für Datenrevision 1.4: Die Welt führt Schiedsrichter als `staff`-Zeilen mit `role: referee`, Name (Vor- und Nachname), Nation und `x-legacy.referee_index` für die Originale. Neu ist ein Eigenschaftswert `strictness` (0–255, Bedeutung wie das Original-Eigenschaftsbyte).
|
||||
- Die Welt führt Schiedsrichter schon heute als `staff`-Zeilen mit `role: referee` (Revision 1.3: die 50 Originale mit `x-legacy.referee_index` 0–49 und `x-legacy.property`, dem Original-Eigenschaftsbyte).
|
||||
- Das Eigenschaftsbyte hat zwei Werte, die die Spiele beeinflussen:
|
||||
- `perception` (Bits 0–1, 0–3): Abseits-Entscheidungen und übersehene Fouls;
|
||||
- `strictness` (Bits 3–4, 0–3): Karten.
|
||||
- **Neue Schiedsrichter (ab Revision 1.4):** `staff`-Zeilen ohne `x-legacy`, Pflichtfelder sind `id`, `name` und `role: referee`. Dazu `attributes.strictness` und `attributes.perception` (je 0–3, fehlend = 1); eine Nation ist optional. Sie folgen in Tabellenreihenfolge auf die Originale (Index 50, 51, …), höchstens 255 insgesamt. Die Originale behalten ihr Eigenschaftsbyte aus `x-legacy.property`.
|
||||
- Empfehlung: mindestens 100 Schiedsrichter, damit auch Tage mit Pokalspielen ohne Doppeleinsatz auskommen.
|
||||
- **Engine (mit M5):** Poolgröße aus der Welt statt fest 49; Eigenschaften und Namen aus den `staff`-Zeilen; Doppeleinsatz nur noch als Rückfall, wenn der Pool trotzdem erschöpft ist.
|
||||
- **Editor:** Schiedsrichterliste anzeigen und bearbeiten (Name, Nation, Strenge), neue Schiedsrichter anlegen; Prüfung auf eindeutige IDs und Strenge im Bereich.
|
||||
- **Engine: erledigt.**
|
||||
- Die Poolgröße kommt aus der Welt.
|
||||
- Namen gehen in den Namenspool (Einzelbyte-Kodierung wie bei den Vereinen), das Eigenschaftsbyte ist `strictness << 3 | perception`.
|
||||
- Ein Doppeleinsatz ist nur noch der Rückfall, wenn der Pool erschöpft ist.
|
||||
- Ein Spielstand passt nur zu einer Welt mit gleich vielen Schiedsrichtern.
|
||||
- Test ohne neuen Datensatz: `MODERN_EXTRA_REFEREES=N modern_season_sim …`.
|
||||
- **Editor:** Schiedsrichterliste anzeigen und bearbeiten (Name, Nation, Strenge, Wahrnehmung), neue Schiedsrichter anlegen; Prüfung auf eindeutige IDs, Werte 0–3 und höchstens 255 Schiedsrichter.
|
||||
|
||||
## Modern-Prüfung (Engine und Editor)
|
||||
|
||||
|
||||
@@ -597,7 +597,10 @@ ModernSession::ModernSession(const std::filesystem::path& data, uint32_t watcom_
|
||||
g_ = modern::startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
|
||||
// A Modern world: give the Classic start the dimensions and data of the world (M3).
|
||||
if (std::getenv("MODERN_DEBUG")) std::fprintf(stderr, "session: classic start built\n");
|
||||
if (const World* world = current_world()) world_report_ = expand_to_world(g_, *world);
|
||||
if (const World* world = current_world()) {
|
||||
world_report_ = expand_to_world(g_, *world);
|
||||
install_world_referees(db_.raw_referee_properties, *world);
|
||||
}
|
||||
if (std::getenv("MODERN_DEBUG")) std::fprintf(stderr, "session: world expanded\n");
|
||||
if (const auto resource = content::find(data)) {
|
||||
g_.display_start_year = resource->content->start_year;
|
||||
@@ -648,6 +651,9 @@ ModernSession::ModernSession(const std::filesystem::path &data, uint32_t watcom_
|
||||
// A Modern career: the save names its world; the dimensions come from the world.
|
||||
auto saved = load_world_career(save_path, *world);
|
||||
install_world_dimensions(*world);
|
||||
install_world_referees(db_.raw_referee_properties, *world);
|
||||
if (saved.state.master_database_metadata.size() != db_.raw_referee_properties.size() * 2)
|
||||
throw FormatError("the save and its world disagree on the referees");
|
||||
g_ = std::move(saved.state);
|
||||
rand_ = saved.random;
|
||||
game_ = saved.game;
|
||||
|
||||
@@ -184,6 +184,27 @@ World read_world(const obw::Documents& documents) {
|
||||
}
|
||||
w.players.push_back(std::move(pl));
|
||||
}
|
||||
// Referees (data format F9): staff rows with role referee. Imported ones keep their
|
||||
// Classic index and property byte; added ones follow the Classic ones in table order.
|
||||
if (documents.contains("world/staff.json"))
|
||||
for (const J& s : items(documents, "staff")) {
|
||||
if (text(find(s, "role")) != "referee") continue;
|
||||
WorldReferee r;
|
||||
r.id = str(get(s, "id"));
|
||||
r.name = text(find(s, "name"));
|
||||
if (const J* a = find(s, "attributes")) {
|
||||
r.strictness = integer(find(*a, "strictness"), 1);
|
||||
r.perception = integer(find(*a, "perception"), 1);
|
||||
}
|
||||
if (r.strictness < 0 || r.strictness > 3 || r.perception < 0 || r.perception > 3)
|
||||
fail("referee strictness or perception outside 0-3: " + r.id);
|
||||
if (const J* legacy = find(s, "x-legacy")) {
|
||||
r.legacy_index = integer(find(*legacy, "referee_index"), -1);
|
||||
r.property = integer(find(*legacy, "property"), -1);
|
||||
if (r.property > 0x7f) fail("referee property outside 0-127: " + r.id);
|
||||
}
|
||||
w.referees.push_back(std::move(r));
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,19 @@ struct WorldPlayer {
|
||||
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_;
|
||||
@@ -61,6 +74,7 @@ struct World {
|
||||
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
|
||||
// rule:training-camps with maps and camp details (data format F4); empty = built-in catalogue.
|
||||
|
||||
@@ -411,9 +411,25 @@ ExpandReport expand_to_world(ModernState& g, const World& world) {
|
||||
g.player_last[i] = p->last;
|
||||
g.player_nation[i] = p->nation;
|
||||
}
|
||||
// Referees the data set added (data format F9): their names go to the referee pool and
|
||||
// their name offsets behind the Classic ones in MasterDatabaseMetadata (u16 per referee).
|
||||
// install_world_referees adds the matching property bytes to the database.
|
||||
for (const WorldReferee& r : world.referees) {
|
||||
if (r.legacy_index >= 0) continue;
|
||||
const uint16_t at = append_name(g.referee_names, legacy_encoding(r.name));
|
||||
g.master_database_metadata.push_back(uint8_t(at));
|
||||
g.master_database_metadata.push_back(uint8_t(at >> 8));
|
||||
++report.added_referees;
|
||||
}
|
||||
if (g.master_database_metadata.size() / 2 > 0xff) fail("more than 255 referees");
|
||||
return report;
|
||||
}
|
||||
|
||||
void install_world_referees(std::vector<uint8_t>& properties, const World& world) {
|
||||
for (const WorldReferee& r : world.referees)
|
||||
if (r.legacy_index < 0) properties.push_back(r.property_byte());
|
||||
}
|
||||
|
||||
} // namespace bmh::modern
|
||||
|
||||
namespace bmh::modern {
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace bmh::modern {
|
||||
struct ExpandReport {
|
||||
int league_clubs = 0, added_clubs = 0, added_players = 0, free_agents = 0;
|
||||
int fallback_nationalities = 0; // players whose nation has no Classic code
|
||||
int added_referees = 0; // referees behind the 49 Classic ones (data format F9)
|
||||
std::vector<std::string> notes; // moved league dates and similar remarks
|
||||
};
|
||||
|
||||
@@ -37,6 +38,11 @@ void install_world_dimensions(const World& world);
|
||||
// (docs/new_engine/trainingslager.md). Classic data keeps the eight original resorts.
|
||||
void install_training_camps(ModernState& g, const World& world);
|
||||
|
||||
// Adds the property bytes of the referees the world added to the referee properties of the
|
||||
// Classic database (indexed by referee; the turn driver draws from them). Needed for a new
|
||||
// career after expand_to_world and for a loaded one; the names live in the game state.
|
||||
void install_world_referees(std::vector<uint8_t>& properties, const World& world);
|
||||
|
||||
// The UTF-8 text of a name in the single-byte encoding of the engine texts (ISO 646-DE;
|
||||
// letters outside it lose their accents, other characters become '?').
|
||||
std::string legacy_encoding(const std::string& utf8);
|
||||
|
||||
@@ -178,14 +178,16 @@ void match_weather(MatchGroup& grp, int m, const MatchdayContext& ctx, GameRando
|
||||
// Range(1): a referee not yet chosen today
|
||||
std::vector<uint8_t>& refs = *ctx.referees;
|
||||
// OpenBMH deviates from the original: in Modern worlds a referee may take a second match on a day with more matches than referees.
|
||||
// Modern: a day can have more matches than the 49 referees (larger international
|
||||
// leagues on the dates of the German leagues). Once every referee has a match, one
|
||||
// may referee a second match that day (DIFFERENCES.md); Classic draws until a free one.
|
||||
// Modern: a day can have more matches than referees (larger international leagues on
|
||||
// the dates of the German leagues). Once every referee has a match, one may referee a
|
||||
// second match that day (DIFFERENCES.md); Classic draws until a free one.
|
||||
// The pool is the world's (data format F9): referees 1..size-1, 49 with Classic data.
|
||||
const int last = int(refs.size()) - 1;
|
||||
bool free_referee = false;
|
||||
for (int k = 1; k <= 0x31 && !free_referee; ++k) free_referee = !(refs.at(size_t(k)) & 0x80);
|
||||
for (int k = 1; k <= last && !free_referee; ++k) free_referee = !(refs.at(size_t(k)) & 0x80);
|
||||
int r;
|
||||
do {
|
||||
r = game.range(1, 0x31);
|
||||
r = game.range(1, last);
|
||||
} while (free_referee && (refs.at(size_t(r)) & 0x80));
|
||||
refs.at(size_t(r)) |= 0x80;
|
||||
grp.desc.at(0x10 + size_t(m)) = uint8_t(r);
|
||||
|
||||
@@ -175,6 +175,20 @@ int main(int argc, char** argv) {
|
||||
if (std::string(argv[1]).size() > 4 && std::string(argv[1]).substr(std::string(argv[1]).size() - 4) == ".obw") {
|
||||
auto package = modern::open_world_package(argv[1]);
|
||||
mount = std::make_unique<content::Mount>(argv[1], package.classic);
|
||||
// MODERN_EXTRA_REFEREES=N: N synthetic referees behind the world's own (data format F9),
|
||||
// until a data set brings its own larger pool.
|
||||
if (const char* extra = std::getenv("MODERN_EXTRA_REFEREES")) {
|
||||
auto world = std::make_shared<modern::World>(*package.world);
|
||||
for (int i = 0; i < std::atoi(extra); ++i) {
|
||||
modern::WorldReferee r;
|
||||
r.id = "staff:sim-" + std::to_string(i);
|
||||
r.name = "Schiri " + std::to_string(i);
|
||||
r.strictness = i % 4;
|
||||
r.perception = (i / 4) % 4;
|
||||
world->referees.push_back(std::move(r));
|
||||
}
|
||||
package.world = world;
|
||||
}
|
||||
modern::set_current_world(package.world);
|
||||
}
|
||||
modern::app::ModernSession session(argv[1], argc > 4 ? uint32_t(std::stoul(argv[4])) : 1u);
|
||||
@@ -186,8 +200,8 @@ int main(int argc, char** argv) {
|
||||
std::string error;
|
||||
if (modern::current_world()) {
|
||||
const auto& r = session.world_report();
|
||||
std::printf("modern world: %d league clubs (%d added), %d added players, %d free agents, %d fallback nationalities\n",
|
||||
r.league_clubs, r.added_clubs, r.added_players, r.free_agents, r.fallback_nationalities);
|
||||
std::printf("modern world: %d league clubs (%d added), %d added players, %d free agents, %d fallback nationalities, %d added referees\n",
|
||||
r.league_clubs, r.added_clubs, r.added_players, r.free_agents, r.fallback_nationalities, r.added_referees);
|
||||
for (const auto& note : r.notes) std::printf(" league date moved: %s\n", note.c_str());
|
||||
}
|
||||
if (!session.confirm_manager(options, choice, error)) throw std::runtime_error("manager: " + error);
|
||||
|
||||
Reference in new issue
Block a user