1use serde::{Deserialize, Serialize};
6use strum::VariantArray;
7
8#[derive(
10 Serialize, Deserialize, Debug, Clone, PartialEq, Eq, strum::Display, strum::EnumString,
11)]
12#[cfg_attr(test, derive(arbitrary::Arbitrary))]
13#[cfg_attr(test, serde(deny_unknown_fields))]
14pub enum Map {
15 #[serde(rename = "Crafted Map")]
16 #[strum(serialize = "Crafted Map")]
17 CraftedMap,
18 #[serde(rename = "Altai")]
19 #[strum(serialize = "Altai")]
20 Altai,
21 #[serde(rename = "Ancient Spires")]
22 #[strum(serialize = "Ancient Spires")]
23 AncientSpires,
24 #[serde(rename = "Archipelago")]
25 #[strum(serialize = "Archipelago")]
26 Archipelago,
27 #[serde(rename = "Black Forest")]
28 #[strum(serialize = "Black Forest")]
29 BlackForest,
30 #[serde(rename = "Boulder Bay")]
31 #[strum(serialize = "Boulder Bay")]
32 BoulderBay,
33 #[serde(rename = "Confluence")]
34 #[strum(serialize = "Confluence")]
35 Confluence,
36 #[serde(rename = "Danube River")]
37 #[strum(serialize = "Danube River")]
38 DanubeRiver,
39 #[serde(rename = "Dry Arabia")]
40 #[strum(serialize = "Dry Arabia")]
41 DryArabia,
42 #[serde(rename = "French Pass")]
43 #[strum(serialize = "French Pass")]
44 FrenchPass,
45 #[serde(rename = "High View")]
46 #[strum(serialize = "High View")]
47 HighView,
48 #[serde(rename = "Hill and Dale")]
49 #[strum(serialize = "Hill and Dale")]
50 HillAndDale,
51 #[serde(rename = "King of the Hill")]
52 #[strum(serialize = "King of the Hill")]
53 KingOfTheHill,
54 #[serde(rename = "Lipany")]
55 #[strum(serialize = "Lipany")]
56 Lipany,
57 #[serde(rename = "Mongolian Heights")]
58 #[strum(serialize = "Mongolian Heights")]
59 MongolianHeights,
60 #[serde(rename = "Mountain Pass")]
61 #[strum(serialize = "Mountain Pass")]
62 MountainPass,
63 #[serde(rename = "Nagari")]
64 #[strum(serialize = "Nagari")]
65 Nagari,
66 #[serde(rename = "Warring Islands")]
67 #[strum(serialize = "Warring Islands")]
68 WarringIslands,
69 #[serde(rename = "MegaRandom")]
70 #[strum(serialize = "MegaRandom")]
71 MegaRandom,
72 #[serde(rename = "The Pit")]
73 #[strum(serialize = "The Pit")]
74 ThePit,
75 #[serde(rename = "Oasis")]
76 #[strum(serialize = "Oasis")]
77 Oasis,
78 #[serde(alias = "Mediterranean")]
79 #[serde(rename = "Baltic")]
80 #[strum(serialize = "Baltic")]
81 Baltic,
82 #[serde(rename = "Forest Ponds")]
83 #[strum(serialize = "Forest Ponds")]
84 ForestPonds,
85 #[serde(rename = "Wetlands")]
86 #[strum(serialize = "Wetlands")]
87 Wetlands,
88 #[serde(rename = "Prairie")]
89 #[strum(serialize = "Prairie")]
90 Prairie,
91 #[serde(rename = "Watering Holes")]
92 #[strum(serialize = "Watering Holes")]
93 WateringHoles,
94 #[serde(rename = "Hideout")]
95 #[strum(serialize = "Hideout")]
96 Hideout,
97 #[serde(rename = "Mountain Clearing")]
98 #[strum(serialize = "Mountain Clearing")]
99 MountainClearing,
100 #[serde(rename = "Continental")]
101 #[strum(serialize = "Continental")]
102 Continental,
103 #[serde(rename = "Marshland")]
104 #[strum(serialize = "Marshland")]
105 Marshland,
106 #[serde(rename = "Four Lakes")]
107 #[strum(serialize = "Four Lakes")]
108 FourLakes,
109 #[serde(rename = "Migration")]
110 #[strum(serialize = "Migration")]
111 Migration,
112 #[serde(rename = "Volcanic Island")]
113 #[strum(serialize = "Volcanic Island")]
114 VolcanicIsland,
115 #[serde(rename = "Golden Heights")]
116 #[strum(serialize = "Golden Heights")]
117 GoldenHeights,
118 #[serde(rename = "African Waters")]
119 #[strum(serialize = "African Waters")]
120 AfricanWaters,
121 #[serde(rename = "Thickets")]
122 #[strum(serialize = "Thickets")]
123 Thickets,
124 #[serde(rename = "Golden Pit")]
125 #[strum(serialize = "Golden Pit")]
126 GoldenPit,
127 #[serde(rename = "Cliffside")]
128 #[strum(serialize = "Cliffside")]
129 Cliffside,
130 #[serde(rename = "Gorge")]
131 #[strum(serialize = "Gorge")]
132 Gorge,
133 #[serde(rename = "Canal")]
134 #[strum(serialize = "Canal")]
135 Canal,
136 #[serde(rename = "Glade")]
137 #[strum(serialize = "Glade")]
138 Glade,
139 #[serde(rename = "Haywire")]
140 #[strum(serialize = "Haywire")]
141 Haywire,
142 #[serde(rename = "Turtle Ridge")]
143 #[strum(serialize = "Turtle Ridge")]
144 TurtleRidge,
145 #[serde(rename = "Rocky River")]
146 #[strum(serialize = "Rocky River")]
147 RockyRiver,
148 #[serde(rename = "Himeyama")]
149 #[strum(serialize = "Himeyama")]
150 Himeyama,
151 #[serde(rename = "Forts")]
152 #[strum(serialize = "Forts")]
153 Forts,
154 #[serde(rename = "Hidden Valley")]
155 #[strum(serialize = "Hidden Valley")]
156 HiddenValley,
157 #[serde(untagged)]
158 #[strum(default)]
159 #[cfg(not(test))]
160 Unknown(String),
161}
162
163impl PartialOrd for Map {
164 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
165 Some(self.to_string().cmp(&other.to_string()))
166 }
167}
168
169impl Ord for Map {
170 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
171 self.partial_cmp(other).unwrap()
172 }
173}
174
175impl VariantArray for Map {
176 const VARIANTS: &'static [Self] = &[
177 Self::CraftedMap,
178 Self::Altai,
179 Self::AncientSpires,
180 Self::Archipelago,
181 Self::BlackForest,
182 Self::BoulderBay,
183 Self::Confluence,
184 Self::DanubeRiver,
185 Self::DryArabia,
186 Self::FrenchPass,
187 Self::HighView,
188 Self::HillAndDale,
189 Self::KingOfTheHill,
190 Self::Lipany,
191 Self::MongolianHeights,
192 Self::MountainPass,
193 Self::Nagari,
194 Self::WarringIslands,
195 Self::MegaRandom,
196 Self::ThePit,
197 Self::Oasis,
198 Self::Baltic,
199 Self::ForestPonds,
200 Self::Wetlands,
201 Self::Prairie,
202 Self::WateringHoles,
203 Self::Hideout,
204 Self::MountainClearing,
205 Self::Continental,
206 Self::Marshland,
207 Self::FourLakes,
208 Self::Migration,
209 Self::VolcanicIsland,
210 Self::GoldenHeights,
211 Self::AfricanWaters,
212 Self::Thickets,
213 Self::GoldenPit,
214 Self::Cliffside,
215 Self::Gorge,
216 Self::Canal,
217 Self::Glade,
218 Self::Haywire,
219 Self::TurtleRidge,
220 Self::RockyRiver,
221 Self::Himeyama,
222 Self::Forts,
223 Self::HiddenValley,
224 ];
225}
226
227impl Map {
228 #[allow(non_upper_case_globals)]
230 pub const Mediterranean: Self = Self::Baltic;
231
232 pub fn map_type(&self) -> MapType {
233 match self {
234 Map::CraftedMap => MapType::Unknown,
235 Map::Altai => MapType::Land,
236 Map::AncientSpires => MapType::Hybrid,
237 Map::Archipelago => MapType::Water,
238 Map::BlackForest => MapType::Hybrid,
239 Map::BoulderBay => MapType::Hybrid,
240 Map::Confluence => MapType::Hybrid,
241 Map::DanubeRiver => MapType::Hybrid,
242 Map::DryArabia => MapType::Land,
243 Map::FrenchPass => MapType::Land,
244 Map::HighView => MapType::Land,
245 Map::HillAndDale => MapType::Land,
246 Map::KingOfTheHill => MapType::Land,
247 Map::Lipany => MapType::Land,
248 Map::MongolianHeights => MapType::Hybrid,
249 Map::MountainPass => MapType::Land,
250 Map::Nagari => MapType::Hybrid,
251 Map::WarringIslands => MapType::Water,
252 Map::MegaRandom => MapType::Hybrid,
253 Map::ThePit => MapType::Land,
254 Map::Oasis => MapType::Hybrid,
255 Map::Baltic => MapType::Hybrid,
256 Map::ForestPonds => MapType::Hybrid,
257 Map::Wetlands => MapType::Hybrid,
258 Map::Prairie => MapType::Land,
259 Map::WateringHoles => MapType::Hybrid,
260 Map::Hideout => MapType::Land,
261 Map::MountainClearing => MapType::Land,
262 Map::Continental => MapType::Hybrid,
263 Map::Marshland => MapType::Land,
264 Map::FourLakes => MapType::Hybrid,
265 Map::Migration => MapType::Water,
266 Map::VolcanicIsland => MapType::Hybrid,
267 Map::GoldenHeights => MapType::Hybrid,
268 Map::AfricanWaters => MapType::Hybrid,
269 Map::Thickets => MapType::Hybrid,
270 Map::GoldenPit => MapType::Land,
271 Map::Cliffside => MapType::Land,
272 Map::Gorge => MapType::Land,
273 Map::Canal => MapType::Hybrid,
274 Map::Glade => MapType::Land,
275 Map::Haywire => MapType::Land,
276 Map::TurtleRidge => MapType::Land,
277 Map::RockyRiver => MapType::Hybrid,
278 Map::Himeyama => MapType::Land,
279 Map::Forts => MapType::Hybrid,
280 Map::HiddenValley => MapType::Land,
281 #[cfg(not(test))]
282 Map::Unknown(_) => MapType::Unknown,
283 }
284 }
285}
286
287#[derive(
289 Serialize,
290 Deserialize,
291 Debug,
292 Clone,
293 PartialEq,
294 Eq,
295 strum::Display,
296 strum::EnumString,
297 strum::VariantArray,
298 PartialOrd,
299 Ord,
300)]
301#[cfg_attr(test, derive(arbitrary::Arbitrary))]
302#[cfg_attr(test, serde(deny_unknown_fields))]
303#[serde(rename_all = "snake_case")]
304#[strum(serialize_all = "snake_case")]
305pub enum MapType {
306 Unknown,
308 Land,
310 Hybrid,
312 Water,
314}
315
316#[cfg(test)]
317mod test_super {
318 #![allow(unused_imports)]
319
320 use crate::testutils::{test_enum_to_string, test_serde_roundtrip_prop};
321
322 use super::*;
323
324 test_serde_roundtrip_prop!(Map);
325 test_serde_roundtrip_prop!(MapType);
326
327 test_enum_to_string!(Map);
328 test_enum_to_string!(MapType);
329}