From c07f554b38e8093aea665692717be1eeca73eacb Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Wed, 10 Dec 2025 22:03:17 +0100 Subject: [PATCH] Some updates --- lib_efo/src/stats.rs | 32 ++++++++++++++++++++++------ lib_efo/src/stats/implementations.rs | 1 + 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib_efo/src/stats.rs b/lib_efo/src/stats.rs index cd985fd..6607748 100644 --- a/lib_efo/src/stats.rs +++ b/lib_efo/src/stats.rs @@ -240,34 +240,54 @@ pub struct OverallStats { } impl OverallStats { /// Create Stats with a given rng distribution + // TODO[6]: Use an iterator over the stat enum pub(crate) fn create_rng( rng: &RngLevel, mut rng_t: &mut ThreadRng, ) -> Result { let r = rng.to_rng()?; - Ok(Self { - demographics: (r.sample(&mut rng_t) as isize).into(), + let mut overall_stats = Self { + demographics: 0.into(), population: (r.sample(&mut rng_t) as isize).into(), growth_rate: (r.sample(&mut rng_t) as isize).into(), crime: (r.sample(&mut rng_t) as isize).into(), happiness: (r.sample(&mut rng_t) as isize).into(), - economy: (r.sample(&mut rng_t) as isize).into(), + economy: 0.into(), food: (r.sample(&mut rng_t) as isize).into(), industry: (r.sample(&mut rng_t) as isize).into(), science: (r.sample(&mut rng_t) as isize).into(), trade: (r.sample(&mut rng_t) as isize).into(), - military: (r.sample(&mut rng_t) as isize).into(), + military: 0.into(), army: (r.sample(&mut rng_t) as isize).into(), strength: (r.sample(&mut rng_t) as isize).into(), fortification: (r.sample(&mut rng_t) as isize).into(), threat: (r.sample(&mut rng_t) as isize).into(), - infrastructure: (r.sample(&mut rng_t) as isize).into(), + infrastructure: 0.into(), bureaucracy: (r.sample(&mut rng_t) as isize).into(), transportation: (r.sample(&mut rng_t) as isize).into(), sprawl: (r.sample(&mut rng_t) as isize).into(), health: (r.sample(&mut rng_t) as isize).into(), - }) + }; + overall_stats.update(); + Ok(overall_stats) } + + /// Updates the inner meta values + fn update(&mut self) { + self.demographics = + (*(self.population + self.growth_rate + self.happiness - self.crime) / 4).into(); + self.economy = (*(self.food + self.industry + self.trade + self.science) / 4).into(); + self.military = + (*(self.army + self.strength + self.fortification + self.threat) / 4).into(); + self.infrastructure = + (*(self.bureaucracy + self.transportation + self.sprawl + self.health) / 4).into(); + } + + /// Updates with events + /// Updates with leader + /// etc. + // TODO: Fill this + fn apply_exteriors(&mut self) {} } /// Strategic context and meta-data for an entity. diff --git a/lib_efo/src/stats/implementations.rs b/lib_efo/src/stats/implementations.rs index 837791a..74f5d65 100644 --- a/lib_efo/src/stats/implementations.rs +++ b/lib_efo/src/stats/implementations.rs @@ -19,6 +19,7 @@ macro_rules! thin_newtype { #[derive( Debug, Clone, + Copy, Default, PartialEq, Eq,