jake
5 years ago
5 changed files with 178 additions and 35 deletions
-
46src/item/armor.rs
-
18src/item/mod.rs
-
45src/item/shield.rs
-
64src/item/tool.rs
-
40src/item/weapon.rs
@ -0,0 +1,46 @@ |
|||
use std::convert::{TryFrom, Into};
|
|||
use std::io::{Read, Seek};
|
|||
use crate::{PSOPacketData, PacketParseError};
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
|||
pub enum ArmorType {
|
|||
Frame,
|
|||
Armor,
|
|||
}
|
|||
|
|||
impl ArmorType {
|
|||
pub fn value(&self) -> [u8; 3] {
|
|||
match self {
|
|||
ArmorType::Frame => [0x01, 0x01, 0x00],
|
|||
ArmorType::Armor => [0x01, 0x01, 0x00],
|
|||
}
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
// TODO: TryFrom<&str>
|
|||
// TODO Into<String>
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
|||
pub struct Armor {
|
|||
pub armor: ArmorType,
|
|||
pub dfp: u8,
|
|||
pub evp: u8,
|
|||
pub slots: u8,
|
|||
}
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
impl Armor {
|
|||
pub fn as_bytes(&self) -> [u8; 16] {
|
|||
let mut result = [0; 16];
|
|||
result[0..3].copy_from_slice(&self.armor.value());
|
|||
// TODO: other attrs
|
|||
|
|||
result
|
|||
}
|
|||
}
|
@ -0,0 +1,45 @@ |
|||
use std::convert::{TryFrom, Into};
|
|||
use std::io::{Read, Seek};
|
|||
use crate::{PSOPacketData, PacketParseError};
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
|||
pub enum ShieldType {
|
|||
Barrier,
|
|||
Shield,
|
|||
}
|
|||
|
|||
impl ShieldType {
|
|||
pub fn value(&self) -> [u8; 3] {
|
|||
match self {
|
|||
ShieldType::Barrier => [0x01, 0x02, 0x00],
|
|||
ShieldType::Shield => [0x01, 0x02, 0x01],
|
|||
}
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
// TODO: TryFrom<&str>
|
|||
// TODO Into<String>
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
|||
pub struct Shield {
|
|||
pub shield: ShieldType,
|
|||
pub dfp: u8,
|
|||
pub evp: u8,
|
|||
}
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
impl Shield {
|
|||
pub fn as_bytes(&self) -> [u8; 16] {
|
|||
let mut result = [0; 16];
|
|||
result[0..3].copy_from_slice(&self.shield.value());
|
|||
// TODO: other attrs
|
|||
|
|||
result
|
|||
}
|
|||
}
|
@ -0,0 +1,64 @@ |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
|||
pub enum ToolType {
|
|||
Monomate,
|
|||
Dimate,
|
|||
Trimate,
|
|||
Monofluid,
|
|||
Difluid,
|
|||
Trifluid,
|
|||
|
|||
ScapeDoll,
|
|||
}
|
|||
|
|||
|
|||
impl ToolType {
|
|||
pub fn is_stackable(&self) -> bool {
|
|||
match self {
|
|||
ToolType::Monomate => true,
|
|||
ToolType::Dimate => true,
|
|||
ToolType::Trimate => true,
|
|||
ToolType::Monofluid => true,
|
|||
ToolType::Difluid => true,
|
|||
ToolType::Trifluid => true,
|
|||
ToolType::ScapeDoll => false,
|
|||
}
|
|||
}
|
|||
|
|||
pub fn value(&self) -> [u8; 3] {
|
|||
match self {
|
|||
ToolType::Monomate => [0x03, 0x00, 0x00],
|
|||
ToolType::Monofluid => [0x03, 0x01, 0x00],
|
|||
_ => panic!()
|
|||
}
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
|||
pub struct Tool {
|
|||
pub tool: ToolType,
|
|||
pub count: usize,
|
|||
}
|
|||
|
|||
impl Tool {
|
|||
pub fn new(tool: ToolType, count: usize) -> Tool {
|
|||
Tool {
|
|||
tool: tool,
|
|||
count: count,
|
|||
}
|
|||
}
|
|||
|
|||
pub fn as_bytes(&self) -> [u8; 16] {
|
|||
let mut result = [0; 16];
|
|||
result[0..3].copy_from_slice(&self.tool.value());
|
|||
result[5] = self.count as u8;
|
|||
|
|||
result
|
|||
}
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue