|
@ -4,6 +4,7 @@ use serde::{Serialize, Deserialize}; |
|
|
use std::fs::File;
|
|
|
use std::fs::File;
|
|
|
use std::io::Read;
|
|
|
use std::io::Read;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::entity::item::weapon::WeaponType;
|
|
|
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;
|
|
@ -11,6 +12,11 @@ use crate::entity::item::mag::MagType; |
|
|
use crate::entity::item::tool::ToolType;
|
|
|
use crate::entity::item::tool::ToolType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lazy_static::lazy_static! {
|
|
|
|
|
|
pub static ref WEAPON_STATS: HashMap<WeaponType, WeaponStats> = weapon_stats();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn load_data_file<T: serde::de::DeserializeOwned>(path: &str) -> T {
|
|
|
fn load_data_file<T: serde::de::DeserializeOwned>(path: &str) -> T {
|
|
|
let mut f = File::open(path).unwrap();
|
|
|
let mut f = File::open(path).unwrap();
|
|
|
let mut s = String::new();
|
|
|
let mut s = String::new();
|
|
@ -20,8 +26,12 @@ fn load_data_file<T: serde::de::DeserializeOwned>(path: &str) -> T { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct WeaponStats {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
|
|
|
|
|
|
pub struct WeaponStats {
|
|
|
|
|
|
pub grind: usize,
|
|
|
|
|
|
pub atp_min: usize,
|
|
|
|
|
|
pub atp_max: usize,
|
|
|
|
|
|
pub shop_multiplier: f32,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
|
|
|
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
|
|
@ -86,6 +96,15 @@ pub struct MagFeedTable(HashMap<ToolType, MagFeedStats>); |
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
|
pub struct MagFeedTables(Vec<MagFeedTable>);
|
|
|
pub struct MagFeedTables(Vec<MagFeedTable>);
|
|
|
|
|
|
|
|
|
|
|
|
pub fn weapon_stats() -> HashMap<WeaponType, WeaponStats> {
|
|
|
|
|
|
let weapon_stats: HashMap<String, WeaponStats> = load_data_file("data/item_stats/weapon_stats.toml");
|
|
|
|
|
|
weapon_stats.iter()
|
|
|
|
|
|
.inspect(|k| println!("{:?}", k))
|
|
|
|
|
|
.map(|(name, stats)| {
|
|
|
|
|
|
(name.parse().unwrap(), *stats)
|
|
|
|
|
|
}).collect()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn armor_stats() -> HashMap<ArmorType, ArmorStats> {
|
|
|
pub fn armor_stats() -> HashMap<ArmorType, ArmorStats> {
|
|
|
let armor_stats: HashMap<String, ArmorStats> = load_data_file("data/item_stats/armor_stats.toml");
|
|
|
let armor_stats: HashMap<String, ArmorStats> = load_data_file("data/item_stats/armor_stats.toml");
|
|
|
armor_stats.iter()
|
|
|
armor_stats.iter()
|
|
@ -135,6 +154,12 @@ pub fn mag_feed_tables() -> MagFeedTables { |
|
|
mod test {
|
|
|
mod test {
|
|
|
use super::*;
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_weapon_stats() {
|
|
|
|
|
|
let wstat = weapon_stats();
|
|
|
|
|
|
assert!(wstat.get(&WeaponType::MadamsUmbrella).unwrap().atp_max == 280);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_armor_stats() {
|
|
|
fn test_armor_stats() {
|
|
|
let astat = armor_stats();
|
|
|
let astat = armor_stats();
|
|
|