bot uses random skill not just highest cooldown

This commit is contained in:
ntr 2019-04-11 10:15:06 +10:00
parent 0f21269a7e
commit d69b74653e
2 changed files with 11 additions and 8 deletions

View File

@ -335,14 +335,17 @@ impl Cryp {
return None;
}
let highest_cd = available.iter()
.filter(|s| s.skill.base_cd().is_some())
.max_by_key(|s| s.skill.base_cd().unwrap());
let mut rng = thread_rng();
return Some(available[rng.gen_range(0, available.len())].skill);
return match highest_cd {
Some(s) => Some(s.skill),
None => Some(available[0].skill),
};
// let highest_cd = available.iter()
// .filter(|s| s.skill.base_cd().is_some())
// .max_by_key(|s| s.skill.base_cd().unwrap());
// return match highest_cd {
// Some(s) => Some(s.skill),
// None => Some(available[0].skill),
// };
}
pub fn knows(&self, skill: Skill) -> bool {

View File

@ -391,6 +391,6 @@ mod tests {
let mut player = Player::new(player_account, Uuid::new_v4(), &"test".to_string(), cryps).set_bot(true);
player.autobuy();
println!("{:#?}", player);
assert!(player.cryps.iter().all(|c| c.skills.len() == 2));
}
}