professional rusting
This commit is contained in:
parent
82c4c2a445
commit
6611f2b3a8
@ -3,6 +3,7 @@ use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::convert::TryInto;
|
||||
use std::cmp::Ordering;
|
||||
use serde::Deserialize;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand::distributions::{WeightedIndex, Distribution};
|
||||
@ -29,6 +30,33 @@ pub struct WeaponShopItem {
|
||||
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 {
|
||||
match special {
|
||||
@ -500,11 +528,13 @@ impl<R: Rng + SeedableRng> WeaponShop<R> {
|
||||
}
|
||||
|
||||
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(|_| {
|
||||
self.generate_weapon(level)
|
||||
})
|
||||
.collect()
|
||||
.collect::<Vec<WeaponShopItem>>();
|
||||
x.sort();
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user