From 80f50c49cc166019da21daf4e9718aef2daa735f Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 21 Sep 2020 00:38:12 -0600 Subject: [PATCH] small fixes in weapon shop --- src/ship/shops/weapon.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/ship/shops/weapon.rs b/src/ship/shops/weapon.rs index c3a3267..723a980 100644 --- a/src/ship/shops/weapon.rs +++ b/src/ship/shops/weapon.rs @@ -1,4 +1,3 @@ - use std::collections::HashMap; use std::fs::File; use std::io::Read; @@ -130,7 +129,7 @@ fn load_weapon_table(difficulty: Difficulty, section_id: SectionID) -> WeaponTab } fn load_special_table() -> SpecialTable { - let mut path = PathBuf::from("data/shops/special.toml"); + let path = PathBuf::from("data/shops/special.toml"); let mut f = File::open(path).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); @@ -141,7 +140,7 @@ fn load_special_table() -> SpecialTable { } fn load_grind_table() -> GrindTable { - let mut path = PathBuf::from("data/shops/grind.toml"); + let path = PathBuf::from("data/shops/grind.toml"); let mut f = File::open(path).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); @@ -152,7 +151,7 @@ fn load_grind_table() -> GrindTable { } fn load_alt_grind_table() -> GrindTable { - let mut path = PathBuf::from("data/shops/alt_grind.toml"); + let path = PathBuf::from("data/shops/alt_grind.toml"); let mut f = File::open(path).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); @@ -163,7 +162,7 @@ fn load_alt_grind_table() -> GrindTable { } fn load_attribute1_table() -> AttributeTable { - let mut path = PathBuf::from("data/shops/attribute1.toml"); + let path = PathBuf::from("data/shops/attribute1.toml"); let mut f = File::open(path).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); @@ -174,7 +173,7 @@ fn load_attribute1_table() -> AttributeTable { } fn load_attribute2_table() -> AttributeTable { - let mut path = PathBuf::from("data/shops/attribute2.toml"); + let path = PathBuf::from("data/shops/attribute2.toml"); let mut f = File::open(path).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); @@ -207,7 +206,7 @@ impl WeaponShop { grind: load_grind_table(), alt_grind: load_alt_grind_table(), attr1: load_attribute1_table(), - attr2: load_attribute1_table(), + attr2: load_attribute2_table(), rng: R::from_entropy(), } } @@ -215,7 +214,7 @@ impl WeaponShop { fn generate_type(&mut self, level: usize) -> WeaponType { let tier = self.weapon.0.iter() - .filter(|t| t.level < level) + .filter(|t| t.level <= level) .last() .unwrap(); @@ -225,7 +224,7 @@ impl WeaponShop { fn generate_special(&mut self, level: usize) -> Option { let tier = self.special.0.iter() - .filter(|t| t.level < level) + .filter(|t| t.level <= level) .last() .unwrap(); @@ -239,7 +238,7 @@ impl WeaponShop { fn generate_grind(&mut self, level: usize) -> usize { let tier = self.grind.0.iter() - .filter(|t| t.level < level) + .filter(|t| t.level <= level) .last() .unwrap(); @@ -248,7 +247,7 @@ impl WeaponShop { fn generate_alt_grind(&mut self, level: usize) -> usize { let tier = self.alt_grind.0.iter() - .filter(|t| t.level < level) + .filter(|t| t.level <= level) .nth(0) .unwrap(); @@ -257,7 +256,7 @@ impl WeaponShop { fn generate_attribute1(&mut self, level: usize) -> Option { let tier = self.attr1.0.iter() - .filter(|t| t.level < level) + .filter(|t| t.level <= level) .last() .unwrap(); @@ -284,7 +283,7 @@ impl WeaponShop { fn generate_attribute2(&mut self, level: usize) -> Option { let tier = self.attr2.0.iter() - .filter(|t| t.level < level) + .filter(|t| t.level <= level) .last() .unwrap(); @@ -399,7 +398,7 @@ mod test { use super::*; #[test] - fn test_loading_weapons() { + fn test_loading_weapon_shop() { WeaponShop::::new(Difficulty::Ultimate, SectionID::Pinkal); } }