41 |
44 |
42 #[derive(PartialEq, Eq, Clone, Debug)] |
45 #[derive(PartialEq, Eq, Clone, Debug)] |
43 pub struct HedgehogInfo { |
46 pub struct HedgehogInfo { |
44 pub name: String, |
47 pub name: String, |
45 pub hat: String, |
48 pub hat: String, |
|
49 } |
|
50 |
|
51 #[derive(Clone, Serialize, Deserialize)] |
|
52 pub struct Ammo { |
|
53 pub name: String, |
|
54 pub settings: Option<String>, |
|
55 } |
|
56 |
|
57 #[derive(Clone, Serialize, Deserialize)] |
|
58 pub struct Scheme { |
|
59 pub name: String, |
|
60 pub settings: Vec<String>, |
|
61 } |
|
62 |
|
63 #[derive(Clone, Serialize, Deserialize)] |
|
64 pub struct RoomConfig { |
|
65 pub feature_size: u32, |
|
66 pub map_type: String, |
|
67 pub map_generator: u32, |
|
68 pub maze_size: u32, |
|
69 pub seed: String, |
|
70 pub template: u32, |
|
71 |
|
72 pub ammo: Ammo, |
|
73 pub scheme: Scheme, |
|
74 pub script: String, |
|
75 pub theme: String, |
|
76 pub drawn_map: Option<String>, |
|
77 } |
|
78 |
|
79 impl RoomConfig { |
|
80 pub fn new() -> RoomConfig { |
|
81 RoomConfig { |
|
82 feature_size: 12, |
|
83 map_type: "+rnd+".to_string(), |
|
84 map_generator: 0, |
|
85 maze_size: 0, |
|
86 seed: "seed".to_string(), |
|
87 template: 0, |
|
88 |
|
89 ammo: Ammo { |
|
90 name: "Default".to_string(), |
|
91 settings: None, |
|
92 }, |
|
93 scheme: Scheme { |
|
94 name: "Default".to_string(), |
|
95 settings: Vec::new(), |
|
96 }, |
|
97 script: "Normal".to_string(), |
|
98 theme: "\u{1f994}".to_string(), |
|
99 drawn_map: None, |
|
100 } |
|
101 } |
|
102 |
|
103 pub fn set_config(&mut self, cfg: GameCfg) { |
|
104 match cfg { |
|
105 GameCfg::FeatureSize(s) => self.feature_size = s, |
|
106 GameCfg::MapType(t) => self.map_type = t, |
|
107 GameCfg::MapGenerator(g) => self.map_generator = g, |
|
108 GameCfg::MazeSize(s) => self.maze_size = s, |
|
109 GameCfg::Seed(s) => self.seed = s, |
|
110 GameCfg::Template(t) => self.template = t, |
|
111 |
|
112 GameCfg::Ammo(n, s) => { |
|
113 self.ammo = Ammo { |
|
114 name: n, |
|
115 settings: s, |
|
116 } |
|
117 } |
|
118 GameCfg::Scheme(n, s) => { |
|
119 self.scheme = Scheme { |
|
120 name: n, |
|
121 settings: s, |
|
122 } |
|
123 } |
|
124 GameCfg::Script(s) => self.script = s, |
|
125 GameCfg::Theme(t) => self.theme = t, |
|
126 GameCfg::DrawnMap(m) => self.drawn_map = Some(m), |
|
127 }; |
|
128 } |
|
129 |
|
130 pub fn to_map_config(&self) -> Vec<String> { |
|
131 vec![ |
|
132 self.feature_size.to_string(), |
|
133 self.map_type.to_string(), |
|
134 self.map_generator.to_string(), |
|
135 self.maze_size.to_string(), |
|
136 self.seed.to_string(), |
|
137 self.template.to_string(), |
|
138 ] |
|
139 } |
|
140 |
|
141 pub fn to_game_config(&self) -> Vec<GameCfg> { |
|
142 use crate::server::coretypes::GameCfg::*; |
|
143 let mut v = vec![ |
|
144 Ammo(self.ammo.name.to_string(), self.ammo.settings.clone()), |
|
145 Scheme(self.scheme.name.to_string(), self.scheme.settings.clone()), |
|
146 Script(self.script.to_string()), |
|
147 Theme(self.theme.to_string()), |
|
148 ]; |
|
149 if let Some(ref m) = self.drawn_map { |
|
150 v.push(DrawnMap(m.to_string())) |
|
151 } |
|
152 v |
|
153 } |
|
154 } |
|
155 |
|
156 pub struct Replay { |
|
157 pub config: RoomConfig, |
|
158 pub teams: Vec<TeamInfo>, |
|
159 pub message_log: Vec<String>, |
46 } |
160 } |
47 |
161 |
48 #[derive(PartialEq, Eq, Clone, Debug)] |
162 #[derive(PartialEq, Eq, Clone, Debug)] |
49 pub enum VoteType { |
163 pub enum VoteType { |
50 Kick(String), |
164 Kick(String), |