rust/hedgewars-server/src/core/types.rs
author unc0rr
Wed, 23 Jun 2021 23:41:51 +0200
changeset 15804 747278149393
parent 15547 863059f61793
child 15882 f185e7367dd3
permissions -rw-r--r--
Extract network protocol into a separate crate

use hedgewars_network_protocol::types::{RoomConfig, TeamInfo, VoteType};
use serde_derive::{Deserialize, Serialize};

pub type ClientId = usize;
pub type RoomId = usize;

#[derive(Debug)]
pub struct Replay {
    pub config: RoomConfig,
    pub teams: Vec<TeamInfo>,
    pub message_log: Vec<String>,
}

#[derive(Clone, Debug)]
pub struct Voting {
    pub ttl: u32,
    pub voters: Vec<ClientId>,
    pub votes: Vec<(ClientId, bool)>,
    pub kind: VoteType,
}

impl Voting {
    pub fn new(kind: VoteType, voters: Vec<ClientId>) -> Voting {
        Voting {
            kind,
            voters,
            ttl: 2,
            votes: Vec::new(),
        }
    }
}