initiative_core/world/place/location/
mod.rs1mod geographical;
2mod landmark;
3mod settlement;
4
5use initiative_macros::WordList;
6use rand::Rng;
7use serde::{Deserialize, Serialize};
8
9use crate::world::Demographics;
10
11use super::{PlaceData, PlaceType};
12
13#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, WordList)]
14#[serde(into = "&'static str", try_from = "&str")]
15pub enum LocationType {
16 #[term = "location"]
17 Any,
18
19 Geographical(geographical::GeographicalType),
20 Landmark(landmark::LandmarkType),
21 Settlement(settlement::SettlementType),
22}
23
24impl LocationType {
25 pub const fn get_emoji(&self) -> Option<&'static str> {
26 match self {
27 Self::Any => None,
28 Self::Geographical(subtype) => subtype.get_emoji(),
29 Self::Landmark(subtype) => subtype.get_emoji(),
30 Self::Settlement(subtype) => subtype.get_emoji(),
31 }
32 }
33}
34
35pub fn generate(place: &mut PlaceData, rng: &mut impl Rng, demographics: &Demographics) {
36 #[expect(clippy::collapsible_match)]
37 if let Some(PlaceType::Location(subtype)) = place.subtype.value() {
38 #[expect(clippy::single_match)]
39 match subtype {
40 LocationType::Geographical(_) => geographical::generate(place, rng, demographics),
41 _ => {}
42 }
43 }
44}