initiative_core/world/place/location/geographical/
mod.rs

1mod beach;
2mod canyon;
3
4use initiative_macros::WordList;
5use rand::Rng;
6use serde::{Deserialize, Serialize};
7
8use crate::world::place::{PlaceData, PlaceType};
9use crate::world::Demographics;
10
11use super::LocationType;
12
13#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, WordList)]
14#[serde(into = "&'static str", try_from = "&str")]
15pub enum GeographicalType {
16    Beach,
17    #[alias = "gorge"]
18    Canyon,
19    #[alias = "cavern"]
20    Cave,
21    Chasm,
22    Glacier,
23    Grove,
24    Hill,
25    Island,
26    Monolith,
27    Oasis,
28    Pass,
29    Peninsula,
30    Ridge,
31    Rift,
32    River,
33    Tree,
34    #[alias = "vale"]
35    Valley,
36}
37
38impl GeographicalType {
39    pub const fn get_emoji(&self) -> Option<&'static str> {
40        match self {
41            Self::Beach => Some("🏖"),
42            Self::Canyon | Self::Chasm | Self::River | Self::Valley => Some("🏞"),
43            Self::Glacier => Some("🏔"),
44            Self::Grove | Self::Tree => Some("🌳"),
45            Self::Hill | Self::Pass | Self::Ridge => Some("⛰"),
46            Self::Island | Self::Peninsula => Some("🏝"),
47            Self::Monolith => Some("🗿"),
48            Self::Oasis => Some("🌴"),
49            Self::Cave | Self::Rift => None,
50        }
51    }
52}
53
54pub fn generate(place: &mut PlaceData, rng: &mut impl Rng, demographics: &Demographics) {
55    if let Some(PlaceType::Location(LocationType::Geographical(subtype))) = place.subtype.value() {
56        match subtype {
57            GeographicalType::Beach => beach::generate(place, rng, demographics),
58            GeographicalType::Canyon => canyon::generate(place, rng, demographics),
59            _ => {}
60        }
61    }
62}