gameServer2/src/server/room.rs
changeset 13416 cdf69667593b
parent 13119 1e39b8749072
child 13419 81e0ed105f5d
equal deleted inserted replaced
13415:0eedc17055a0 13416:cdf69667593b
       
     1 use server::{
       
     2     coretypes::TeamInfo,
       
     3     client::{ClientId, HWClient}
       
     4 };
       
     5 
     1 pub type RoomId = usize;
     6 pub type RoomId = usize;
     2 
     7 
     3 pub struct HWRoom {
     8 pub struct HWRoom {
     4     pub id: RoomId,
     9     pub id: RoomId,
       
    10     pub master_id: Option<ClientId>,
     5     pub name: String,
    11     pub name: String,
     6     pub password: Option<String>,
    12     pub password: Option<String>,
     7     pub protocol_number: u32,
    13     pub protocol_number: u32,
       
    14 
       
    15     pub players_number: u32,
     8     pub ready_players_number: u8,
    16     pub ready_players_number: u8,
       
    17     pub teams: Vec<TeamInfo>,
     9 }
    18 }
    10 
    19 
    11 impl HWRoom {
    20 impl HWRoom {
    12     pub fn new(id: RoomId) -> HWRoom {
    21     pub fn new(id: RoomId) -> HWRoom {
    13         HWRoom {
    22         HWRoom {
    14             id,
    23             id,
       
    24             master_id: None,
    15             name: String::new(),
    25             name: String::new(),
    16             password: None,
    26             password: None,
    17             protocol_number: 0,
    27             protocol_number: 0,
       
    28             players_number: 0,
    18             ready_players_number: 0,
    29             ready_players_number: 0,
       
    30             teams: Vec::new()
    19         }
    31         }
    20     }
    32     }
       
    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     }
    21 }
    48 }