Modern UI contract: press journal for business events
Business events cannot be derived from the almanac later, so a saved journal notes them once: squad changes of the human clubs at a kickoff (signed, free, sold, contract ended; clubs compared by identity across the season's new draw positions), toto settlements, season change, contract renewals and resigning. The news read merges it with the almanac events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9c436c753e
commit
651d262546
9 files changed
+318
-4
No files matched your search
@@ -71,6 +71,20 @@ std::vector<ModernState::ExclusiveSponsor> sponsors_json(const J& value) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// The press journal (content/press_journal.hpp): the entries with their facts as JSON text.
|
||||
J press_json(const std::vector<ModernState::PressEntry>& press) {
|
||||
A out;
|
||||
for (const auto& e : press)
|
||||
out.push_back(O{{"id", e.id}, {"type", e.type}, {"team", e.team}, {"date", int64_t(e.date)}, {"data", e.data}});
|
||||
return out;
|
||||
}
|
||||
std::vector<ModernState::PressEntry> press_json(const J& value) {
|
||||
std::vector<ModernState::PressEntry> out;
|
||||
for (const J& row : arr(value))
|
||||
out.push_back({str(get(row, "id")), str(get(row, "type")), str(get(row, "team")), uint32_t(num(get(row, "date"))), str(get(row, "data"))});
|
||||
return out;
|
||||
}
|
||||
|
||||
// The Toto columns 2-6 and the last settlement per manager (docs/new_engine/toto.md).
|
||||
J pools_json(const std::vector<ModernState::PoolsColumns>& pools) {
|
||||
A out;
|
||||
@@ -139,7 +153,9 @@ void save_world_career(const std::filesystem::path& path, const World& world, co
|
||||
{"career_id", state.career_id},
|
||||
{"manager_ids", strings(state.manager_ids)},
|
||||
{"manager_serial", int64_t(state.manager_serial)},
|
||||
{"traffic_scale", int64_t(state.traffic_scale)}});
|
||||
{"traffic_scale", int64_t(state.traffic_scale)},
|
||||
{"press", press_json(state.press)},
|
||||
{"press_serial", int64_t(state.press_serial)}});
|
||||
// The almanac: finished seasons unchanged, the running one encoded now.
|
||||
for (const auto& [name, bytes] : state.almanac.finished) docs[name] = bytes;
|
||||
if (state.almanac.current.season >= 0) docs["history/current.bin"] = encode_almanac_season(state.almanac.current);
|
||||
@@ -195,6 +211,10 @@ SavedWorldCareer load_world_career(const std::filesystem::path& path, const Worl
|
||||
out.state.manager_ids = strings(get(modern, "manager_ids"));
|
||||
out.state.manager_serial = uint32_t(num(get(modern, "manager_serial")));
|
||||
if (o->count("traffic_scale")) out.state.traffic_scale = uint8_t(num(get(modern, "traffic_scale")));
|
||||
if (o->count("press")) {
|
||||
out.state.press = press_json(get(modern, "press"));
|
||||
out.state.press_serial = uint32_t(num(get(modern, "press_serial")));
|
||||
}
|
||||
}
|
||||
for (const auto& [name, bytes] : docs) {
|
||||
if (!name.starts_with("history/season-")) continue;
|
||||
|
||||
Reference in new issue
Block a user