|
@ -11,14 +11,56 @@ use crate::ship::room::Difficulty; |
|
|
use crate::entity::item::armor::ArmorType;
|
|
|
use crate::entity::item::armor::ArmorType;
|
|
|
use crate::entity::item::shield::ShieldType;
|
|
|
use crate::entity::item::shield::ShieldType;
|
|
|
use crate::entity::item::unit::UnitType;
|
|
|
use crate::entity::item::unit::UnitType;
|
|
|
|
|
|
use crate::ship::shops::ShopItem;
|
|
|
|
|
|
use crate::ship::item_stats::{ARMOR_STATS, SHIELD_STATS, UNIT_STATS};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
enum ShopArmor {
|
|
|
enum ShopArmor {
|
|
|
Frame(ArmorType, usize),
|
|
|
Frame(ArmorType, usize),
|
|
|
Barrier(ShieldType),
|
|
|
Barrier(ShieldType),
|
|
|
Unit(UnitType),
|
|
|
Unit(UnitType),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ARMOR_MULTIPLIER: f32 = 0.799999952;
|
|
|
|
|
|
const SHIELD_MULTIPLIER: f32 = 1.5;
|
|
|
|
|
|
const UNIT_MULTIPLIER: f32 = 1000.0;
|
|
|
|
|
|
|
|
|
|
|
|
impl ShopItem for ShopArmor {
|
|
|
|
|
|
fn price(&self) -> usize {
|
|
|
|
|
|
match self {
|
|
|
|
|
|
ShopArmor::Frame(frame, slot) => {
|
|
|
|
|
|
ARMOR_STATS.get(&frame)
|
|
|
|
|
|
.map(|frame_stats| {
|
|
|
|
|
|
let mut price = (frame_stats.dfp + frame_stats.evp) as f32;
|
|
|
|
|
|
price *= price;
|
|
|
|
|
|
price /= ARMOR_MULTIPLIER;
|
|
|
|
|
|
price += 70.0 * frame_stats.level_req as f32;
|
|
|
|
|
|
price += 70.0 * frame_stats.level_req as f32 * *slot as f32;
|
|
|
|
|
|
price as usize
|
|
|
|
|
|
})
|
|
|
|
|
|
.unwrap_or(0)
|
|
|
|
|
|
},
|
|
|
|
|
|
ShopArmor::Barrier(barrier) => {
|
|
|
|
|
|
SHIELD_STATS.get(&barrier)
|
|
|
|
|
|
.map(|barrier_stats| {
|
|
|
|
|
|
let mut price = (barrier_stats.dfp + barrier_stats.evp) as f32;
|
|
|
|
|
|
price *= price;
|
|
|
|
|
|
price /= SHIELD_MULTIPLIER;
|
|
|
|
|
|
price += 70.0 * barrier_stats.level_req as f32;
|
|
|
|
|
|
price as usize
|
|
|
|
|
|
})
|
|
|
|
|
|
.unwrap_or(0)
|
|
|
|
|
|
},
|
|
|
|
|
|
ShopArmor::Unit(unit) => {
|
|
|
|
|
|
UNIT_STATS.get(&unit)
|
|
|
|
|
|
.map(|unit_stats| {
|
|
|
|
|
|
(unit_stats.stars as f32 * UNIT_MULTIPLIER) as usize
|
|
|
|
|
|
})
|
|
|
|
|
|
.unwrap_or(0)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
|