74 lines
4.7 KiB
C++
74 lines
4.7 KiB
C++
// 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 <vector>
|
|
|
|
#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:<season start year>-<index>")
|
|
// 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);
|
|
|
|
// 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:<type>:<occurrence>:<team>"), 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<LiveGame>& 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
|