Annual general meeting and change of club
At the end of a season three groups of members vote on a human manager. Below half of the votes he has to take over one of up to seven interested clubs; the same list lets a manager leave on his own from the manager page. The meeting is shown as a needle that swings between red and green and comes to rest on the result. Engine: assembly_vote, club_offers, change_club; read "assembly", command manager.clubChange, field assembly of session.advance; saved in state/modern.json. Dismissals are always on until the options offer them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
811edfa900
commit
a2b9770d81
24 files changed
+1016
-7
No files matched your search
@@ -5,6 +5,7 @@
|
||||
#include "modern/game/career.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -579,6 +580,13 @@ bool career_add_manager(ModernState& g, const LeImage& exe, int m, const CareerM
|
||||
modern::clubs_change_places(g, int16_t(team_of(g, m)), place);
|
||||
}
|
||||
set_club_strength(g, int16_t(team_of(g, m)), choice.strength + 1, rand);
|
||||
return modern::equip_manager(g, exe, m, league, adding, rand, report);
|
||||
}
|
||||
|
||||
bool equip_manager(ModernState& g, const LeImage& exe, int m, int league, bool adding, WatcomRandom& rand, MinuteReport& report) {
|
||||
StaticMemory& mem = g.memory;
|
||||
const size_t rec = size_t(m) * kRecord;
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
|
||||
const int club = int16_t(team_of(g, m));
|
||||
if (adding && !remove_join_loans(g, club, report)) return false;
|
||||
@@ -643,6 +651,78 @@ bool career_add_manager(ModernState& g, const LeImage& exe, int m, const CareerM
|
||||
return !report.unsupported;
|
||||
}
|
||||
|
||||
// OpenBMH deviates from the original: in Modern a human manager can change to an interested club; he starts there as a manager who joins a running game, with the cash the club offers and without his funds, shares and loans.
|
||||
bool change_club(ModernState& g, const LeImage& exe, int m, int team, int32_t cash, WatcomRandom& rand, MinuteReport& report) {
|
||||
// Reject before anything changes or a number is drawn.
|
||||
if (!g.memory.has(::bmh::layout::ManagerCount) || m < 0 || m >= 4 || m >= g.memory.u8(::bmh::layout::ManagerCount) ||
|
||||
size_t(m) >= g.manager_teams.size() || g.manager_records.size() < 5 * kRecord ||
|
||||
team < 0 || team >= german_clubs() || size_t(team) >= g.club_ids.size() || size_t(team) >= g.team_morale.size() ||
|
||||
g.tactics.size() < size_t(m + 1) * 0x840 || g.stocks.size() < 12 * 0x5c) {
|
||||
report.fail("invalid club change");
|
||||
return false;
|
||||
}
|
||||
const int old_team = g.manager_teams[size_t(m)];
|
||||
if (old_team < 0 || old_team >= league_clubs() || old_team == team || human_club(g, team)) {
|
||||
report.fail("club change needs a league club and a club no human manages");
|
||||
return false;
|
||||
}
|
||||
StaticMemory& mem = g.memory;
|
||||
const size_t rec = size_t(m) * kRecord;
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
|
||||
// What belongs to the man stays in his record: name, portrait, the national coach's flag.
|
||||
std::array<uint8_t, 0x19> name{};
|
||||
std::copy_n(r.begin() + ptrdiff_t(rec + 0xa8), name.size(), name.begin());
|
||||
const uint8_t portrait = r[rec + 0x221], coach = r[rec + 0x21c];
|
||||
// His private assets stay behind with everything else: funds, shares, loans.
|
||||
for (uint32_t k = 0; k < 6; ++k)
|
||||
if (const uint32_t at = ::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(m) * 2 + k * 0x1c; mem.has(at + 1)) mem.set16(at, 0);
|
||||
for (size_t k = 0; k < 12; ++k) {
|
||||
const size_t at = k * 0x5c;
|
||||
g.stocks[at + 0x50 + size_t(m) * 2] = g.stocks[at + 0x51 + size_t(m) * 2] = 0;
|
||||
for (size_t i = 0; i < 4; ++i) g.stocks[at + 4 + size_t(m) * 4 + i] = 0;
|
||||
}
|
||||
// His loans end. What a fellow manager lent him (rows 1-4 of his five loans) the lender gets
|
||||
// back: the part of the principal that is not yet repaid.
|
||||
const uint32_t loans = ::bmh::layout::Loans + uint32_t(m) * 0x78;
|
||||
if (mem.has(loans + 0x77)) {
|
||||
for (uint32_t row = 1; row < 5; ++row) {
|
||||
const int64_t principal = int32_t(mem.u32(loans + row * 0x18)), term = int32_t(mem.u32(loans + row * 0x18 + 12)),
|
||||
elapsed = int32_t(mem.u32(loans + row * 0x18 + 16));
|
||||
const int lender = int(row) - 1;
|
||||
if (principal <= 0 || term <= 0 || lender == m || size_t(lender) >= g.manager_teams.size()) continue;
|
||||
const int64_t open = std::clamp<int64_t>(principal - principal / term * elapsed, 0, principal);
|
||||
modern::book_money(g, lender, int32_t(-open), true);
|
||||
}
|
||||
for (uint32_t i = 0; i < 0x78; ++i) mem.set8(loans + i, 0);
|
||||
}
|
||||
if (size_t(m) < g.pools.size()) g.pools[size_t(m)] = {};
|
||||
if (size_t(m) < g.exclusive_sponsors.size()) g.exclusive_sponsors[size_t(m)] = {};
|
||||
|
||||
// The club he leaves is a computer club again: its sales, bids and loans as a human club end.
|
||||
remove_join_transfers(g, old_team);
|
||||
if (!remove_join_loans(g, old_team, report)) return false;
|
||||
g.team_morale[size_t(old_team)] &= 0x7f;
|
||||
|
||||
std::fill_n(r.begin() + ptrdiff_t(rec), kRecord, uint8_t(0));
|
||||
std::fill_n(g.tactics.begin() + ptrdiff_t(size_t(m) * 0x840), 0x840, uint8_t(0));
|
||||
std::copy(name.begin(), name.end(), r.begin() + ptrdiff_t(rec + 0xa8));
|
||||
r[rec + 0x221] = portrait, r[rec + 0x21c] = coach;
|
||||
for (size_t i = 0; i < 0x12; i++) r[rec + 0x1f6 + i] = 1;
|
||||
for (size_t i = 0; i < 10; i++) r[rec + 0x8b6 + i] = 0xff;
|
||||
r[rec + 0x1f6] = 0x40;
|
||||
r[rec + 0x290] = uint8_t(team), r[rec + 0x291] = uint8_t(team >> 8);
|
||||
const int league = team_league(team);
|
||||
r[rec + 0x210] = uint8_t(league);
|
||||
g.manager_teams[size_t(m)] = int16_t(team);
|
||||
|
||||
remove_join_transfers(g, team);
|
||||
if (!modern::equip_manager(g, exe, m, league, true, rand, report)) return false;
|
||||
put32(r, rec + 0x314, uint32_t(cash));
|
||||
put32(r, rec + 0x324, uint32_t(cash));
|
||||
return !report.unsupported;
|
||||
}
|
||||
|
||||
void career_managers_end(ModernState& g, bool adding) {
|
||||
g.memory.add_block(::bmh::layout::CareerSession_FormatError_RuntimeField6, 1);
|
||||
g.memory.set8(::bmh::layout::CareerSession_FormatError_RuntimeField6, 0);
|
||||
|
||||
Reference in new issue
Block a user