From d0a84af1c3aa84b3b4cc4a4e75a8137876fde186 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 14 Mar 2020 20:49:29 -0700 Subject: [PATCH] load armor stats --- src/entity/item/armor.rs | 34 ++++++++--------- src/ship/item_stats.rs | 79 ++++++++++++++++++++++++++++++++++++++++ src/ship/mod.rs | 1 + 3 files changed, 97 insertions(+), 17 deletions(-) create mode 100644 src/ship/item_stats.rs diff --git a/src/entity/item/armor.rs b/src/entity/item/armor.rs index 8f2e658..d37bce0 100644 --- a/src/entity/item/armor.rs +++ b/src/entity/item/armor.rs @@ -1,6 +1,6 @@ use serde::{Serialize, Deserialize}; -#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display)] pub enum ArmorType { Frame, Armor, @@ -32,16 +32,16 @@ pub enum ArmorType { RevivalGarment, SpiritGarment, StinkFrame, - DPartsver101, - DPartsver210, - ParasiteWeardeRol, - ParasiteWearnelgal, - ParasiteWearvajulla, + DPartsVer101, + DPartsVer210, + ParasiteWearDeRol, + ParasiteWearNelgal, + ParasiteWearVajulla, SensePlate, GravitonPlate, AttributePlate, FlowensFrame, - CustomFrameveroo, + CustomFrameVerOo, DbsArmor, GuardWave, DfField, @@ -49,7 +49,7 @@ pub enum ArmorType { ChuChuFever, LoveHeart, FlameGarment, - VirusArmorlafuteria, + VirusArmorLafuteria, BrightnessCircle, AuraField, ElectroFrame, @@ -69,7 +69,7 @@ pub enum ArmorType { RedCoat, Thirteen, MotherGarb, - MotherGarb2, + MotherGarbPlus, DressPlate, Sweetheart, IgnitionCloak, @@ -125,16 +125,16 @@ impl ArmorType { ArmorType::RevivalGarment => [0x01, 0x01, 0x1B], ArmorType::SpiritGarment => [0x01, 0x01, 0x1C], ArmorType::StinkFrame => [0x01, 0x01, 0x1D], - ArmorType::DPartsver101 => [0x01, 0x01, 0x1E], - ArmorType::DPartsver210 => [0x01, 0x01, 0x1F], - ArmorType::ParasiteWeardeRol => [0x01, 0x01, 0x20], - ArmorType::ParasiteWearnelgal => [0x01, 0x01, 0x21], - ArmorType::ParasiteWearvajulla => [0x01, 0x01, 0x22], + ArmorType::DPartsVer101 => [0x01, 0x01, 0x1E], + ArmorType::DPartsVer210 => [0x01, 0x01, 0x1F], + ArmorType::ParasiteWearDeRol => [0x01, 0x01, 0x20], + ArmorType::ParasiteWearNelgal => [0x01, 0x01, 0x21], + ArmorType::ParasiteWearVajulla => [0x01, 0x01, 0x22], ArmorType::SensePlate => [0x01, 0x01, 0x23], ArmorType::GravitonPlate => [0x01, 0x01, 0x24], ArmorType::AttributePlate => [0x01, 0x01, 0x25], ArmorType::FlowensFrame => [0x01, 0x01, 0x26], - ArmorType::CustomFrameveroo => [0x01, 0x01, 0x27], + ArmorType::CustomFrameVerOo => [0x01, 0x01, 0x27], ArmorType::DbsArmor => [0x01, 0x01, 0x28], ArmorType::GuardWave => [0x01, 0x01, 0x29], ArmorType::DfField => [0x01, 0x01, 0x2A], @@ -142,7 +142,7 @@ impl ArmorType { ArmorType::ChuChuFever => [0x01, 0x01, 0x2C], ArmorType::LoveHeart => [0x01, 0x01, 0x2D], ArmorType::FlameGarment => [0x01, 0x01, 0x2E], - ArmorType::VirusArmorlafuteria => [0x01, 0x01, 0x2F], + ArmorType::VirusArmorLafuteria => [0x01, 0x01, 0x2F], ArmorType::BrightnessCircle => [0x01, 0x01, 0x30], ArmorType::AuraField => [0x01, 0x01, 0x31], ArmorType::ElectroFrame => [0x01, 0x01, 0x32], @@ -162,7 +162,7 @@ impl ArmorType { ArmorType::RedCoat => [0x01, 0x01, 0x40], ArmorType::Thirteen => [0x01, 0x01, 0x41], ArmorType::MotherGarb => [0x01, 0x01, 0x42], - ArmorType::MotherGarb2 => [0x01, 0x01, 0x43], + ArmorType::MotherGarbPlus => [0x01, 0x01, 0x43], ArmorType::DressPlate => [0x01, 0x01, 0x44], ArmorType::Sweetheart => [0x01, 0x01, 0x45], ArmorType::IgnitionCloak => [0x01, 0x01, 0x46], diff --git a/src/ship/item_stats.rs b/src/ship/item_stats.rs new file mode 100644 index 0000000..b86a84d --- /dev/null +++ b/src/ship/item_stats.rs @@ -0,0 +1,79 @@ +use std::collections::HashMap; +use serde::{Serialize, Deserialize}; +use std::fs::File; +use std::io::Read; + +use crate::entity::item::armor::ArmorType; + + + + + + + + +fn load_data_file(path: &str) -> T { + let mut f = File::open(path).unwrap(); + let mut s = String::new(); + f.read_to_string(&mut s); + + toml::from_str::(s.as_str()).unwrap() +} + + + + + + + +struct WeaponStats { + +} + +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] +struct ArmorStats { + stars: u32, + dfp: i32, + evp: i32, + dfp_modifier: u32, + evp_modifier: u32, + team_points: u32, + level_req: u32, + efr: i32, + eic: i32, + eth: i32, + elt: i32, + edk: i32, +} + +struct ShieldStats { + +} + +struct UnitStats { + +} + + + +fn armor_stats() -> HashMap { + let armor_stats: HashMap = load_data_file("data/item_stats/armor_stats.toml"); + armor_stats.iter() + .map(|(name, stats)| { + (name.parse().unwrap(), *stats) + }).collect() +} + + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_armor_stats() { + let astat = armor_stats(); + assert!(astat.get(&ArmorType::CrimsonCoat).unwrap().stars == 11); + } + + +} diff --git a/src/ship/mod.rs b/src/ship/mod.rs index 47662f2..1353f31 100644 --- a/src/ship/mod.rs +++ b/src/ship/mod.rs @@ -3,6 +3,7 @@ pub mod location; pub mod character; pub mod room; pub mod items; +pub mod item_stats; pub mod map; pub mod monster;