armor shop pricing
This commit is contained in:
parent
52d4fe8495
commit
8a9ced09ea
@ -14,6 +14,9 @@ use crate::entity::item::tool::ToolType;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref WEAPON_STATS: HashMap<WeaponType, WeaponStats> = weapon_stats();
|
||||
pub static ref ARMOR_STATS: HashMap<ArmorType, ArmorStats> = armor_stats();
|
||||
pub static ref SHIELD_STATS: HashMap<ShieldType, ShieldStats> = shield_stats();
|
||||
pub static ref UNIT_STATS: BTreeMap<UnitType, UnitStats> = unit_stats();
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,14 +11,56 @@ use crate::ship::room::Difficulty;
|
||||
use crate::entity::item::armor::ArmorType;
|
||||
use crate::entity::item::shield::ShieldType;
|
||||
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 {
|
||||
Frame(ArmorType, usize),
|
||||
Barrier(ShieldType),
|
||||
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)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user