diff --git a/data/item_stats/tech_stats.toml b/data/item_stats/tech_stats.toml new file mode 100644 index 0000000..959a8d5 --- /dev/null +++ b/data/item_stats/tech_stats.toml @@ -0,0 +1,56 @@ +[Foie] +price = 100 + +[Gifoie] +price = 300 + +[Rafoie] +price = 450 + +[Zonde] +price = 100 + +[Gizonde] +price = 300 + +[Razonde] +price = 450 + +[Barta] +price = 100 + +[Gibarta] +price = 300 + +[Rabarta] +price = 450 + +[Grants] +price = 500 + +[Deband] +price = 100 + +[Jellen] +price = 100 + +[Zalure] +price = 100 + +[Shifta] +price = 100 + +[Ryuker] +price = 5000 + +[Resta] +price = 300 + +[Anti] +price = 100 + +[Reverser] +price = 5000 + +[Megid] +price = 500 diff --git a/data/item_stats/tool_stats.toml b/data/item_stats/tool_stats.toml new file mode 100644 index 0000000..1d69fcd --- /dev/null +++ b/data/item_stats/tool_stats.toml @@ -0,0 +1,92 @@ +[Monomate] +price = 50 + +[Dimate] +price = 300 + +[Trimate] +price = 2000 + +[Monofluid] +price = 100 + +[Difluid] +price = 500 + +[Trifluid] +price = 3600 + +[SolAtomizer] +price = 300 + +[MoonAtomizer] +price = 500 + +[StarAtomizer] +price = 5000 + +[Antidote] +price = 60 + +[Antiparalysis] +price = 60 + +[Telepipe] +price = 350 + +[TrapVision] +price = 100 + +[ScapeDoll] +price = 10000 + +[Monogrinder] +price = 5000 + +[Digrinder] +price = 10000 + +[Trigrinder] +price = 15000 + +[PowerMaterial] +price = 2400 + +[MindMaterial] +price = 2400 + +[EvadeMaterial] +price = 2400 + +[HpMaterial] +price = 2400 + +[TpMaterial] +price = 2400 + +[DefMaterial] +price = 2400 + +[LuckMaterial] +price = 2400 + +[PhotonDrop] +price = 8000 + +[PhotonSphere] +price = 16000 + +[PhotonCrystal] +price = 24000 + +[TeamPoints500] +price = 500 + +[TeamPoints1000] +price = 1000 + +[TeamPoints5000] +price = 5000 + +[TeamPoints10000] +price = 10000 diff --git a/src/ship/item_stats.rs b/src/ship/item_stats.rs index 953ecce..c2b72b3 100644 --- a/src/ship/item_stats.rs +++ b/src/ship/item_stats.rs @@ -10,6 +10,7 @@ use crate::entity::item::shield::ShieldType; use crate::entity::item::unit::UnitType; use crate::entity::item::mag::MagType; use crate::entity::item::tool::ToolType; +use crate::entity::item::tech::Technique; lazy_static::lazy_static! { @@ -17,6 +18,8 @@ lazy_static::lazy_static! { pub static ref ARMOR_STATS: HashMap = armor_stats(); pub static ref SHIELD_STATS: HashMap = shield_stats(); pub static ref UNIT_STATS: BTreeMap = unit_stats(); + pub static ref TOOL_STATS: HashMap = tool_stats(); + pub static ref TECH_STATS: HashMap = tech_stats(); } @@ -78,6 +81,17 @@ pub struct UnitStats { pub modifier: u32, } + +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] +pub struct ToolStats { + pub price: usize, +} + +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] +pub struct TechStats { + pub price: usize, +} + #[derive(Debug, Copy, Clone, Serialize, Deserialize)] pub struct MagStats { pub feed_table: u32, @@ -102,7 +116,6 @@ pub struct MagFeedTables(Vec); pub fn weapon_stats() -> HashMap { let weapon_stats: HashMap = load_data_file("data/item_stats/weapon_stats.toml"); weapon_stats.iter() - .inspect(|k| println!("{:?}", k)) .map(|(name, stats)| { (name.parse().unwrap(), *stats) }).collect() @@ -132,6 +145,22 @@ pub fn unit_stats() -> BTreeMap { }).collect() } +pub fn tool_stats() -> HashMap { + let tool_stats: HashMap = load_data_file("data/item_stats/tool_stats.toml"); + tool_stats.iter() + .map(|(name, stats)| { + (name.parse().unwrap(), *stats) + }).collect() +} + +pub fn tech_stats() -> HashMap { + let tech_stats: HashMap = load_data_file("data/item_stats/tech_stats.toml"); + tech_stats.iter() + .map(|(name, stats)| { + (name.parse().unwrap(), *stats) + }).collect() +} + pub fn mag_stats() -> HashMap { let mag_stats: BTreeMap = load_data_file("data/item_stats/mag_stats.toml"); mag_stats.iter() @@ -181,6 +210,18 @@ mod test { assert!(ustat.get(&UnitType::ElfArm).unwrap().stars == 5); } + #[test] + fn test_tool_stats() { + let tstat = tool_stats(); + assert!(tstat.get(&ToolType::Monomate).unwrap().price == 50); + } + + #[test] + fn test_tech_stats() { + let tstat = tech_stats(); + assert!(tstat.get(&Technique::Reverser).unwrap().price == 5000); + } + #[test] fn test_mag_stats() { let mstats = mag_stats(); diff --git a/src/ship/shops/tool.rs b/src/ship/shops/tool.rs index 1b3df5d..dbabc11 100644 --- a/src/ship/shops/tool.rs +++ b/src/ship/shops/tool.rs @@ -10,6 +10,8 @@ use crate::entity::character::SectionID; use crate::ship::room::Difficulty; use crate::entity::item::tool::{Tool, ToolType}; use crate::entity::item::tech::{Technique, TechniqueDisk}; +use crate::ship::shops::ShopItem; +use crate::ship::item_stats::{TOOL_STATS, TECH_STATS}; #[derive(Debug, PartialEq, Eq)] @@ -48,6 +50,28 @@ impl PartialOrd for ShopTool { } } +impl ShopItem for ShopTool { + fn price(&self) -> usize { + match self { + ShopTool::Tool(tool) => { + TOOL_STATS.get(&tool) + .map(|tool_stats| { + tool_stats.price + }) + .unwrap_or(0xFFFF) + }, + ShopTool::Tech(tech) => { + TECH_STATS.get(&tech.tech) + .map(|tech_stats| { + tech_stats.price * tech.level as usize + }) + .unwrap_or(0xFFFF) + } + } + } +} + + #[derive(Debug, Deserialize)] struct ToolTable(Vec);