Browse Source

armor shop pricing

pbs
jake 4 years ago
parent
commit
8a9ced09ea
  1. 3
      src/ship/item_stats.rs
  2. 44
      src/ship/shops/armor.rs

3
src/ship/item_stats.rs

@ -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();
}

44
src/ship/shops/armor.rs

@ -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…
Cancel
Save