bunch of item additions
This commit is contained in:
parent
477db05b24
commit
355de1a8a9
46
src/item/armor.rs
Normal file
46
src/item/armor.rs
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,7 @@
|
|||||||
pub mod weapon;
|
pub mod weapon;
|
||||||
|
pub mod tool;
|
||||||
|
pub mod armor;
|
||||||
|
pub mod shield;
|
||||||
|
|
||||||
use std::io::{Read, Seek};
|
use std::io::{Read, Seek};
|
||||||
use crate::{PSOPacketData, PacketParseError};
|
use crate::{PSOPacketData, PacketParseError};
|
||||||
@ -8,11 +11,11 @@ use crate::{PSOPacketData, PacketParseError};
|
|||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum Item {
|
pub enum Item {
|
||||||
Weapon(weapon::Weapon),
|
Weapon(weapon::Weapon),
|
||||||
//Armor(Armor),
|
Armor(armor::Armor),
|
||||||
//Shield(Shield),
|
Shield(shield::Shield),
|
||||||
//Unit(Unit),
|
//Unit(Unit),
|
||||||
//Mag(Mag),
|
//Mag(Mag),
|
||||||
//Tool(Tool),
|
Tool(tool::Tool),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -23,8 +26,17 @@ impl Item {
|
|||||||
pub fn as_bytes(&self) -> [u8; 16] {
|
pub fn as_bytes(&self) -> [u8; 16] {
|
||||||
match self {
|
match self {
|
||||||
Item::Weapon(wep) => wep.as_bytes(),
|
Item::Weapon(wep) => wep.as_bytes(),
|
||||||
|
Item::Armor(armor) => armor.as_bytes(),
|
||||||
|
Item::Shield(shield) => shield.as_bytes(),
|
||||||
|
Item::Tool(tool) => tool.as_bytes(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_stackable(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
Item::Tool(_) => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
45
src/item/shield.rs
Normal file
45
src/item/shield.rs
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
64
src/item/tool.rs
Normal file
64
src/item/tool.rs
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek};
|
|||||||
use crate::{PSOPacketData, PacketParseError};
|
use crate::{PSOPacketData, PacketParseError};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum Attribute {
|
pub enum Attribute {
|
||||||
Native,
|
Native,
|
||||||
ABeast,
|
ABeast,
|
||||||
@ -13,14 +13,14 @@ pub enum Attribute {
|
|||||||
Hit
|
Hit
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct WeaponAttribute {
|
pub struct WeaponAttribute {
|
||||||
attr: Attribute,
|
attr: Attribute,
|
||||||
value: u8,
|
value: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum WeaponSpecial {
|
pub enum WeaponSpecial {
|
||||||
Draw,
|
Draw,
|
||||||
Drain,
|
Drain,
|
||||||
@ -68,7 +68,7 @@ pub enum WeaponTypeError {
|
|||||||
UnknownWeapon(String)
|
UnknownWeapon(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum WeaponType {
|
pub enum WeaponType {
|
||||||
Saber,
|
Saber,
|
||||||
Handgun,
|
Handgun,
|
||||||
@ -76,7 +76,7 @@ pub enum WeaponType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl WeaponType {
|
impl WeaponType {
|
||||||
fn value(&self) -> [u8; 3] {
|
pub fn value(&self) -> [u8; 3] {
|
||||||
match self {
|
match self {
|
||||||
WeaponType::Saber => [0x00, 0x01, 0x00],
|
WeaponType::Saber => [0x00, 0x01, 0x00],
|
||||||
WeaponType::Handgun => [0x00, 0x06, 0x00],
|
WeaponType::Handgun => [0x00, 0x06, 0x00],
|
||||||
@ -108,7 +108,7 @@ impl Into<String> for WeaponType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct Weapon {
|
pub struct Weapon {
|
||||||
pub weapon: WeaponType,
|
pub weapon: WeaponType,
|
||||||
pub special: Option<WeaponSpecial>,
|
pub special: Option<WeaponSpecial>,
|
||||||
@ -118,7 +118,7 @@ pub struct Weapon {
|
|||||||
|
|
||||||
|
|
||||||
impl Weapon {
|
impl Weapon {
|
||||||
pub fn new(&self, wep: WeaponType) -> Weapon {
|
pub fn new(wep: WeaponType) -> Weapon {
|
||||||
Weapon {
|
Weapon {
|
||||||
weapon: wep,
|
weapon: wep,
|
||||||
special: None,
|
special: None,
|
||||||
@ -131,33 +131,9 @@ impl Weapon {
|
|||||||
let mut result = [0u8; 16];
|
let mut result = [0u8; 16];
|
||||||
result[0..3].copy_from_slice(&self.weapon.value());
|
result[0..3].copy_from_slice(&self.weapon.value());
|
||||||
result[3] = self.grind;
|
result[3] = self.grind;
|
||||||
//result.extend_from_slice(&self.weapon.value());
|
// TODO: percents
|
||||||
//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
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*impl PSOPacketData for Weapon{
|
|
||||||
fn from_bytes<R: Read + Seek>(cursor: &mut R) -> Result<Self, PacketParseError> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
fn as_bytes(&self) -> Vec<u8> {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user