diff --git a/src/entity/character.rs b/src/entity/character.rs index 27eecaf..344b7db 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use libpso::character::character; use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; +use crate::entity::item::tech::Technique; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub enum CharacterClass { @@ -127,29 +128,6 @@ pub struct CharacterAppearance { } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub enum Technique { - Foie, - Gifoie, - Rafoie, - Zonde, - Gizonde, - Razonde, - Barta, - Gibarta, - Rabarta, - Grants, - Megid, - Shifta, - Deband, - Jellen, - Zalure, - Resta, - Anti, - Reverser, - Ryuker, -} - #[derive(Clone, Debug)] pub struct TechLevel(pub u8); diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index 8f20a8a..9dc4739 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -2,6 +2,7 @@ pub mod weapon; pub mod armor; pub mod shield; pub mod tool; +pub mod tech; pub mod unit; pub mod mag; @@ -55,6 +56,7 @@ pub enum ItemDetail { Shield(shield::Shield), Unit(unit::Unit), Tool(Tool), + TechniqueDisk(tech::TechniqueDisk) } impl ItemDetail { @@ -72,6 +74,7 @@ impl ItemDetail { ItemDetail::Shield(shield) => shield.as_bytes(), ItemDetail::Unit(unit) => unit.as_bytes(), ItemDetail::Tool(tool) => tool.as_bytes(), + ItemDetail::TechniqueDisk(tech) => tech.as_bytes(), } } } diff --git a/src/login/character.rs b/src/login/character.rs index c09087e..b7efa66 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -20,7 +20,8 @@ use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROO use crate::entity::item::{ItemDetail, ItemLocation, Tool}; use crate::entity::item::weapon::Weapon; use crate::entity::item::armor::Armor; -use crate::entity::character::{Character, CharacterClass, Technique, TechLevel}; +use crate::entity::item::tech::Technique; +use crate::entity::character::{Character, CharacterClass, TechLevel}; use crate::login::login::get_login_status; diff --git a/src/ship/drops/tech_table.rs b/src/ship/drops/tech_table.rs index 99acc7b..f739e78 100644 --- a/src/ship/drops/tech_table.rs +++ b/src/ship/drops/tech_table.rs @@ -4,8 +4,8 @@ use serde::{Serialize, Deserialize}; use rand::{Rng, SeedableRng}; use rand::distributions::{WeightedIndex, Distribution}; -use crate::entity::item::{ItemDetail, Tool as ToolDetail}; -use crate::entity::item::tool::{StackedTool, ToolType}; +use crate::entity::item::ItemDetail; +use crate::entity::item::tech::{Technique, TechniqueDisk}; use crate::ship::room::{Difficulty, Episode}; use crate::ship::map::MapVariantType; use crate::entity::character::SectionID; @@ -13,23 +13,81 @@ use crate::ship::drops::load_data_file; +#[derive(Debug, Serialize, Deserialize)] +struct TechniqueRateStat { + rate: u32, + min: i32, + max: i32, +} +#[derive(Debug, Serialize, Deserialize)] +struct TechniqueRate { + #[serde(rename = "Foie")] + foie: TechniqueRateStat, + #[serde(rename = "Gifoie")] + gifoie: TechniqueRateStat, + #[serde(rename = "Rafoie")] + rafoie: TechniqueRateStat, + #[serde(rename = "Zonde")] + zonde: TechniqueRateStat, + #[serde(rename = "Gizonde")] + gizonde: TechniqueRateStat, + #[serde(rename = "Razonde")] + razonde: TechniqueRateStat, + #[serde(rename = "Barta")] + barta: TechniqueRateStat, + #[serde(rename = "Gibarta")] + gibarta: TechniqueRateStat, + #[serde(rename = "Rabarta")] + rabarta: TechniqueRateStat, + #[serde(rename = "Grants")] + grants: TechniqueRateStat, + #[serde(rename = "Deband")] + deband: TechniqueRateStat, + #[serde(rename = "Jellen")] + jellen: TechniqueRateStat, + #[serde(rename = "Zalure")] + zalure: TechniqueRateStat, + #[serde(rename = "Shifta")] + shifta: TechniqueRateStat, + #[serde(rename = "Ryuker")] + ryuker: TechniqueRateStat, + #[serde(rename = "Resta")] + resta: TechniqueRateStat, + #[serde(rename = "Anti")] + anti: TechniqueRateStat, + #[serde(rename = "Reverser")] + reverser: TechniqueRateStat, + #[serde(rename = "Megid")] + megid: TechniqueRateStat, +} - - - +#[derive(Debug, Serialize, Deserialize)] +struct TechniqueRates { + area1: TechniqueRate, + area2: TechniqueRate, + area3: TechniqueRate, + area4: TechniqueRate, + area5: TechniqueRate, + area6: TechniqueRate, + area7: TechniqueRate, + area8: TechniqueRate, + area9: TechniqueRate, + area10: TechniqueRate, +} pub struct TechniqueTable { - + rates: TechniqueRates } impl TechniqueTable { pub fn new(episode: Episode, difficulty: Difficulty, section_id: SectionID) -> TechniqueTable { TechniqueTable { + rates: load_data_file(episode, difficulty, section_id, "tech_rate.toml") } } diff --git a/src/ship/drops/tool_table.rs b/src/ship/drops/tool_table.rs index 3757968..161610c 100644 --- a/src/ship/drops/tool_table.rs +++ b/src/ship/drops/tool_table.rs @@ -97,7 +97,8 @@ impl ToolTable { let tool_rates = self.rates.get_by_area(map_area).iter(); let tool_weights = WeightedIndex::new(tool_rates.clone().map(|(_, weights)| weights)).unwrap(); - match tool_rates.map(|(ttype, _)| ttype).nth(tool_weights.sample(rng)).unwrap() { + let tool = tool_rates.map(|(ttype, _)| ttype).nth(tool_weights.sample(rng)).unwrap(); + match tool { ToolRateType::Monomate => ToolType::Monomate, ToolRateType::Dimate => ToolType::Dimate, ToolRateType::Trimate => ToolType::Trimate, @@ -124,9 +125,8 @@ impl ToolTable { ToolRateType::ScapeDoll => ToolType::ScapeDoll, ToolRateType::PhotonDrop => ToolType::PhotonDrop, ToolRateType::Technique => todo!(), - //ToolRateType::Technique => self.tech_table.get_drop(area, rng), + //ToolRateType::Technique => self.tech_table.get_drop(map_area, rng), } - //let attribute_weights = WeightedIndex::new(&[rates.none, rates.native, rates.abeast, rates.machine, rates.dark, rates.hit]).unwrap(); } pub fn get_drop(&self, map_area: &MapVariantType, rng: &mut R) -> Option { diff --git a/src/ship/items.rs b/src/ship/items.rs index 10e7bd5..7f206fc 100644 --- a/src/ship/items.rs +++ b/src/ship/items.rs @@ -115,6 +115,7 @@ impl Hash for StackedItemKey { ItemDetail::Shield(s) => s.shield.value().hash(hasher), ItemDetail::Unit(u) => u.unit.value().hash(hasher), ItemDetail::Tool(t) => t.tool.value().hash(hasher), + ItemDetail::TechniqueDisk(t) => t.tech.hash(hasher), } } }