1#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct DailyGame {
16 #[serde(rename = "white")]
18 pub white: String,
19 #[serde(rename = "black")]
21 pub black: String,
22 #[serde(rename = "url")]
24 pub url: String,
25 #[serde(rename = "fen")]
27 pub fen: String,
28 #[serde(rename = "pgn")]
30 pub pgn: String,
31 #[serde(rename = "turn")]
32 pub turn: crate::models::Player,
33 #[serde(rename = "move_by", skip_serializing_if = "Option::is_none")]
35 #[serde(with = "chrono::serde::ts_seconds_option")]
36 pub move_by: Option<chrono::DateTime<chrono::Utc>>,
37 #[serde(rename = "draw_offer", skip_serializing_if = "Option::is_none")]
38 pub draw_offer: Option<crate::models::Player>,
39 #[serde(rename = "last_activity")]
41 #[serde(with = "chrono::serde::ts_seconds")]
42 pub last_activity: chrono::DateTime<chrono::Utc>,
43 #[serde(rename = "start_time", skip_serializing_if = "Option::is_none")]
45 #[serde(with = "chrono::serde::ts_seconds_option")]
46 pub start_time: Option<chrono::DateTime<chrono::Utc>>,
47 #[serde(rename = "time_control")]
49 pub time_control: String,
50 #[serde(rename = "time_class")]
52 pub time_class: TimeClass,
53 #[serde(rename = "rules")]
55 pub rules: Rules,
56 #[serde(rename = "tournament", skip_serializing_if = "Option::is_none")]
58 pub tournament: Option<String>,
59 #[serde(rename = "match", skip_serializing_if = "Option::is_none")]
61 pub _match: Option<String>,
62}
63
64impl DailyGame {
65 pub fn new(white: String, black: String, url: String, fen: String, pgn: String, turn: crate::models::Player, last_activity: chrono::DateTime<chrono::Utc>, time_control: String, time_class: TimeClass, rules: Rules) -> DailyGame {
66 DailyGame {
67 white,
68 black,
69 url,
70 fen,
71 pgn,
72 turn,
73 move_by: None,
74 draw_offer: None,
75 last_activity,
76 start_time: None,
77 time_control,
78 time_class,
79 rules,
80 tournament: None,
81 _match: None,
82 }
83 }
84}
85
86#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum TimeClass {
89 #[serde(rename = "daily")]
90 Daily,
91 #[serde(rename = "rapid")]
92 Rapid,
93 #[serde(rename = "blitz")]
94 Blitz,
95 #[serde(rename = "bullet")]
96 Bullet,
97}
98
99impl std::fmt::Display for TimeClass {
100 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
101 match self {
102 TimeClass::Daily => write!(f, "daily"),
103 TimeClass::Rapid => write!(f, "rapid"),
104 TimeClass::Blitz => write!(f, "blitz"),
105 TimeClass::Bullet => write!(f, "bullet"),
106
107 }
108 }
109}
110
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
113pub enum Rules {
114 #[serde(rename = "chess")]
115 Chess,
116 #[serde(rename = "chess960")]
117 Chess960,
118 #[serde(rename = "bughouse")]
119 Bughouse,
120 #[serde(rename = "kingofthehill")]
121 Kingofthehill,
122 #[serde(rename = "threecheck")]
123 Threecheck,
124 #[serde(rename = "crazyhouse")]
125 Crazyhouse,
126}
127
128impl std::fmt::Display for Rules {
129 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
130 match self {
131 Rules::Chess => write!(f, "chess"),
132 Rules::Chess960 => write!(f, "chess960"),
133 Rules::Bughouse => write!(f, "bughouse"),
134 Rules::Kingofthehill => write!(f, "kingofthehill"),
135 Rules::Threecheck => write!(f, "threecheck"),
136 Rules::Crazyhouse => write!(f, "crazyhouse"),
137
138 }
139 }
140}
141
142