author | unc0rr |
Wed, 23 Jun 2021 23:41:51 +0200 | |
changeset 15804 | 747278149393 |
parent 15547 | 863059f61793 |
child 15882 | f185e7367dd3 |
permissions | -rw-r--r-- |
15804 | 1 |
use hedgewars_network_protocol::types::{RoomConfig, TeamInfo, VoteType}; |
14785
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
2 |
use serde_derive::{Deserialize, Serialize}; |
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
3 |
|
13478 | 4 |
pub type ClientId = usize; |
5 |
pub type RoomId = usize; |
|
6 |
||
15102 | 7 |
#[derive(Debug)] |
14785
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
8 |
pub struct Replay { |
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
9 |
pub config: RoomConfig, |
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
10 |
pub teams: Vec<TeamInfo>, |
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
11 |
pub message_log: Vec<String>, |
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
12 |
} |
a1077e8d26f4
implement watch message apart from replay deserializing
alfadur
parents:
14783
diff
changeset
|
13 |
|
13478 | 14 |
#[derive(Clone, Debug)] |
15 |
pub struct Voting { |
|
16 |
pub ttl: u32, |
|
17 |
pub voters: Vec<ClientId>, |
|
18 |
pub votes: Vec<(ClientId, bool)>, |
|
14457 | 19 |
pub kind: VoteType, |
13478 | 20 |
} |
21 |
||
22 |
impl Voting { |
|
23 |
pub fn new(kind: VoteType, voters: Vec<ClientId>) -> Voting { |
|
24 |
Voting { |
|
14457 | 25 |
kind, |
26 |
voters, |
|
27 |
ttl: 2, |
|
28 |
votes: Vec::new(), |
|
13478 | 29 |
} |
30 |
} |
|
14457 | 31 |
} |