// SPDX-License-Identifier: GPL-3.0-only #pragma once // Read-only queries for the game statistics menu of the Modern UI ("Spielstatistik"; // docs/new_engine/statistik.md). They evaluate the football almanac (docs/new_engine/ // almanach.md) of the running career and never change the game. // // A request is a JSON object with a `kind`; the answer is {ok: true, ...} or // {ok: false, error}: // {kind: "competitions"} leagues and cups with recorded results, per season // {kind: "winners", competition?} the winners of every competition by season // {kind: "player_stats", competition, season?, sort?, limit?} // goals, assists, cards per player in one competition, // of one season ("2026/27") or all seasons #include #include #include #include "cli/json.hpp" #include "modern/game/modern_state.hpp" namespace bmh::modern { cli::Json query_statistics(const ModernState& g, const cli::Json& request); // Current-season player categories and fair-play cards from recorded events only. cli::Json query_rankings(const ModernState& g, int manager, const cli::Json& request); // The almanac screen of the Modern UI (DataSource::read_almanac), the request kinds of its demo: // {kind: "index"} years with matches, their number, first and last date // {kind: "calendar", year} the match days of a year with counts and highlights // {kind: "day", date} all matches of a day (ISO date) // {kind: "match", id} one match ("match:-") // A match: date, season, competition, round, both sides (manager if human), result split into // regulation / extra time / penalties, referee, attendance, weather, line-ups, events. cli::Json query_almanac(const ModernState& g, const cli::Json& request); // The statistics screen of the Modern UI (DataSource::read_statistics) with the filters of its demo // (section 0-8, category, country, winner_country, absolute, curves), from the almanac: eternal // table, national tournaments (winners, scorers, history), series and records, winners by season, // the own club per five minutes. Views without a record yet answer available: false, reason // not_recorded (title chances, transfers, weekly curves, season finances). cli::Json query_statistics_screen(const ModernState& g, int manager, const cli::Json& request); // The live ticker (DataSource::read_live): the matches recorded between two day counters (the last // kickoff) in the fixture form of the interface: the matches of human managers (at most four) // with their owners, frames in minute order (kickoff, every event, half time, the end) with // score, chances, cards and players per match, the event lines, and the other matches of the // day as the conference. source: "engine-recording". cli::Json live_fixture(const ModernState& g, uint32_t after_date, uint32_t until_date, uint64_t revision); // Modern's eleven of the day per league with a human match in the kickoff (3-4-3), chosen from // the recorded facts of that league's matches; empty when a line is short of players. cli::Json team_of_the_day(const ModernState& g, uint32_t from_date, uint32_t until_date); // The last `count` recorded matches of a club (world club id), oldest first: each // {form: "S"|"U"|"N", score: "own:other", opponent, home}. A shoot-out counts for its winner. cli::Json recent_results(const ModernState& g, const std::string& club_id, size_t count); // A club's running season read from the almanac, for charts: every match (opponent, score, // attendance), goals by quarter of an hour, goal kinds, chances and their conversion, cards, // the home and away records, who scored first and what came of it, the club's scorers, the // points after each league match beside the league's average, and the final ranks of the // finished seasons. Counts only: nothing is drawn and nothing the season core reads changes. cli::Json club_analysis(const ModernState& g, const std::string& club_id); // The ticker's headline and sentence for one event (kind as AlmanacEventKind); `home`/`away` is the // score after it. Deterministic: the variant follows from the event's facts. std::pair ticker_phrase(int kind, const std::string& team, const std::string& who, const std::string& other, int detail, int minute, int home, int away, bool away_side); // The press events of a team (contract team id) with from <= date <= until (ISO dates), derived // from the almanac and so the same on every read: match.result, cup.round_result / // cup.final_result / cup.extra_time / cup.penalties, player.sent_off, player.injury, run.wins / // run.unbeaten / run.winless / run.losses (at fixed lengths), league.position / // league.champion, cup.won / indoor.won. Each {id, type, date, scope, data, variant: null}; // the id is stable ("press-event:::"), the facts are typed (score // {for, against} from the team's side, venue, trailed, minute of the deciding goal). cli::Json query_news(const ModernState& g, const std::string& team, const std::string& from, const std::string& until); // The teams a human manager (slot, contract id) led, from the almanac: Employment of the contract // [{id, managerId, teamId, role club_manager or national_coach, from, until (null while running), // endReason}] in order. Before the first recorded match: empty. cli::Json manager_employments(const ModernState& g, int manager, const std::string& manager_id); // A game of a matchday under way: runtime teams and goals so far. struct LiveGame { int home = 0, away = 0, home_goals = 0, away_goals = 0; }; // The live table of a league during matchday `round` (1-based): the table before it plus the // given games. {competitionId, name, round, rows: [{rank, previousRank, team, played, won, // drawn, lost, goalsFor, goalsAgainst, points}]}. cli::Json live_league_table(const ModernState& g, int league, int round, const std::vector& games); // All recorded matches with from_date <= date < until_date in the almanac form (the matches of a kickoff). cli::Json almanac_matches_between(const ModernState& g, uint32_t from_date, uint32_t until_date); } // namespace bmh::modern