From 5158360fb57bc9f0bad4f7b765ac5ec25402f406 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Wed, 15 May 2024 02:42:04 +0200 Subject: [PATCH] Squashes last bugs --- src/stat_algo.rs | 9 +++++++++ src/stat_io.rs | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/stat_algo.rs b/src/stat_algo.rs index 314b8d8..fdb6f82 100644 --- a/src/stat_algo.rs +++ b/src/stat_algo.rs @@ -111,12 +111,21 @@ fn test_fit_for_all_creatures( mode: Mode, ) -> Result<()> { for _ in 0..statmatrix.get_len_affinity(stat) { + println!( + "[{:?}] Testing fit for stat {:?} at level {:?}", + mode, stat, fit_level + ); let found = match mode { Mode::Negative => statmatrix.find_creature_for_stat_with_negative_fit(stat, fit_level), Mode::Positive => statmatrix.find_creature_for_stat_with_fit(stat, fit_level), }; if let Ok(creature_id) = found { + println!( + " ==> Creature {} has affinity for stat {:?}", + statmatrix.inner_creature(creature_id, stat).get_name(), + stat + ); statmatrix .add_affinity_to_creature(statmatrix.to_vec_id(creature_id, stat), stat, mode) .unwrap(); diff --git a/src/stat_io.rs b/src/stat_io.rs index 1d73ba7..e280fc7 100644 --- a/src/stat_io.rs +++ b/src/stat_io.rs @@ -166,6 +166,7 @@ impl Creature { /// This test only works if the algo is done in the correct order #[deprecated] fn can_pick(&self, stat: AffName) -> bool { + println!(" ==> Testing if {} can fit {:?}", self.name, stat); self.selected_affinities.len() < 2 && !self.selected_affinities.contains(&stat) } @@ -173,7 +174,8 @@ impl Creature { /// This test only works if the algo is done in the correct order #[deprecated] fn can_pick_negatively(&self, stat: AffName) -> bool { - self.selected_affinities.is_empty() && !self.selected_affinities.contains(&stat) + println!(" ==> Testing if {} can fit {:?}", self.name, stat); + self.selected_negative_affinities.is_empty() && !self.selected_affinities.contains(&stat) } } @@ -299,7 +301,7 @@ impl CharacCharMatrix { stat: AffName, fit_level: &Fit, ) -> Result { - for (i, (creature, _)) in self.inner[stat as usize].iter().rev().enumerate() { + for (i, (creature, _)) in self.inner[stat as usize].iter().enumerate().rev() { if self.available_negative(*creature, stat, *fit_level).is_ok() { return Ok(i.into()); }