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
use quake_clientinfo::Clientinfo;

#[derive(Clone, Debug, Default, PartialEq)]
pub struct Client {
    pub number: u8,
    pub name: String,
    pub team: String,
    pub color: [u8; 2],
    pub is_spectator: bool,
    pub is_bot: bool,
    pub auth_username: Option<String>,
    pub auth_cc: Option<String>,
}

impl From<&Clientinfo> for Client {
    fn from(value: &Clientinfo) -> Self {
        Client {
            number: 0,
            name: value.name.clone().unwrap_or_default(),
            team: value.team.clone().unwrap_or_default(),
            color: [
                value.topcolor.unwrap_or(0) as u8,
                value.bottomcolor.unwrap_or(0) as u8,
            ],
            is_spectator: value.spectator.is_some_and(|v| v != 0),
            is_bot: value.bot.is_some_and(|v| v != 0),
            auth_username: value.auth.clone(),
            auth_cc: value.flag.clone(),
        }
    }
}