use crate::internal::*;
use crate::prelude::*;
#[path = "./constants.rs"]
mod constants;
use constants::*;
pub mod generator;
pub mod map;
pub mod neighborhood;
pub mod types;
#[derive(Clone, PartialEq, PartialOrd, Debug, Serialize, Deserialize)]
pub struct Galaxy {
pub settings: GenerationSettings,
pub neighborhood: GalacticNeighborhood,
pub index: u16,
pub name: Rc<str>,
pub age: f32,
pub is_dominant: bool,
pub is_major: bool,
pub category: GalaxyCategory,
pub sub_category: GalaxySubCategory,
pub special_traits: Vec<GalaxySpecialTrait>,
pub division_levels: Vec<GalacticMapDivisionLevel>,
pub divisions: Vec<GalacticMapDivision>,
pub hexes: Vec<GalacticHex>,
}
impl Default for Galaxy {
fn default() -> Self {
Self {
settings: GenerationSettings {
..Default::default()
},
neighborhood: GalacticNeighborhood {
..Default::default()
},
index: 0,
name: OUR_GALAXYS_NAME.into(),
age: OUR_GALAXYS_AGE,
is_dominant: false,
is_major: true,
category: OUR_GALAXYS_CATEGORY,
sub_category: OUR_GALAXYS_SUB_CATEGORY,
special_traits: vec![NO_SPECIAL_TRAIT],
division_levels: vec![],
divisions: vec![],
hexes: vec![],
}
}
}
impl Display for Galaxy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{:04} - \"{}\" - {}{}, of sub-type {}, aged {} billion years, with the following special traits: {}",
self.index,
self.name,
if self.is_dominant { "" } else if self.is_major { "major " } else { "minor " },
self.category,
self.sub_category,
self.age,
self.special_traits
.iter()
.map(|t| format!("{}", t))
.collect::<Vec<String>>()
.join(", ")
)
}
}
impl Galaxy {
pub fn new(
settings: GenerationSettings,
neighborhood: GalacticNeighborhood,
index: u16,
name: Rc<str>,
age: f32,
is_dominant: bool,
is_major: bool,
category: GalaxyCategory,
sub_category: GalaxySubCategory,
special_traits: Vec<GalaxySpecialTrait>,
) -> Self {
Self {
settings,
neighborhood,
index,
name,
age,
is_dominant,
is_major,
category,
sub_category,
special_traits,
division_levels: vec![],
divisions: vec![],
hexes: vec![],
}
}
}