1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use connect4_lib::game::ChipDescrip;
use connect4_lib::game::{BoardState, Game, Player};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct Signin {
    pub status: String,
    pub tok: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Refresh {
    pub status: String,
    pub new_tok: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PlayMove {
    pub status: String,
    pub game_id: String,
    pub column: isize,
    pub chip_descrip: ChipDescrip,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GameData {
    pub roomcode: String,
    pub board_state: BoardState,
    pub users: Vec<String>,

    #[serde(flatten)]
    pub game: Game,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GameDataResponse {
    pub status: String,
    pub game_data: Option<GameData>,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum ClaimPayload {
    username(String),
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
    pub data: ClaimPayload, // extra data fields
    pub exp: usize,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GameStats {
    pub game_id: String,
    pub player: String,
    pub games_won: isize,
    pub games_lost: isize,
    pub games_played: isize,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GameStatsResponse {
    pub status: String,
    pub game_stats: Option<GameStats>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct JoinPlayers {
    pub players: Vec<i32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct JoinPlayersResponse {
    pub status: String,
    pub player_numbers: Vec<Option<isize>>,
}