Browse Source

lint src/ship/shop/weapon.rs

pull/42/head
jake 3 years ago
parent
commit
027de8a20d
  1. 109
      src/ship/shops/weapon.rs

109
src/ship/shops/weapon.rs

@ -32,14 +32,10 @@ pub struct WeaponShopItem {
impl PartialEq for WeaponShopItem {
fn eq(&self, other: &Self) -> bool {
if self.weapon == other.weapon &&
self.special == other.special &&
self.grind == other.grind &&
self.attributes == other.attributes {
true
} else {
false
}
self.weapon == other.weapon &&
self.special == other.special &&
self.grind == other.grind &&
self.attributes == other.attributes
}
}
@ -247,7 +243,7 @@ fn load_weapon_table(difficulty: Difficulty, section_id: SectionID) -> WeaponTab
let mut table: HashMap<String, Vec<WeaponTableTier>> = toml::from_str(s.as_str()).unwrap();
WeaponTable(table.remove("weapon_tier".into()).unwrap())
WeaponTable(table.remove("weapon_tier").unwrap())
}
fn load_special_table() -> SpecialTable {
@ -258,7 +254,7 @@ fn load_special_table() -> SpecialTable {
let mut table: HashMap<String, Vec<SpecialTier>> = toml::from_str(s.as_str()).unwrap();
SpecialTable(table.remove("specials".into()).unwrap())
SpecialTable(table.remove("specials").unwrap())
}
fn load_grind_table() -> GrindTable {
@ -269,7 +265,7 @@ fn load_grind_table() -> GrindTable {
let mut table: HashMap<String, Vec<GrindTier>> = toml::from_str(s.as_str()).unwrap();
GrindTable(table.remove("grind".into()).unwrap())
GrindTable(table.remove("grind").unwrap())
}
fn load_alt_grind_table() -> GrindTable {
@ -280,7 +276,7 @@ fn load_alt_grind_table() -> GrindTable {
let mut table: HashMap<String, Vec<GrindTier>> = toml::from_str(s.as_str()).unwrap();
GrindTable(table.remove("grind".into()).unwrap())
GrindTable(table.remove("grind").unwrap())
}
fn load_attribute1_table() -> AttributeTable {
@ -291,7 +287,7 @@ fn load_attribute1_table() -> AttributeTable {
let mut table: HashMap<String, Vec<AttributeTier>> = toml::from_str(s.as_str()).unwrap();
AttributeTable(table.remove("attributes".into()).unwrap())
AttributeTable(table.remove("attributes").unwrap())
}
fn load_attribute2_table() -> AttributeTable {
@ -302,7 +298,7 @@ fn load_attribute2_table() -> AttributeTable {
let mut table: HashMap<String, Vec<AttributeTier>> = toml::from_str(s.as_str()).unwrap();
AttributeTable(table.remove("attributes".into()).unwrap())
AttributeTable(table.remove("attributes").unwrap())
}
fn number_of_weapons_to_generate(character_level: usize) -> usize {
@ -381,8 +377,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> {
fn generate_alt_grind(&mut self, level: usize) -> usize {
let tier = self.alt_grind.0.iter()
.filter(|t| t.level <= level)
.nth(0)
.find(|t| t.level <= level)
.unwrap();
self.rng.gen_range(tier.min, tier.max+1)
@ -443,48 +438,46 @@ impl<R: Rng + SeedableRng> WeaponShop<R> {
}
fn is_alt_grind(&self, weapon: &WeaponType) -> bool {
match (self.section_id, weapon) {
(SectionID::Viridia, WeaponType::Shot) => true,
(SectionID::Viridia, WeaponType::Spread) => true,
(SectionID::Viridia, WeaponType::Cannon) => true,
(SectionID::Viridia, WeaponType::Launcher) => true,
(SectionID::Viridia, WeaponType::Arms) => true,
(SectionID::Greenill, WeaponType::Rifle) => true,
(SectionID::Greenill, WeaponType::Sniper) => true,
(SectionID::Greenill, WeaponType::Blaster) => true,
(SectionID::Greenill, WeaponType::Beam) => true,
(SectionID::Greenill, WeaponType::Laser) => true,
(SectionID::Skyly, WeaponType::Sword) => true,
(SectionID::Skyly, WeaponType::Gigush) => true,
(SectionID::Skyly, WeaponType::Breaker) => true,
(SectionID::Skyly, WeaponType::Claymore) => true,
(SectionID::Skyly, WeaponType::Calibur) => true,
(SectionID::Bluefull, WeaponType::Partisan) => true,
(SectionID::Bluefull, WeaponType::Halbert) => true,
(SectionID::Bluefull, WeaponType::Glaive) => true,
(SectionID::Bluefull, WeaponType::Berdys) => true,
(SectionID::Bluefull, WeaponType::Gungnir) => true,
(SectionID::Purplenum, WeaponType::Mechgun) => true,
(SectionID::Purplenum, WeaponType::Assault) => true,
(SectionID::Purplenum, WeaponType::Repeater) => true,
(SectionID::Purplenum, WeaponType::Gatling) => true,
(SectionID::Purplenum, WeaponType::Vulcan) => true,
(SectionID::Pinkal, WeaponType::Cane) => true,
(SectionID::Pinkal, WeaponType::Stick) => true,
(SectionID::Pinkal, WeaponType::Mace) => true,
(SectionID::Pinkal, WeaponType::Club) => true,
(SectionID::Oran, WeaponType::Dagger) => true,
(SectionID::Oran, WeaponType::Knife) => true,
(SectionID::Oran, WeaponType::Blade) => true,
(SectionID::Oran, WeaponType::Edge) => true,
(SectionID::Oran, WeaponType::Ripper) => true,
(SectionID::Whitill, WeaponType::Slicer) => true,
(SectionID::Whitill, WeaponType::Spinner) => true,
(SectionID::Whitill, WeaponType::Cutter) => true,
(SectionID::Whitill, WeaponType::Sawcer) => true,
(SectionID::Whitill, WeaponType::Diska) => true,
_ => false,
}
matches!((self.section_id, weapon),
(SectionID::Viridia, WeaponType::Shot) |
(SectionID::Viridia, WeaponType::Spread) |
(SectionID::Viridia, WeaponType::Cannon) |
(SectionID::Viridia, WeaponType::Launcher) |
(SectionID::Viridia, WeaponType::Arms) |
(SectionID::Greenill, WeaponType::Rifle) |
(SectionID::Greenill, WeaponType::Sniper) |
(SectionID::Greenill, WeaponType::Blaster) |
(SectionID::Greenill, WeaponType::Beam) |
(SectionID::Greenill, WeaponType::Laser) |
(SectionID::Skyly, WeaponType::Sword) |
(SectionID::Skyly, WeaponType::Gigush) |
(SectionID::Skyly, WeaponType::Breaker) |
(SectionID::Skyly, WeaponType::Claymore) |
(SectionID::Skyly, WeaponType::Calibur) |
(SectionID::Bluefull, WeaponType::Partisan) |
(SectionID::Bluefull, WeaponType::Halbert) |
(SectionID::Bluefull, WeaponType::Glaive) |
(SectionID::Bluefull, WeaponType::Berdys) |
(SectionID::Bluefull, WeaponType::Gungnir) |
(SectionID::Purplenum, WeaponType::Mechgun) |
(SectionID::Purplenum, WeaponType::Assault) |
(SectionID::Purplenum, WeaponType::Repeater) |
(SectionID::Purplenum, WeaponType::Gatling) |
(SectionID::Purplenum, WeaponType::Vulcan) |
(SectionID::Pinkal, WeaponType::Cane) |
(SectionID::Pinkal, WeaponType::Stick) |
(SectionID::Pinkal, WeaponType::Mace) |
(SectionID::Pinkal, WeaponType::Club) |
(SectionID::Oran, WeaponType::Dagger) |
(SectionID::Oran, WeaponType::Knife) |
(SectionID::Oran, WeaponType::Blade) |
(SectionID::Oran, WeaponType::Edge) |
(SectionID::Oran, WeaponType::Ripper) |
(SectionID::Whitill, WeaponType::Slicer) |
(SectionID::Whitill, WeaponType::Spinner) |
(SectionID::Whitill, WeaponType::Cutter) |
(SectionID::Whitill, WeaponType::Sawcer) |
(SectionID::Whitill, WeaponType::Diska))
}
fn generate_weapon(&mut self, level: usize) -> WeaponShopItem {

Loading…
Cancel
Save