diff --git a/src/item/mod.rs b/src/item/mod.rs new file mode 100644 index 0000000..f2bbd3e --- /dev/null +++ b/src/item/mod.rs @@ -0,0 +1,30 @@ +pub mod weapon; + +use std::io::{Read, Seek}; +use crate::{PSOPacketData, PacketParseError}; + + + +#[derive(Debug, Copy, Clone)] +pub enum Item { + Weapon(weapon::Weapon), + //Armor(Armor), + //Shield(Shield), + //Unit(Unit), + //Mag(Mag), + //Tool(Tool), +} + + +impl Item { + fn from_bytes(cursor: &mut R) -> Result { + unimplemented!() + } + pub fn as_bytes(&self) -> [u8; 16] { + match self { + Item::Weapon(wep) => wep.as_bytes(), + } + } + + +} diff --git a/src/item/weapon.rs b/src/item/weapon.rs new file mode 100644 index 0000000..127ef6a --- /dev/null +++ b/src/item/weapon.rs @@ -0,0 +1,138 @@ + +use std::io::{Read, Seek}; +use crate::{PSOPacketData, PacketParseError}; + + +#[derive(Debug, Copy, Clone)] +pub enum Attribute { + Native, + ABeast, + Machine, + Dark, + Hit +} + +#[derive(Debug, Copy, Clone)] +pub struct WeaponAttribute { + attr: Attribute, + value: u8, +} + + +#[derive(Debug, Copy, Clone)] +pub enum WeaponSpecial { + Draw, + Drain, + Fill, + Gush, + Heart, + Mind, + Soul, + Geist, + Masters, + Lords, + Kings, + Charge, + Spirit, + Berserk, + Ice, + Frost, + Freeze, + Blizzard, + Bind, + Hold, + Seize, + Arrest, + Heat, + Fire, + Flame, + Burning, + Shock, + Thunder, + Storm, + Tempest, + Dim, + Shadow, + Dark, + Hell, + Panic, + Riot, + Havoc, + Chaos, + Devils, + Demons, +} + + +#[derive(Debug, Copy, Clone)] +pub enum WeaponType { + Saber, + Handgun, + Cane, +} + +impl WeaponType { + fn value(&self) -> [u8; 3] { + match self { + WeaponType::Saber => [0x00, 0x01, 0x00], + WeaponType::Handgun => [0x00, 0x06, 0x00], + WeaponType::Cane => [0x00, 0x0A, 0x00], + } + } +} + + + +#[derive(Debug, Copy, Clone)] +pub struct Weapon { + pub weapon: WeaponType, + pub special: Option, + pub grind: u8, + pub attrs: [Option; 3], +} + + +impl Weapon { + pub fn new(&self, wep: WeaponType) -> Weapon { + Weapon { + weapon: wep, + special: None, + grind: 0, + attrs: [None; 3] + } + } + + pub fn as_bytes(&self) -> [u8; 16] { + let mut result = [0u8; 16]; + result[0..3].copy_from_slice(&self.weapon.value()); + result[3] = self.grind; + //result.extend_from_slice(&self.weapon.value()); + //result.push(self.grind); + + //result.extend_from_slice(&[0,0,0,0]); + //result.extend_from_slice(&[0,0,0,0]); + //result.extend_from_slice(&[0,0,0,0]); + + result + } +} + + +/*impl PSOPacketData for Weapon{ + fn from_bytes(cursor: &mut R) -> Result { + unimplemented!() + } + fn as_bytes(&self) -> Vec { + let mut result = Vec::new(); + result.extend_from_slice(&self.weapon.value()); + result.push(self.grind); + + result.extend_from_slice(&[0,0,0,0]); + result.extend_from_slice(&[0,0,0,0]); + result.extend_from_slice(&[0,0,0,0]); + + result + } + + +}*/ diff --git a/src/lib.rs b/src/lib.rs index 29e8953..8b48f4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ pub mod crypto; pub mod packet; pub mod character; pub mod util; +pub mod item; use std::io::{Read, Seek}; #[derive(Debug, PartialEq)]