|
@ -3,6 +3,7 @@ use std::fs::File; |
|
|
use std::io::Read;
|
|
|
use std::io::Read;
|
|
|
use std::path::PathBuf;
|
|
|
use std::path::PathBuf;
|
|
|
use std::convert::TryInto;
|
|
|
use std::convert::TryInto;
|
|
|
|
|
|
use std::cmp::Ordering;
|
|
|
use serde::Deserialize;
|
|
|
use serde::Deserialize;
|
|
|
use rand::{Rng, SeedableRng};
|
|
|
use rand::{Rng, SeedableRng};
|
|
|
use rand::distributions::{WeightedIndex, Distribution};
|
|
|
use rand::distributions::{WeightedIndex, Distribution};
|
|
@ -29,6 +30,33 @@ pub struct WeaponShopItem { |
|
|
attributes: [Option<WeaponAttribute>; 2],
|
|
|
attributes: [Option<WeaponAttribute>; 2],
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Eq for WeaponShopItem {}
|
|
|
|
|
|
|
|
|
|
|
|
impl Ord for WeaponShopItem {
|
|
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
|
|
|
|
|
self.weapon.value().cmp(&other.weapon.value())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl PartialOrd for WeaponShopItem {
|
|
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
|
|
Some(self.cmp(other))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn special_stars(special: &WeaponSpecial) -> usize {
|
|
|
fn special_stars(special: &WeaponSpecial) -> usize {
|
|
|
match special {
|
|
|
match special {
|
|
@ -500,11 +528,13 @@ impl<R: Rng + SeedableRng> WeaponShop<R> { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn generate_weapon_list(&mut self, level: usize) -> Vec<WeaponShopItem> {
|
|
|
pub fn generate_weapon_list(&mut self, level: usize) -> Vec<WeaponShopItem> {
|
|
|
(0..number_of_weapons_to_generate(level))
|
|
|
|
|
|
|
|
|
let mut x = (0..number_of_weapons_to_generate(level))
|
|
|
.map(|_| {
|
|
|
.map(|_| {
|
|
|
self.generate_weapon(level)
|
|
|
self.generate_weapon(level)
|
|
|
})
|
|
|
})
|
|
|
.collect()
|
|
|
|
|
|
|
|
|
.collect::<Vec<WeaponShopItem>>();
|
|
|
|
|
|
x.sort();
|
|
|
|
|
|
x
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|