Browse Source

base impls for what weapontype needs

pull/3/head
jake 5 years ago
parent
commit
70584a4d01
  1. 25
      src/item/weapon.rs

25
src/item/weapon.rs

@ -1,3 +1,4 @@
use std::convert::{TryFrom, Into};
use std::io::{Read, Seek};
use crate::{PSOPacketData, PacketParseError};
@ -63,6 +64,9 @@ pub enum WeaponSpecial {
Demons,
}
pub enum WeaponTypeError {
UnknownWeapon(String)
}
#[derive(Debug, Copy, Clone)]
pub enum WeaponType {
@ -81,6 +85,27 @@ impl WeaponType {
}
}
impl TryFrom<&str> for WeaponType {
type Error = WeaponTypeError;
fn try_from(value: &str) -> Result<WeaponType, WeaponTypeError> {
match value {
"Saber" => Ok(WeaponType::Saber),
"Handgun" => Ok(WeaponType::Handgun),
"Cane" => Ok(WeaponType::Cane),
_ => Err(WeaponTypeError::UnknownWeapon(value.to_string()))
}
}
}
impl Into<String> for WeaponType {
fn into(self) -> String {
match self {
WeaponType::Saber => "Saber",
WeaponType::Handgun => "Handgun",
WeaponType::Cane => "Cane",
}.to_string()
}
}
#[derive(Debug, Copy, Clone)]

Loading…
Cancel
Save