13421
|
1 |
use server::{
|
|
2 |
coretypes::TeamInfo,
|
|
3 |
client::{ClientId, HWClient}
|
|
4 |
};
|
|
5 |
|
13124
|
6 |
pub type RoomId = usize;
|
|
7 |
|
|
8 |
pub struct HWRoom {
|
|
9 |
pub id: RoomId,
|
13421
|
10 |
pub master_id: Option<ClientId>,
|
13124
|
11 |
pub name: String,
|
|
12 |
pub password: Option<String>,
|
|
13 |
pub protocol_number: u32,
|
13421
|
14 |
|
|
15 |
pub players_number: u32,
|
13124
|
16 |
pub ready_players_number: u8,
|
13421
|
17 |
pub teams: Vec<TeamInfo>,
|
13124
|
18 |
}
|
|
19 |
|
|
20 |
impl HWRoom {
|
|
21 |
pub fn new(id: RoomId) -> HWRoom {
|
|
22 |
HWRoom {
|
|
23 |
id,
|
13421
|
24 |
master_id: None,
|
13124
|
25 |
name: String::new(),
|
|
26 |
password: None,
|
|
27 |
protocol_number: 0,
|
13421
|
28 |
players_number: 0,
|
13124
|
29 |
ready_players_number: 0,
|
13421
|
30 |
teams: Vec::new()
|
13124
|
31 |
}
|
|
32 |
}
|
13421
|
33 |
|
|
34 |
pub fn info(&self, master: Option<&HWClient>) -> Vec<String> {
|
|
35 |
let flags = "-".to_string();
|
|
36 |
vec![
|
|
37 |
flags,
|
|
38 |
self.name.clone(),
|
|
39 |
self.players_number.to_string(),
|
|
40 |
self.teams.len().to_string(),
|
|
41 |
master.map_or("?", |c| &c.nick).to_string(),
|
|
42 |
"Default".to_string(),
|
|
43 |
"Default".to_string(),
|
|
44 |
"Default".to_string(),
|
|
45 |
"Default".to_string(),
|
|
46 |
]
|
|
47 |
}
|
13124
|
48 |
} |