1pub mod bookmark;
2pub mod chat;
3pub mod export;
4pub mod import;
5pub mod ongoing;
6pub mod stream;
7
8use crate::model::{Clock, LightUser, PlayerColor, Speed, VariantKey};
9use serde::{Deserialize, Serialize};
10
11#[serde_with::skip_serializing_none]
12#[derive(Clone, Debug, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct GameStream {
15 pub id: String,
16 pub rated: bool,
17 pub variant: VariantKey,
18 pub speed: Speed,
19 pub perf: String,
20 pub created_at: u64,
21 pub status: u32,
22 pub status_name: GameStatus,
23 pub players: Players,
24 pub clock: Option<Clock>,
25}
26
27#[serde_with::skip_serializing_none]
28#[derive(Clone, Debug, Serialize, Deserialize)]
29#[serde(rename_all = "camelCase")]
30pub struct GameJson {
31 pub id: String,
32 pub rated: bool,
33 pub variant: VariantKey,
34 pub speed: Speed,
35 pub perf: String,
36 pub created_at: u64,
37 pub last_move_at: Option<u64>,
38 pub status: GameStatus,
39 pub players: Option<Players>,
40 pub initial_fen: Option<String>,
41 pub winner: Option<PlayerColor>,
42 pub opening: Option<Opening>,
43 pub moves: Option<String>,
44 pub pgn: Option<String>,
45 pub days_per_turn: Option<u64>,
46 pub analysis: Option<Vec<GameMoveAnalysis>>,
47 pub tournament: Option<String>,
48 pub swiss: Option<String>,
49 pub clock: Option<Clock>,
50 pub clocks: Option<Vec<u64>>,
51 pub division: Option<Division>,
52}
53
54#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
55#[serde(rename_all = "camelCase")]
56pub enum GameStatus {
57 Created,
58 Started,
59 Aborted,
60 Mate,
61 Resign,
62 Stalemate,
63 Timeout,
64 Draw,
65 Outoftime,
66 Cheat,
67 NoStart,
68 UnknownFinish,
69 VariantEnd,
70}
71
72#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
73pub struct GameStatusJson {
74 pub id: u32,
75 pub name: GameStatus,
76}
77
78#[serde_with::skip_serializing_none]
79#[derive(Clone, Debug, Serialize, Deserialize)]
80pub struct Players {
81 pub white: Option<GameUser>,
82 pub black: Option<GameUser>,
83}
84
85#[serde_with::skip_serializing_none]
86#[derive(Clone, Debug, Serialize, Deserialize)]
87#[serde(rename_all = "camelCase")]
88pub struct GameUser {
89 pub user: Option<LightUser>,
90 pub rating: Option<u32>,
91 pub rating_diff: Option<i32>,
92 pub name: Option<String>,
93 pub provisional: Option<bool>,
94 pub ai_level: Option<u32>,
95 pub analysis: Option<Analysis>,
96 pub team: Option<String>,
97}
98
99#[derive(Clone, Debug, Serialize, Deserialize)]
100pub struct Analysis {
101 pub inaccuracy: u32,
102 pub mistake: u32,
103 pub blunder: u32,
104 pub acpl: u32,
105}
106
107#[derive(Clone, Debug, Serialize, Deserialize)]
108pub struct Opening {
109 pub eco: String,
110 pub name: String,
111 pub ply: u32,
112}
113
114#[serde_with::skip_serializing_none]
115#[derive(Clone, Debug, Serialize, Deserialize)]
116pub struct Division {
117 pub middle: Option<u32>,
118 pub end: Option<u32>,
119}
120
121#[serde_with::skip_serializing_none]
122#[derive(Clone, Debug, Serialize, Deserialize)]
123pub struct GameMoveAnalysis {
124 pub eval: Option<i32>,
125 pub mate: Option<u32>,
126 pub best: Option<String>,
127 pub variation: Option<String>,
128 pub judgment: Option<Judgement>,
130}
131
132#[serde_with::skip_serializing_none]
133#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct Judgement {
135 pub name: JudgementName,
136 pub comment: Option<String>,
137}
138
139#[derive(Debug, Clone, Serialize, Deserialize)]
140pub enum JudgementName {
141 Inaccuracy,
143 Mistake,
144 Blunder,
145}