starlane_core/
constellation.rs

1use crate::template::{StarTemplate, StarTemplateSelector};
2
3pub struct Constellation {
4    pub name: String,
5    pub stars: Vec<StarTemplate>,
6}
7
8impl Constellation {
9    pub fn new(name: String) -> Self {
10        Self {
11            name: name,
12            stars: vec![],
13        }
14    }
15
16    pub fn select(&self, selector: StarTemplateSelector) -> Option<StarTemplate> {
17        for star in &self.stars {
18            match &selector {
19                StarTemplateSelector::Handle(handle) => {
20                    if star.handle == *handle {
21                        return Option::Some(star.clone());
22                    }
23                }
24                StarTemplateSelector::Kind(kind) => {
25                    if star.kind == *kind {
26                        return Option::Some(star.clone());
27                    }
28                }
29            }
30        }
31        return Option::None;
32    }
33}
34
35#[derive(Clone, Eq, PartialEq)]
36pub enum ConstellationStatus {
37    Unknown,
38    Assembled,
39    Ready,
40}
41
42#[cfg(test)]
43mod test {
44    use tokio::runtime::Runtime;
45
46    #[test]
47    pub fn test() {}
48}