|
@ -19,7 +19,7 @@ pub enum ArmorShopItem { |
|
|
Unit(UnitType),
|
|
|
Unit(UnitType),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
const ARMOR_MULTIPLIER: f32 = 0.799999952;
|
|
|
|
|
|
|
|
|
const ARMOR_MULTIPLIER: f32 = 0.799_999_95;
|
|
|
const SHIELD_MULTIPLIER: f32 = 1.5;
|
|
|
const SHIELD_MULTIPLIER: f32 = 1.5;
|
|
|
const UNIT_MULTIPLIER: f32 = 1000.0;
|
|
|
const UNIT_MULTIPLIER: f32 = 1000.0;
|
|
|
|
|
|
|
|
@ -27,7 +27,7 @@ impl ShopItem for ArmorShopItem { |
|
|
fn price(&self) -> usize {
|
|
|
fn price(&self) -> usize {
|
|
|
match self {
|
|
|
match self {
|
|
|
ArmorShopItem::Frame(frame, slot) => {
|
|
|
ArmorShopItem::Frame(frame, slot) => {
|
|
|
ARMOR_STATS.get(&frame)
|
|
|
|
|
|
|
|
|
ARMOR_STATS.get(frame)
|
|
|
.map(|frame_stats| {
|
|
|
.map(|frame_stats| {
|
|
|
let mut price = (frame_stats.dfp + frame_stats.evp) as f32;
|
|
|
let mut price = (frame_stats.dfp + frame_stats.evp) as f32;
|
|
|
price *= price;
|
|
|
price *= price;
|
|
@ -39,7 +39,7 @@ impl ShopItem for ArmorShopItem { |
|
|
.unwrap_or(0xFFFF)
|
|
|
.unwrap_or(0xFFFF)
|
|
|
},
|
|
|
},
|
|
|
ArmorShopItem::Barrier(barrier) => {
|
|
|
ArmorShopItem::Barrier(barrier) => {
|
|
|
SHIELD_STATS.get(&barrier)
|
|
|
|
|
|
|
|
|
SHIELD_STATS.get(barrier)
|
|
|
.map(|barrier_stats| {
|
|
|
.map(|barrier_stats| {
|
|
|
let mut price = (barrier_stats.dfp + barrier_stats.evp) as f32;
|
|
|
let mut price = (barrier_stats.dfp + barrier_stats.evp) as f32;
|
|
|
price *= price;
|
|
|
price *= price;
|
|
@ -50,7 +50,7 @@ impl ShopItem for ArmorShopItem { |
|
|
.unwrap_or(0xFFFF)
|
|
|
.unwrap_or(0xFFFF)
|
|
|
},
|
|
|
},
|
|
|
ArmorShopItem::Unit(unit) => {
|
|
|
ArmorShopItem::Unit(unit) => {
|
|
|
UNIT_STATS.get(&unit)
|
|
|
|
|
|
|
|
|
UNIT_STATS.get(unit)
|
|
|
.map(|unit_stats| {
|
|
|
.map(|unit_stats| {
|
|
|
(unit_stats.stars as f32 * UNIT_MULTIPLIER) as usize
|
|
|
(unit_stats.stars as f32 * UNIT_MULTIPLIER) as usize
|
|
|
})
|
|
|
})
|
|
@ -236,8 +236,8 @@ pub struct ArmorShop<R: Rng + SeedableRng> { |
|
|
rng: R,
|
|
|
rng: R,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<R: Rng + SeedableRng> ArmorShop<R> {
|
|
|
|
|
|
pub fn new() -> ArmorShop<R> {
|
|
|
|
|
|
|
|
|
impl<R: Rng + SeedableRng> Default for ArmorShop<R> {
|
|
|
|
|
|
fn default() -> ArmorShop<R> {
|
|
|
ArmorShop {
|
|
|
ArmorShop {
|
|
|
frame: load_frame_table(),
|
|
|
frame: load_frame_table(),
|
|
|
barrier: load_barrier_table(),
|
|
|
barrier: load_barrier_table(),
|
|
@ -245,7 +245,9 @@ impl<R: Rng + SeedableRng> ArmorShop<R> { |
|
|
rng: R::from_entropy(),
|
|
|
rng: R::from_entropy(),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<R: Rng + SeedableRng> ArmorShop<R> {
|
|
|
fn generate_frame_list(&mut self, character_level: usize) -> Vec<ArmorShopItem> {
|
|
|
fn generate_frame_list(&mut self, character_level: usize) -> Vec<ArmorShopItem> {
|
|
|
let tier = self.frame.frame.iter()
|
|
|
let tier = self.frame.frame.iter()
|
|
|
.filter(|t| t.level <= character_level)
|
|
|
.filter(|t| t.level <= character_level)
|
|
@ -297,7 +299,7 @@ impl<R: Rng + SeedableRng> ArmorShop<R> { |
|
|
})
|
|
|
})
|
|
|
.collect()
|
|
|
.collect()
|
|
|
})
|
|
|
})
|
|
|
.unwrap_or(Vec::new())
|
|
|
|
|
|
|
|
|
.unwrap_or_else(Vec::new)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn generate_armor_list(&mut self, character_level: usize) -> Vec<ArmorShopItem> {
|
|
|
pub fn generate_armor_list(&mut self, character_level: usize) -> Vec<ArmorShopItem> {
|
|
@ -316,12 +318,12 @@ mod test { |
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_loading_tool_shop() {
|
|
|
fn test_loading_tool_shop() {
|
|
|
ArmorShop::<rand_chacha::ChaCha20Rng>::new();
|
|
|
|
|
|
|
|
|
ArmorShop::<rand_chacha::ChaCha20Rng>::default();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_generating_some_armor() {
|
|
|
fn test_generating_some_armor() {
|
|
|
let mut fs = ArmorShop::<rand_chacha::ChaCha20Rng>::new();
|
|
|
|
|
|
|
|
|
let mut fs = ArmorShop::<rand_chacha::ChaCha20Rng>::default();
|
|
|
for i in 0..200 {
|
|
|
for i in 0..200 {
|
|
|
fs.generate_armor_list(i);
|
|
|
fs.generate_armor_list(i);
|
|
|
}
|
|
|
}
|
|
|