|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
|
|
use std::collections::HashMap;
|
|
|
use std::fs::File;
|
|
|
use std::fs::File;
|
|
|
use std::io::Read;
|
|
|
use std::io::Read;
|
|
@ -130,7 +129,7 @@ fn load_weapon_table(difficulty: Difficulty, section_id: SectionID) -> WeaponTab |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn load_special_table() -> SpecialTable {
|
|
|
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 f = File::open(path).unwrap();
|
|
|
let mut s = String::new();
|
|
|
let mut s = String::new();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
@ -141,7 +140,7 @@ fn load_special_table() -> SpecialTable { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn load_grind_table() -> GrindTable {
|
|
|
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 f = File::open(path).unwrap();
|
|
|
let mut s = String::new();
|
|
|
let mut s = String::new();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
@ -152,7 +151,7 @@ fn load_grind_table() -> GrindTable { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn load_alt_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 f = File::open(path).unwrap();
|
|
|
let mut s = String::new();
|
|
|
let mut s = String::new();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
@ -163,7 +162,7 @@ fn load_alt_grind_table() -> GrindTable { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn load_attribute1_table() -> AttributeTable {
|
|
|
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 f = File::open(path).unwrap();
|
|
|
let mut s = String::new();
|
|
|
let mut s = String::new();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
@ -174,7 +173,7 @@ fn load_attribute1_table() -> AttributeTable { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn load_attribute2_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 f = File::open(path).unwrap();
|
|
|
let mut s = String::new();
|
|
|
let mut s = String::new();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
@ -207,7 +206,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
grind: load_grind_table(),
|
|
|
grind: load_grind_table(),
|
|
|
alt_grind: load_alt_grind_table(),
|
|
|
alt_grind: load_alt_grind_table(),
|
|
|
attr1: load_attribute1_table(),
|
|
|
attr1: load_attribute1_table(),
|
|
|
attr2: load_attribute1_table(),
|
|
|
|
|
|
|
|
|
attr2: load_attribute2_table(),
|
|
|
rng: R::from_entropy(),
|
|
|
rng: R::from_entropy(),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -215,7 +214,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
|
|
|
|
|
|
fn generate_type(&mut self, level: usize) -> WeaponType {
|
|
|
fn generate_type(&mut self, level: usize) -> WeaponType {
|
|
|
let tier = self.weapon.0.iter()
|
|
|
let tier = self.weapon.0.iter()
|
|
|
.filter(|t| t.level < level)
|
|
|
|
|
|
|
|
|
.filter(|t| t.level <= level)
|
|
|
.last()
|
|
|
.last()
|
|
|
.unwrap();
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
@ -225,7 +224,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
|
|
|
|
|
|
fn generate_special(&mut self, level: usize) -> Option<WeaponSpecial> {
|
|
|
fn generate_special(&mut self, level: usize) -> Option<WeaponSpecial> {
|
|
|
let tier = self.special.0.iter()
|
|
|
let tier = self.special.0.iter()
|
|
|
.filter(|t| t.level < level)
|
|
|
|
|
|
|
|
|
.filter(|t| t.level <= level)
|
|
|
.last()
|
|
|
.last()
|
|
|
.unwrap();
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
@ -239,7 +238,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
|
|
|
|
|
|
fn generate_grind(&mut self, level: usize) -> usize {
|
|
|
fn generate_grind(&mut self, level: usize) -> usize {
|
|
|
let tier = self.grind.0.iter()
|
|
|
let tier = self.grind.0.iter()
|
|
|
.filter(|t| t.level < level)
|
|
|
|
|
|
|
|
|
.filter(|t| t.level <= level)
|
|
|
.last()
|
|
|
.last()
|
|
|
.unwrap();
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
@ -248,7 +247,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
|
|
|
|
|
|
fn generate_alt_grind(&mut self, level: usize) -> usize {
|
|
|
fn generate_alt_grind(&mut self, level: usize) -> usize {
|
|
|
let tier = self.alt_grind.0.iter()
|
|
|
let tier = self.alt_grind.0.iter()
|
|
|
.filter(|t| t.level < level)
|
|
|
|
|
|
|
|
|
.filter(|t| t.level <= level)
|
|
|
.nth(0)
|
|
|
.nth(0)
|
|
|
.unwrap();
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
@ -257,7 +256,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
|
|
|
|
|
|
fn generate_attribute1(&mut self, level: usize) -> Option<WeaponAttribute> {
|
|
|
fn generate_attribute1(&mut self, level: usize) -> Option<WeaponAttribute> {
|
|
|
let tier = self.attr1.0.iter()
|
|
|
let tier = self.attr1.0.iter()
|
|
|
.filter(|t| t.level < level)
|
|
|
|
|
|
|
|
|
.filter(|t| t.level <= level)
|
|
|
.last()
|
|
|
.last()
|
|
|
.unwrap();
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
@ -284,7 +283,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
|
|
|
|
|
|
fn generate_attribute2(&mut self, level: usize) -> Option<WeaponAttribute> {
|
|
|
fn generate_attribute2(&mut self, level: usize) -> Option<WeaponAttribute> {
|
|
|
let tier = self.attr2.0.iter()
|
|
|
let tier = self.attr2.0.iter()
|
|
|
.filter(|t| t.level < level)
|
|
|
|
|
|
|
|
|
.filter(|t| t.level <= level)
|
|
|
.last()
|
|
|
.last()
|
|
|
.unwrap();
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
@ -399,7 +398,7 @@ mod test { |
|
|
use super::*;
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_loading_weapons() {
|
|
|
|
|
|
|
|
|
fn test_loading_weapon_shop() {
|
|
|
WeaponShop::<rand_chacha::ChaCha20Rng>::new(Difficulty::Ultimate, SectionID::Pinkal);
|
|
|
WeaponShop::<rand_chacha::ChaCha20Rng>::new(Difficulty::Ultimate, SectionID::Pinkal);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|