vlr_scraper/model/
match_detail.rs

1use chrono::NaiveDateTime;
2use serde::Serialize;
3
4/// Full details of a single match, including all games played.
5#[derive(Debug, Clone, Serialize)]
6pub struct Match {
7    pub id: u32,
8    pub header: MatchHeader,
9    pub streams: Vec<MatchStream>,
10    pub vods: Vec<MatchStream>,
11    pub games: Vec<MatchGame>,
12    pub head_to_head: Vec<HeadToHeadMatch>,
13    pub past_matches: Vec<TeamPastMatches>,
14    pub performance: Option<MatchPerformance>,
15    pub economy: Option<MatchEconomy>,
16}
17
18/// Header metadata for a match (event info, date, teams).
19#[derive(Debug, Clone, Serialize)]
20pub struct MatchHeader {
21    pub event_icon: String,
22    pub event_title: String,
23    pub event_series_name: String,
24    pub event_id: u32,
25    pub event_slug: String,
26    pub date: NaiveDateTime,
27    pub patch: String,
28    pub format: String,
29    pub status: String,
30    pub note: String,
31    pub teams: Vec<MatchHeaderTeam>,
32}
33
34/// A team as shown in the match header.
35#[derive(Debug, Clone, Serialize)]
36pub struct MatchHeaderTeam {
37    pub id: u32,
38    pub slug: String,
39    pub href: String,
40    pub name: String,
41    pub score: Option<u8>,
42    pub icon: String,
43}
44
45/// A stream or VOD link associated with a match.
46#[derive(Debug, Clone, Serialize)]
47pub struct MatchStream {
48    pub name: String,
49    pub link: String,
50}
51
52/// Stats for a single game (map) within a match.
53#[derive(Debug, Clone, Serialize)]
54pub struct MatchGame {
55    pub map: String,
56    pub picked_by: Option<u32>,
57    pub duration: Option<String>,
58    pub teams: Vec<MatchGameTeam>,
59    pub rounds: Vec<MatchGameRound>,
60}
61
62/// Per-team stats for a single game.
63#[derive(Debug, Clone, Serialize)]
64pub struct MatchGameTeam {
65    pub name: String,
66    pub score: Option<u8>,
67    pub score_t: Option<u8>,
68    pub score_ct: Option<u8>,
69    pub is_winner: bool,
70    pub players: Vec<MatchGamePlayer>,
71}
72
73/// The outcome of a single round within a game.
74#[derive(Debug, Clone, Serialize)]
75pub struct MatchGameRound {
76    pub round: u8,
77    pub winning_team: u32,
78    pub winning_site: String,
79}
80
81/// A previous head-to-head encounter between the two teams.
82#[derive(Debug, Clone, Serialize)]
83pub struct HeadToHeadMatch {
84    pub match_id: u32,
85    pub match_slug: String,
86    pub event_name: String,
87    pub event_series: String,
88    pub event_icon: String,
89    pub team1_score: u8,
90    pub team2_score: u8,
91    pub winner_index: u8,
92    pub date: String,
93}
94
95/// A team's recent past matches.
96#[derive(Debug, Clone, Serialize)]
97pub struct TeamPastMatches {
98    pub team_id: u32,
99    pub matches: Vec<PastMatch>,
100}
101
102/// A single past match from a team's recent history.
103#[derive(Debug, Clone, Serialize)]
104pub struct PastMatch {
105    pub match_id: u32,
106    pub match_slug: String,
107    pub score_for: u8,
108    pub score_against: u8,
109    pub is_win: bool,
110    pub opponent_name: String,
111    pub opponent_logo: String,
112    pub date: String,
113}
114
115/// Overall performance data from the performance tab.
116#[derive(Debug, Clone, Serialize)]
117pub struct MatchPerformance {
118    pub kill_matrix: Vec<KillMatrixEntry>,
119    pub player_performances: Vec<PlayerPerformance>,
120}
121
122/// A single cell in the kill matrix (killer vs victim).
123#[derive(Debug, Clone, Serialize)]
124pub struct KillMatrixEntry {
125    pub killer_id: u32,
126    pub victim_id: u32,
127    pub kills: u16,
128    pub deaths: u16,
129}
130
131/// Detailed performance stats for a single player.
132#[derive(Debug, Clone, Serialize)]
133pub struct PlayerPerformance {
134    pub player_id: u32,
135    pub player_name: String,
136    pub multi_kills_2k: u8,
137    pub multi_kills_3k: u8,
138    pub multi_kills_4k: u8,
139    pub multi_kills_5k: u8,
140    pub clutch_1v1: u8,
141    pub clutch_1v2: u8,
142    pub clutch_1v3: u8,
143    pub clutch_1v4: u8,
144    pub clutch_1v5: u8,
145    pub econ_rating: u16,
146    pub plants: u8,
147    pub defuses: u8,
148}
149
150/// Economy data from the economy tab.
151#[derive(Debug, Clone, Serialize)]
152pub struct MatchEconomy {
153    pub teams: Vec<TeamEconomy>,
154}
155
156/// Economy breakdown for a single team.
157#[derive(Debug, Clone, Serialize)]
158pub struct TeamEconomy {
159    pub team_name: String,
160    pub pistol_won: u8,
161    pub eco_rounds: u8,
162    pub eco_won: u8,
163    pub semi_eco_rounds: u8,
164    pub semi_eco_won: u8,
165    pub semi_buy_rounds: u8,
166    pub semi_buy_won: u8,
167    pub full_buy_rounds: u8,
168    pub full_buy_won: u8,
169}
170
171/// A player's participation in a single game.
172#[derive(Debug, Clone, Serialize)]
173pub struct MatchGamePlayer {
174    pub nation: String,
175    pub id: u32,
176    pub name: String,
177    pub slug: String,
178    pub agent: String,
179    pub rating: Option<f32>,
180    pub acs: Option<u16>,
181    pub kills: Option<u16>,
182    pub deaths: Option<u16>,
183    pub assists: Option<u16>,
184    pub kd_diff: Option<i16>,
185    pub kast: Option<f32>,
186    pub adr: Option<f32>,
187    pub hs_pct: Option<f32>,
188    pub first_kills: Option<u16>,
189    pub first_deaths: Option<u16>,
190    pub fk_diff: Option<i16>,
191}