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:
MichaelandClaude Fable 5.2 committed 2026-11-17 12:58:36 +01:00
1 parent 811edfa900
commit a2b9770d81
24 files changed
+1016 -7

No files matched your search

+39
View File
@@ -948,6 +948,45 @@ int main(int argc, char** argv) {
const J curves = session.read_statistics_screen(O{{"section", 2}});
check(!club_desk || (at(curves, "series").array() && at(curves, "series").array()->size() == 6), "the six curves of the original");
}
// the annual general meeting and the interested clubs: the read, then a change of club
{
const J meeting = at(session.ui_read(O{{"kind", "assembly"}}, rev), "data");
if (truth(at(meeting, "available"))) {
const J& vote = at(meeting, "vote");
check(vote.object() && at(vote, "yes").integer() && *at(vote, "yes").integer() >= 0 && *at(vote, "yes").integer() <= 100 &&
!truth(at(meeting, "due")) && truth(at(meeting, "dismissals")),
"assembly: a vote, not due in the season, dismissals on");
const auto* offers = at(meeting, "offers").array();
check(offers && !offers->empty() && offers->size() <= 7, "assembly: one to seven interested clubs");
const std::string own = s(at(at(meeting, "club"), "teamId"));
check(cli::dump_json(at(session.ui_read(O{{"kind", "assembly"}}, rev), "data")) == cli::dump_json(meeting), "assembly: reading changes nothing");
const auto change = [&](const std::string& id, J payload) {
return session.ui_command(cmd(id, "manager.clubChange", std::move(payload)), rev);
};
const uint64_t before = rev;
check(s(at(change("request:cc1", O{{"teamId", own}}), "code")) == "confirmation_required", "club change needs the confirmation");
check(s(at(change("request:cc2", O{{"teamId", own}, {"confirmed", true}}), "code")) == "club_change_refused" && rev == before,
"a club that is not interested is refused, nothing changes");
if (offers && !offers->empty()) {
const std::string to = s(at(offers->front(), "teamId"));
const std::string cash = cli::dump_json(at(offers->front(), "cash"));
const J done = change("request:cc3", O{{"teamId", to}, {"confirmed", true}});
if (s(at(done, "messageType")) != "command_result") std::fprintf(stderr, "club change: %s\n",cli::dump_json(done).c_str());
check(s(at(done, "messageType")) == "command_result" && rev == before + 1, "club change accepted");
const J after = at(session.ui_read(O{{"kind", "assembly"}}, rev), "data");
check(s(at(at(after, "club"), "teamId")) == to, "the manager runs the new club");
const J bank = at(session.ui_read(O{{"kind", "bank"}}, rev), "data");
check(cli::dump_json(bank).find(cash) != std::string::npos, "he starts with the cash the club offered");
const J lineup = at(session.ui_read(O{{"kind", "lineup"}}, rev), "data");
check(lineup.object() != nullptr, "the new club has a line-up to read");
for (int k = 0; k < 3; ++k) {
const J next = session.ui_command(cmd("request:cc-go" + std::to_string(k), "session.advance", O{}), rev);
if (s(at(next, "messageType")) != "command_result") std::fprintf(stderr, "advance after change: %s\n",cli::dump_json(next).c_str());
check(s(at(next, "messageType")) == "command_result", "the game goes on at the new club");
}
}
}
}
// resigning: needs the confirmation; the last human manager ends the career
{
const auto resign = [&](const std::string& id, J payload) {