jake
5 years ago
3 changed files with 97 additions and 17 deletions
@ -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<T: serde::de::DeserializeOwned>(path: &str) -> T {
|
|||
let mut f = File::open(path).unwrap();
|
|||
let mut s = String::new();
|
|||
f.read_to_string(&mut s);
|
|||
|
|||
toml::from_str::<T>(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<ArmorType, ArmorStats> {
|
|||
let armor_stats: HashMap<String, ArmorStats> = 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);
|
|||
}
|
|||
|
|||
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue