Modern press journal: monthly results

At the first kickoff of a new month each club manager's cash change over
the month just ended becomes finance.profit or finance.loss. The month
and the cash at its start are saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-27 18:46:54 +01:00
1 parent d6d31f939d
commit 706577d002
5 files changed
+43 -1

No files matched your search

+31
View File
@@ -138,6 +138,37 @@ void journal_advance(ModernState& g, const ModernState& before) {
note_press(g, "transfer.sold", id, O{{"team", me}, {"player", press_player(g, p)}, {"toClub", team_entity(next->second)}, {"fee", nullptr}});
}
}
// the month's result of each club manager: the change of his cash over the month just ended
// (everything booked: income, wages, transfers, loans), noted when the kickoff enters a new month
{
const AlmanacDate today = almanac_date(g.date, g.display_start_year);
const uint32_t month = uint32_t(today.year * 12 + today.month - 1);
const auto cash = [&](size_t m) -> int64_t {
// while coaching the national team the club's record waits in slot 4
size_t slot = m;
if (m == 0 && g.manager_teams.size() > 0 && g.manager_teams[0] == no_team() &&
g.memory.has(::bmh::layout::CoachActive) && g.memory.u8(::bmh::layout::CoachActive) != 0) slot = 4;
const size_t at = slot * 0xb0c + 0x314;
if (at + 3 >= g.manager_records.size()) return 0;
return int32_t(uint32_t(g.manager_records[at]) | uint32_t(g.manager_records[at + 1]) << 8 |
uint32_t(g.manager_records[at + 2]) << 16 | uint32_t(g.manager_records[at + 3]) << 24);
};
if (g.press_month != 0 && month != g.press_month)
for (size_t m = 0; m < g.manager_teams.size() && m < g.press_month_cash.size(); ++m) {
const int team = club_of_manager(g, m);
if (team < 0) continue;
const int64_t change = cash(m) - g.press_month_cash[m];
char label[16];
std::snprintf(label, sizeof label, "%04u-%02u", g.press_month / 12, g.press_month % 12 + 1);
note_press(g, change >= 0 ? "finance.profit" : "finance.loss", ui_team_id(g, team),
O{{"team", press_team(g, team)}, {"amount", ui_money(change >= 0 ? change : -change)}, {"month", label}});
}
if (month != g.press_month) {
g.press_month = month;
g.press_month_cash.clear();
for (size_t m = 0; m < g.manager_teams.size(); ++m) g.press_month_cash.push_back(cash(m));
}
}
// a new toto settlement of a club manager
for (size_t m = 0; m < g.pools.size() && m < before.pools.size() && m < g.manager_teams.size(); ++m) {
const auto& a = before.pools[m];
+6
View File
@@ -156,6 +156,8 @@ void save_world_career(const std::filesystem::path& path, const World& world, co
{"traffic_scale", int64_t(state.traffic_scale)},
{"press", press_json(state.press)},
{"press_serial", int64_t(state.press_serial)},
{"press_month", int64_t(state.press_month)},
{"press_month_cash", [&] { A a; for (int64_t v : state.press_month_cash) a.push_back(v); return J(std::move(a)); }()},
{"career_end_reason", state.career_end_reason},
{"career_end_date", int64_t(state.career_end_date)}});
// The almanac: finished seasons unchanged, the running one encoded now.
@@ -217,6 +219,10 @@ SavedWorldCareer load_world_career(const std::filesystem::path& path, const Worl
out.state.press = press_json(get(modern, "press"));
out.state.press_serial = uint32_t(num(get(modern, "press_serial")));
}
if (o->count("press_month")) {
out.state.press_month = uint32_t(num(get(modern, "press_month")));
for (const J& v : arr(get(modern, "press_month_cash"))) out.state.press_month_cash.push_back(int64_t(num(v)));
}
if (o->count("career_end_reason")) {
out.state.career_end_reason = str(get(modern, "career_end_reason"));
out.state.career_end_date = uint32_t(num(get(modern, "career_end_date")));
+4
View File
@@ -93,6 +93,10 @@ struct ModernState : GameState {
};
std::vector<PressEntry> press;
uint32_t press_serial = 0;
// The monthly result for the press: the month (year * 12 + month - 1, 0 = not yet started) and
// each manager's cash at its start; the change over a month is finance.profit / finance.loss.
uint32_t press_month = 0;
std::vector<int64_t> press_month_cash;
// How and when the career ended ("" while it runs; "career_completed" when the set duration ran
// out, "last_human_resigned" when the only or last human manager gave up): the interface's
// terminationReason and the end of the employments.