veloren_common/terrain/
biome.rs1use serde::{Deserialize, Serialize};
2use strum::EnumIter;
3
4#[derive(Default, Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, EnumIter)]
5pub enum BiomeKind {
6 #[default]
7 Void,
8 Lake,
9 Grassland,
10 Ocean,
11 Mountain,
12 Snowland,
13 Desert,
14 Swamp,
15 Jungle,
16 Forest,
17 Savannah,
18 Taiga,
19}
20
21impl BiomeKind {
22 pub fn difficulty(&self) -> i32 {
24 match self {
25 BiomeKind::Void => 1,
26 BiomeKind::Lake => 1,
27 BiomeKind::Grassland => 2,
28 BiomeKind::Ocean => 1,
29 BiomeKind::Mountain => 1,
30 BiomeKind::Snowland => 2,
31 BiomeKind::Desert => 5,
32 BiomeKind::Swamp => 2,
33 BiomeKind::Jungle => 3,
34 BiomeKind::Forest => 1,
35 BiomeKind::Savannah => 2,
36 BiomeKind::Taiga => 2,
37 }
38 }
39}
40
41#[cfg(test)]
42#[test]
43fn test_biome_difficulty() {
44 use strum::IntoEnumIterator;
45
46 for biome_kind in BiomeKind::iter() {
47 assert!(
48 (1..=5).contains(&biome_kind.difficulty()),
49 "Biome {biome_kind:?} has invalid difficulty {}",
50 biome_kind.difficulty()
51 );
52 }
53}