author | alfadur |
Tue, 09 Apr 2019 21:08:35 +0300 | |
changeset 14779 | f43ab2bd76ae |
parent 14687 | 5122c584804e |
child 14783 | b3adc030104b |
permissions | -rw-r--r-- |
13478 | 1 |
pub type ClientId = usize; |
2 |
pub type RoomId = usize; |
|
3 |
||
13795
e335daaa77a9
Add hogs per team named constant that absolutely no one asked for
alfadur
parents:
13478
diff
changeset
|
4 |
pub const MAX_HEDGEHOGS_PER_TEAM: u8 = 8; |
e335daaa77a9
Add hogs per team named constant that absolutely no one asked for
alfadur
parents:
13478
diff
changeset
|
5 |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12131
diff
changeset
|
6 |
#[derive(PartialEq, Eq, Clone, Debug)] |
12130 | 7 |
pub enum ServerVar { |
8 |
MOTDNew(String), |
|
9 |
MOTDOld(String), |
|
10 |
LatestProto(u32), |
|
11 |
} |
|
12 |
||
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12131
diff
changeset
|
13 |
#[derive(PartialEq, Eq, Clone, Debug)] |
12130 | 14 |
pub enum GameCfg { |
13422 | 15 |
FeatureSize(u32), |
16 |
MapType(String), |
|
17 |
MapGenerator(u32), |
|
18 |
MazeSize(u32), |
|
19 |
Seed(String), |
|
20 |
Template(u32), |
|
12130 | 21 |
|
13422 | 22 |
Ammo(String, Option<String>), |
13801 | 23 |
Scheme(String, Vec<String>), |
13422 | 24 |
Script(String), |
25 |
Theme(String), |
|
14457 | 26 |
DrawnMap(String), |
12130 | 27 |
} |
28 |
||
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12131
diff
changeset
|
29 |
#[derive(PartialEq, Eq, Clone, Debug)] |
12130 | 30 |
pub struct TeamInfo { |
13419 | 31 |
pub name: String, |
32 |
pub color: u8, |
|
33 |
pub grave: String, |
|
34 |
pub fort: String, |
|
35 |
pub voice_pack: String, |
|
36 |
pub flag: String, |
|
37 |
pub difficulty: u8, |
|
38 |
pub hedgehogs_number: u8, |
|
13795
e335daaa77a9
Add hogs per team named constant that absolutely no one asked for
alfadur
parents:
13478
diff
changeset
|
39 |
pub hedgehogs: [HedgehogInfo; MAX_HEDGEHOGS_PER_TEAM as usize], |
12130 | 40 |
} |
41 |
||
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12131
diff
changeset
|
42 |
#[derive(PartialEq, Eq, Clone, Debug)] |
12130 | 43 |
pub struct HedgehogInfo { |
13419 | 44 |
pub name: String, |
45 |
pub hat: String, |
|
12130 | 46 |
} |
13478 | 47 |
|
48 |
#[derive(PartialEq, Eq, Clone, Debug)] |
|
49 |
pub enum VoteType { |
|
50 |
Kick(String), |
|
51 |
Map(Option<String>), |
|
52 |
Pause, |
|
53 |
NewSeed, |
|
14457 | 54 |
HedgehogsPerTeam(u8), |
13478 | 55 |
} |
56 |
||
14687
5122c584804e
Server action refactoring part A of N
alfadur <mail@none>
parents:
14457
diff
changeset
|
57 |
pub struct Vote { |
5122c584804e
Server action refactoring part A of N
alfadur <mail@none>
parents:
14457
diff
changeset
|
58 |
pub is_pro: bool, |
5122c584804e
Server action refactoring part A of N
alfadur <mail@none>
parents:
14457
diff
changeset
|
59 |
pub is_forced: bool, |
5122c584804e
Server action refactoring part A of N
alfadur <mail@none>
parents:
14457
diff
changeset
|
60 |
} |
5122c584804e
Server action refactoring part A of N
alfadur <mail@none>
parents:
14457
diff
changeset
|
61 |
|
13478 | 62 |
#[derive(Clone, Debug)] |
63 |
pub struct Voting { |
|
64 |
pub ttl: u32, |
|
65 |
pub voters: Vec<ClientId>, |
|
66 |
pub votes: Vec<(ClientId, bool)>, |
|
14457 | 67 |
pub kind: VoteType, |
13478 | 68 |
} |
69 |
||
70 |
impl Voting { |
|
71 |
pub fn new(kind: VoteType, voters: Vec<ClientId>) -> Voting { |
|
72 |
Voting { |
|
14457 | 73 |
kind, |
74 |
voters, |
|
75 |
ttl: 2, |
|
76 |
votes: Vec::new(), |
|
13478 | 77 |
} |
78 |
} |
|
14457 | 79 |
} |