Squashes last bugs

This commit is contained in:
Dandaedre 2024-05-15 02:42:04 +02:00
parent fa4cf4be29
commit 5158360fb5
2 changed files with 13 additions and 2 deletions

View File

@ -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();

View File

@ -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<CreatureInnerId> {
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());
}