A club analysis in the statistics: the season as charts; larger trophies
The engine counts the manager's club's running season from the almanac (read "analysis"): matches, the points course beside the league's pace, records by venue, what the first goal decided, goals by quarter of an hour, scorers and goal kinds. The statistics open with it; the archive tables keep their place with larger type and trophies. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
9006b7a05d
commit
8f607a9d89
13 files changed
+444
-9
No files matched your search
@@ -225,7 +225,52 @@ void check_shootout_projection() {
|
||||
"overlapping stoppage/extra-time goal minute has unknown partial score");
|
||||
}
|
||||
|
||||
// The club analysis counts what the almanac recorded: records by venue, goals by quarter of
|
||||
// an hour, chances, the first goal and the points course of the league matches.
|
||||
void check_club_analysis() {
|
||||
AlmanacSeason s;
|
||||
s.season = 0; s.start_year = 2026; s.display_start_year = 2026;
|
||||
s.leagues.push_back({0, "league:test", "Testliga"});
|
||||
const uint16_t own = s.club({"club:own", "Eigene Elf"}), other = s.club({"club:other", "Gegner"});
|
||||
const uint16_t striker = s.player({"player:striker", "Anna", "Sturm", "nation:de"});
|
||||
const uint16_t helper = s.player({"player:helper", "Ben", "Pass", "nation:de"});
|
||||
const auto event = [](AlmanacEventKind kind, int minute, int side, uint16_t player, uint16_t assistant, int detail) {
|
||||
AlmanacEvent e; e.kind = kind; e.minute = uint8_t(minute); e.side = uint8_t(side); e.player = player; e.other = assistant; e.detail = uint8_t(detail);
|
||||
return e;
|
||||
};
|
||||
AlmanacMatch home; // 2:1 at home: own goals in minutes 10 and 80, the guests score first in minute 5
|
||||
home.type = 0; home.league = 0; home.round = 1; home.home = own; home.away = other; home.home_goals = 2; home.away_goals = 1; home.attendance = 30000;
|
||||
home.events = {event(AlmanacEventKind::Goal, 5, 1, kAlmanacNone, kAlmanacNone, 0), event(AlmanacEventKind::Goal, 10, 0, striker, helper, 0),
|
||||
event(AlmanacEventKind::Miss, 30, 0, striker, kAlmanacNone, 0), event(AlmanacEventKind::YellowCard, 40, 0, helper, kAlmanacNone, 0),
|
||||
event(AlmanacEventKind::Goal, 80, 0, striker, kAlmanacNone, 3)};
|
||||
AlmanacMatch away; // 0:0 away
|
||||
away.type = 0; away.league = 0; away.round = 2; away.home = other; away.away = own; away.attendance = 12000;
|
||||
away.events = {event(AlmanacEventKind::Miss, 50, 1, helper, kAlmanacNone, 0)};
|
||||
s.matches = {home, away};
|
||||
ModernState g; g.season = 0; g.display_start_year = 2026; g.almanac.current = s;
|
||||
const auto a = club_analysis(g, "club:own");
|
||||
const auto whole = [&](const cli::Json& j, const char* key) { return int(*field(j, key).integer()); };
|
||||
check(std::get<bool>(field(a, "available").value) && field(a, "matches").array()->size() == 2, "analysis lists both matches");
|
||||
check(whole(field(a, "home"), "won") == 1 && whole(field(a, "home"), "points") == 3 && whole(field(a, "away"), "drawn") == 1,
|
||||
"analysis keeps the records by venue");
|
||||
check(whole(field(a, "goals"), "for") == 2 && whole(field(a, "goals"), "against") == 1 && whole(field(a, "chances"), "for") == 4 &&
|
||||
whole(field(a, "chances"), "against") == 1, "analysis counts goals and chances of both sides");
|
||||
const auto& buckets = *field(a, "buckets").array();
|
||||
check(buckets.size() == 6 && whole(buckets[0], "for") == 1 && whole(buckets[0], "against") == 1 && whole(buckets[5], "for") == 1,
|
||||
"analysis sorts goals into quarters of an hour");
|
||||
check(whole(field(a, "firstAgainst"), "played") == 1 && whole(field(a, "firstAgainst"), "won") == 1 && whole(field(a, "firstFor"), "played") == 0,
|
||||
"analysis notes who scored first and what came of it");
|
||||
const auto& points = *field(a, "points").array();
|
||||
check(points.size() == 2 && *points[0].integer() == 3 && *points[1].integer() == 4, "analysis follows the points course");
|
||||
const auto& scorers = *field(a, "scorers").array();
|
||||
check(scorers.size() == 2 && whole(scorers[0], "goals") == 2 && whole(scorers[1], "assists") == 1 && whole(field(a, "cards"), "yellow") == 1,
|
||||
"analysis ranks scorers and counts cards");
|
||||
check(whole((*field(a, "kinds").array())[3], "for") == 1, "analysis keeps the goal kinds");
|
||||
check(!std::get<bool>(field(club_analysis(g, "club:absent"), "available").value), "a club without a match has no analysis");
|
||||
}
|
||||
|
||||
int main() {
|
||||
check_club_analysis();
|
||||
check_shootout_recording();
|
||||
check_shootout_projection();
|
||||
const AlmanacSeason s = sample();
|
||||
|
||||
Reference in new issue
Block a user